To read the key from your header file you might want to use a memory BIO in
conjunction with the PEM_read_bio_PUBKEY function or
PEM_read_bio_RSAPublicKey ( I don't remember which one you should use, but
this was answered in this list before). I don't have a test enviroment
right now, but you should do something like this:

char key[] = "Your pem key goes here";

BIO *mem = BIO_new(BIO_s_mem());
BIO_puts(mem, key);
EVP_PKEY* pkey=PEM_read_bio_PUBKEY(mem,NULL,NULL,NULL);

...



2013/3/29 Zach <lace...@roboticresearch.com>

> The reason I want to put the public key into the header file is to
> simply make it easier to use the software (you can do the public key
> encryption of some data with only the binary file, not the binary and
> another file).  Thus, I don't want to read a PEM file from the disk, but
> rather from memory.
>
> Thank you very much for your link for EVP_Seal*.  I'll have a look.
>
> On 03/29/2013 11:41 AM, Matt Caswell wrote:
> > On 29 March 2013 15:09, Zach <lace...@roboticresearch.com> wrote:
> >> I'm trying to do the following:
> >> 1) Put a base64-encoded key (the normal one generated by openssl command
> >> line tools) into a header file
> > Do you mean to put the actual key itself hardcoded into the header
> > file?? This seems like a strange thing to do.
> >
> > PEM files can be read using the various functions described here:
> > http://www.openssl.org/docs/crypto/pem.html
> >
> >
> >> 2) Compile code with this key which will public-key encrypt a message.
> >>
> > To encrypt a message you need to use the EVP_Seal* functions described
> here:
> >
> http://wiki.opensslfoundation.com/index.php/EVP_Asymmetric_Encryption_and_Decryption_of_an_Envelope
> > http://www.openssl.org/docs/crypto/EVP_SealInit.html
> >
> >
> > Matt
> > ______________________________________________________________________
> > OpenSSL Project                                 http://www.openssl.org
> > User Support Mailing List                    openssl-users@openssl.org
> > Automated List Manager                           majord...@openssl.org
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
>



-- 
Felipe Menegola Blauth

Reply via email to