c - Extract RSA public key from a x509 char array with openssl -
Here is a certificate in the x509 format that stores the public key and module:
< Code> Const unsigned char * DataBytes = {/ * Data *};Using OpenSSL and C, how can I convert it to an RSA object? I have tried many ways but I do not have to work it in
RSA_public_encrypt
Can get it.I think you mean public key in RSA * structure.
Since this DER is in encoded bytes, you have a certificate in bytes, so you have to convert it to the X509 * structure first. / P>
X509 * cert; EVP_PKEY * Pabki; // Length is the duration of the certificate in terms of bytes DataBytes. Cert = d2i_x509 (certificate data bytes, length); Pabki = X509_get_pubkey (certificate); Please note that if RSA is a public key in the certificate, then you can get RSA public key as follows:
RSA * RSA RSA = EVP_PKEY_get1_RSA (Pabki); // Now RSA is a public key, RSA is the public key. // After using, Pipki EVP_PKEY_free (Pabki) is free;
I hope this should solve your objective. If the certificate encoding is different, then use a different function, once you get x 50 9 *, the rest of the steps are the same.
Comments
Post a Comment