Erwann ABALEA wrote:
> 
> On Mon, 13 Dec 1999, Dr Stephen Henson wrote:
> 
> > Erwann ABALEA wrote:
> > >
> > > Could I suggest to add this in the default .h files?:
> > >
> > > #define d2i_PrivateKey_bio(bp,x) (EVP_PKEY *)ASN1_d2i_bio(\
> > >         (char *(*)())EVP_PKEY_new, (char *(*)())d2i_PrivateKey, bp, \
> > >         (unsigned char **)x)
> > >
> > > I wanted to be able to save my private keys in DER format, and read them
> > > later... I didn't find the macro/function to do it... Unfortunately, my
> > > definition doesn't handle encrypted keys...
> > >
> >
> > One minor problem... d2i_PrivateKey doesn't exist!
> >
> > DER encoded private keys are a bit of a problem because you can't
> > automatically tell the format (unlike PEM keys where you can read the
> > header lines). This means you have to know the format in advance so
> > you'd need separate versions for RSA, DSA, PKCS#8 unencrypted and PKCS#8
> > encryped.
> 
> But it works for me! The d2i_PrivateKey function exists, at least in the
> 0.9.4 version...
> 
> For DER encoded keys, I have to know in advance the format of the key
> (RSAPrivateKey or PKCS#8), but that's not a problem (I don't like idiot
> users working with security... ;-) ).
> 

Yes you are right. Urk I missed that: I was looking in the wrong place.

There is a problem though (I think!). d2i_PrivateKey() has the
prototype:

EVP_PKEY *      d2i_PrivateKey(int type,EVP_PKEY **a,
                        unsigned char **pp, long length);

whereas ASN1_d2i_bio() normally calls functions like:

RSA *   d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);

So it will need some extra functionality to handle this. Anyway the
macros are now all #ifdef'ed out so this will end up as functions.

I do agree though. We need some DER+{BIO,fp} versions of the EVP_PKEY
stuff and PKCS#8. I'll see about adding them.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to