OpenSSL key format help

Hi All,


I have my public key as an "unsigned char*".

How can I convert it into RSA *publickey format?



Code:
unsigned char *pkey = "-----BEGIN PUBLIC KEY-----\n" +
        
"MIIBPAIBAAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNwL4lYKbpzzlmC5beaQXeQ\n" +
        
"2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAAQJBALjkK+jc2+iihI98riEF\n" +
        
"oudmkNziSRTYjnwjx8mCoAjPWviB3c742eO3FG4/soi1jD9A5alihEOXfUzloenr\n" +
        
"8IECIQD3B5+0l+68BA/6d76iUNqAAV8djGTzvxnCxycnxPQydQIhAMXt4trUI3nc\n" +
        
"a+U8YL2HPFA3gmhBsSICbq2OptOCnM7hAiEA6Xi3JIQECob8YwkRj29DU3/4WYD7\n" +
        
"WLPgsQpwo1GuSpECICGsnWH5oaeD9t9jbFoSfhJvv0IZmxdcLpRcpslpeWBBAiEA\n" +
                "6/5B8J0GHdJq89FHwEG/H2eVVUYu5y/aD6sgcm+0Avg=\n" +
                "-----END PUBLIC KEY-----\n" ;


RSA *pubkey;

pubkey = (RSA*)pkey;
I know this is wrong but dunno what is the right way.

Please help.
 
telltera said:
Hi All,


I have my public key as an "unsigned char*".

How can I convert it into RSA *publickey format?

You will find some examples in /usr/src/crypto/openssl/demos
demos/eay/loadrsa.c may help :
Code:
/* This is a simple program to generate an RSA private key.  It then
 * saves both the public and private key into a char array, then
 * re-reads them.  It saves them as DER encoded binary data.
 */
 
Back
Top