Your RSA public key is not pure DER encoded, it's DER+base64 encoded. d2i_* functions take pure DER objects (binary on the wire).
-- Erwann ABALEA ----- multicoprothalassotope: station balnéaire de la Méditerranée Le 16/11/2012 15:37, PraveenPVS a écrit :
Hi, I need to load RSA Public key which is stored in the char buffer. I came across d2i_RSA_PUBKEY function to do the same (Please correct me if I am wrong here). When I use this function, RSA Public key is not getting loaded. In the main, i have the following function call: loadRSAPubKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0yepYbVklwYuwGEmenQhVwyddHGdM26rZqWG5tFFPYz1QA51EJ44thSejrbRKHqV/EmqU8wwuFeaDmxnVz6UhG3HfjuTbAkkuZ+boEIealr/Ml+kHqRgzQ6G1rP9+5goboZzlpB9b8zYvp+5my5xFCd8OqyoKKyoHBJ3Tf0NCSstow7k0W/5JMeDa844HpCK4rOxlUaIGsDGTC/XIJ93EQs8yT4js5iw++pJslQvh1RzeQtzLQ8xNGYKlr9RyIvh2S28qXb+qfEx7r+kG8RjS4jc3E3XR/nja7HXnAFWCgF/cRcj5aQHq02scW8Vi+iBS/A1Y5RD2QMxJqY1yxC28QIDAQAB"); int loadRSAPubKey(char *key) { const unsigned char *p = key; int keylen = strlen(key); prsa_loaded = (RSA *)d2i_RSAPublicKey(NULL, &p, keylen); if(!prsa_loaded) { printf("Failed to load RSA key\n"); exit(0); } return 1; } It was always saying "Failed to load RSA Key" and exiting... Am i missing something here?? Could you please help me out. Thank you. regards Praveen
______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org