> From: [email protected] On Behalf Of heiko vonsachsen > Sent: Thursday, 06 May, 2010 11:26
> EVP_PKEY* pkey=PEM_read_bio_PUBKEY(mem,NULL,NULL,NULL) does not return any > value...can anybody please explaine me why? i've spend hours without any results! ... > char* key = "MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEwiljC8QSd5Q89jqg+Qk5KmFXdbbR+006PMkmr9e GEmDTsB9GVY9OTx8+b3nNqdMS"; ... > BIO* b64 = BIO_new(BIO_f_base64()); > BIO* mem = BIO_new(BIO_s_mem()); > BIO_puts(mem,key); > mem = BIO_push(b64,mem); > EVP_PKEY* pkey=PEM_read_bio_PUBKEY(mem,NULL,NULL,NULL); First, b64BIO input by default *requires* PEM-style lines: not more than IIRC 76 chars each terminated by \n . Either change the data you supply to it accordingly or override with BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL). Second, after you have unbase64ed the data, it is NOT in PEM format and PEM_read has no hope of handling it. Use d2i_PUBKEY_bio instead. Alternatively create a valid PEM format in memBIO: dash-BEGIN *line*, base64 *lines* with terminators, dash-END *line*, and PEM_read that. In fact you don't really need to go through b64BIO to unbase64 a small chunk like this. You could just EVP_DecodeBlock into a buffer, and d2i_PUBKEY (not _bio or _fp) on the buffer. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [email protected] Automated List Manager [email protected]
