Okay, I'll admit straight off that I am a openssl noob.

 

First off,  I've been struggling with the documentation trying to work
out what I'm supposed to do and found that the documentation on
openssl.org is very sparse, so is there some commercial documentation I
can but for libcrypto?

 

If not then I have only extreme admiration for those people that can
turn the sparcity of documentation in to working programs :-)

 

So I've been trawling through the documentation and the header files to
try to solve my problem but whilst I think I have been fairly
successful, I am now at a blockage.

 

I have to write an application that will encrypt a certain portion of
the data using a X509 certificate's public RSA key. I have the
certificate loaded and think I managed to encrypt the data using the
public RSA key but now need to convert that to base64, I think?

 

Is there a base64 encoder in libcrypto or a method of encrypting and
encoding at the same time or should I use an external base64 encoder?

 

Anyhow, could someone tell me if I have gone the right way for what I am
attempting to do?

 

What I did was

 

1)       Load the certificate from a file using PEM_read_X509

2)       extracted the X509 public key from the loaded certificate using
X509_get_pubkey in to x509PublicKey

3)       extracted the RSA public key from the extracted X509 public key
using x509PublicKey->pkey.rsa in to rsaPublicKey

4)       encrypted the data using rsaPublicKey->RSA_public_encrypt into
encryptedBuffer

 

So I know that is not an executable example but it is the sequence that
I have used the libcrypto elements, so is it right or did I miss out on
anything?

 

Also, one thing that is nagging at me, is whether I need to delete the
pointer I receive X509_get_pubkey?

 

TIA.

 

Reply via email to