I'm having a little trouble understanding what function to use to load my key into an RSA.
I get the key in string form like this from a local database:
-----begin public key----- migfma0gcsqgsib3dqebaquaa4gnadcbiqkbgqdcz4npasjgxrcv8fwqcrdw+cze 76l3inzil3mquizvuyyn5heqqsrvg7/4mu1czc5fghcuk2pbfjgk9ev3xz6soxpk pkhkxot87xgkmi1hulszcyouhvrtgkgcbk/kuktqozklgbolxf+cxigdptpgareg dp+6ieuziwsfpjrkjwidaqab -----end public key-----
then I try something like this (in objective-c):
long len = [key length];
const unsigned char *p = (unsigned char *)[key UTF8String];
RSA *r = d2i_RSA_PUBKEY(NULL, &p, len);
r always comes back null so I'm doing something wrong there. I've tried a few other things but I'm just missing it I guess. The ultimate goal is to create an RSA from my public key, and then use something like
RSA_public_encrypt ( 1, hash, secret, r, RSA_PKCS1_OAEP_PADDING );
To encrypt a hash, but I'm stuck on loading my keys :) Any help is appreciated.
Thank you.
ERR_get_error()to obtaion information about OpenSSL error.