This has hit the list a couple of times and I seem to making great progress thanks a lot to Jim. I believe I am now in the process of compiling and I have one final compile issue left.
PEM_read_bio_RSAPrivateKey() returns a BIO *, not a EVP_PKEY *. So, I am passing the wrong argument type when I call EVP_PKEY_get1_RSA(). Did I use the wrong call, or am I missing a call? Thanks! On 7/5/07, John T. Cox <[EMAIL PROTECTED]> wrote:
You've been very helpful Jim. I grabbed "Network Security with OpenSSL" on Safari and have been reading the relevant sections. If I understand correctly, to read an external file, decrypt it using an internal private key and write the decrypted out to internal data, I would do: void fn(char *infile) { char *pk_data = NULL; int keysize = 0; unsigned char rsa_in = NULL; unsigned char rsa_out = NULL; unsigned char pad = RSA_PKCS1_PADDING; BIO *in = NULL; BIO *out = NULL; BIO *pk_bio = NULL; EVP_PKEY *pkey = NULL; RSA *rsa = NULL; pk_data = get_internal_data(); pk_bio = BIO_new_mem_buf(pk_data, strlen(pk_data)); pkey = PEM_read_bio_RSAPrivateKey(pk_bio, NULL, 0, NULL); rsa = EVP_PKEY_get1_RSA(pkey); in = BIO_new_file(infile, "rb") out = BIO_new_mem_buf(data, DATA_SIZE); keysize = RSA_size(rsa); rsa_in = OPEN_malloc(keysize *2); rsa_out = OPENSSL_malloc(keysize); rsa_inlen = BIO_read(in, rsa_in, keysize * 2); rsa_outlen = RSA_private_decrypt(rsa_inlen, rsa_in, rsa_out, rsa, padding); } I realize, I need some error handling. But, I want to make sure I understand the interoperability of the core calls and that my process is correct.
-- ============================================================================== John T. Cox e-mail [EMAIL PROTECTED] www http://members.iglou.com/vampire ============================================================================== ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]