On 16 Nov 2012, at 4:37 PM, PraveenPVS <[email protected]> wrote:
> 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).
The "d2i" in the function you're trying to use means "from DER encoded to
internal", you'll see a whole lot of complementary functions with "i2d" in them
that do the opposite.
The data you've shown looks like it has been PEM encoded, not DER encoded:
> loadRSAPubKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0yepYbVklwYuwGEmenQhVwyddHGdM26rZqWG5tFFPYz1QA51EJ44thSejrbRKHqV/EmqU8wwuFeaDmxnVz6UhG3HfjuTbAkkuZ+boEIealr/Ml+kHqRgzQ6G1rP9+5goboZzlpB9b8zYvp+5my5xFCd8OqyoKKyoHBJ3Tf0NCSstow7k0W/5JMeDa844HpCK4rOxlUaIGsDGTC/XIJ93EQs8yT4js5iw++pJslQvh1RzeQtzLQ8xNGYKlr9RyIvh2S28qXb+qfEx7r+kG8RjS4jc3E3XR/nja7HXnAFWCgF/cRcj5aQHq02scW8Vi+iBS/A1Y5RD2QMxJqY1yxC28QIDAQAB");
To convert the PEM encoding, try wrap your buffer in a BIO and call
PEM_read_bio_X509(). "man PEM_read_bio_X509" for details. Make sure you
preserve the "-----" bars before and after the PEM encoded certificate, as they
form part of the PEM encoding and your data may be ignored if you chop them off.
Regards,
Graham
--
smime.p7s
Description: S/MIME cryptographic signature
