Chris Brook wrote:
> 
> I notice when using d2i_PUBKEY() to convert a string RSA
> SubjectPublicKeyInfo to an EVP_PKEY struct that the string pointer ends up
> pointing to random memory.

The function 
'EVP_PKEY * d2i_PUBKEY(EVP_PKEY **a,unsigned char **pp, long length)'
modifies the pointer *pp ( *pp += length ).

> Is this deliberate (e.g. for security reasons)
> or a bug?

It's not a bug (I guess it simplifies programming)

> I would like to have the public key string still available when
> the function returns (without copying and restoring every time).

save the pointer, i.e. :

unsigned char *buffer; // points to the binary SubjectPublicKeyInfo 
                       // structure
long len;              // the length of the buffer
....
unsigned char *p = buffer;
EVP_PKEY *key = d2i_PUBKEY(NULL, &p, len);

Regards,
Nils
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to