On Fri August 29 2008 11:35, Michael Luich wrote: > Hello everyone, here's what's driving me nuts. I'm sure i'm missing > something simple, but why isn't the encrypted message coming out of " > BIO_get_mem_data(out, &enc_msg); " Null terminated ? >
Because null is a valid encrypted value of a byte. Mike > Full code below. > > Mike Luich > > > fprintf (stderr, "ENTER: %s in %s, line %d.\n", > __FUNCTION__, __FILE__, __LINE__); > > > const EVP_CIPHER *cipher= EVP_des_ede3_cbc(); > STACK_OF(X509) *certs= sk_X509_new_null(); > X509 *tmp; > BIO *in, *out, *b64_bio; > PKCS7 *pkcs7; > char *enc_msg, *ptr; > > OpenSSL_add_all_algorithms(); > ERR_load_crypto_strings(); > RAND_load_file("/dev/urandom", 1024); > > fprintf (stderr, "START: %s in %s, line %d.\n", > __FUNCTION__, __FILE__, __LINE__); > > in = BIO_new_mem_buf(clear_msg, -1); > out = BIO_new(BIO_s_mem()); > > if (!(tmp = PEM_read_X509(pub_cert, NULL, NULL, NULL))) { > fprintf (stderr, "Error Opening Public Key"); > } > sk_X509_push(certs,tmp); > fclose (pub_cert); > > if (!(pkcs7 = PKCS7_encrypt(certs, in, cipher, PKCS7_BINARY))) { > fprintf (stderr,"Error making PKC#7object : %s in %s, line %d.\n", > __FUNCTION__, __FILE__, __LINE__); > } > > if (SMIME_write_PKCS7(out, pkcs7, in, 0) !=1) > { > fprintf (stderr,"Error writing SMIME : %s in %s, line %d.\n", > __FUNCTION__, __FILE__, __LINE__); > } > > fprintf (stderr,"Encryption success : %s in %s, line %d.\n", > __FUNCTION__, __FILE__, __LINE__); > > BIO_get_mem_data(out, &enc_msg); > > fprintf (stderr,"Data out of bio: %s in %s, line %d.\n %s\n", > __FUNCTION__, __FILE__, __LINE__, enc_msg); > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]