PEM_read_PrivateKey
call PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u)


{
if (!PEM_bytes_read_bio(&data, &len, &nm, PEM_STRING_EVP_PKEY, bp, cb, u))
                return NULL;
        p = data;

        if (strcmp(nm,PEM_STRING_RSA) == 0)
                ret=d2i_PrivateKey(EVP_PKEY_RSA,x,&p,len);
        else if (strcmp(nm,PEM_STRING_DSA) == 0)
                ret=d2i_PrivateKey(EVP_PKEY_DSA,x,&p,len);
        else if (strcmp(nm,PEM_STRING_ECPRIVATEKEY) == 0)
                ret=d2i_PrivateKey(EVP_PKEY_EC,x,&p,len);
}
the cert nm find -----BEGIN EC PRIVATE KEY-----
then call
ret=d2i_PrivateKey(EVP_PKEY_EC,x,&p,len);
id d2i_PrivateKey()

#ifndef OPENSSL_NO_EC
        case EVP_PKEY_EC:
if ((ret->pkey.ec = d2i_ECPrivateKey(NULL, (const unsigned char **)pp, length)) == NULL)
                        {
                        //ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
                        goto err;
                        }
                break;
#endif
so last it's call       
 d2i_ECPrivateKey
but my ec curve is not in openssl curve list so it's error to read private key

From: "Rajeshwar Singh Jenwar" <[EMAIL PROTECTED]>
Reply-To: openssl-users@openssl.org
To: openssl-users@openssl.org
Subject: Re: i am confused in PEM_read_PrivateKey
Date: Wed, 14 Jun 2006 09:49:04 +0530

Hi Girish,

Can u explain how d2i is indeed getting resolve to d2i_RSAPrivateKey() ?

RSJ


On 6/13/06, Girish Venkatachalam <[EMAIL PROTECTED]> wrote:

Sorry I was wrong. d2i indeed resolves to
d2i_RSAPrivateKey() which takes 3 parameters and
passes the first type parameter to d2i_PrivateKey()
which takes 4 parameters.

But it beats me why I cannot find the definition of
d2i_RSAPrivateKey() anywhere.

--- Rajeshwar Singh Jenwar <[EMAIL PROTECTED]> wrote:

> how come ? plz explain.
>
> On 6/13/06, Girish Venkatachalam
> <[EMAIL PROTECTED]> wrote:
> >
> > bcoz d2i resolves to d2i_X509() , not to
> > d2i_PrivateKey
> >
> > --- 锟斤拷 锟斤拷锟斤拷 <[EMAIL PROTECTED]>
> wrote:
> >
> > > when i use PEM_read_PrivateKey find it work
> error
> > > ,so i look into
> > > PEM_read_PrivateKey to find the reason.
> > > first i find in
> > > #define       PEM_read_PrivateKey(fp,x,cb,u)
> (EVP_PKEY
> > > *)PEM_ASN1_read( \
> > >       (char
> > >
> *(*)())d2i_PrivateKey,PEM_STRING_EVP_PKEY,fp,(char
> > > **)x,cb,u)
> > > next i find in
> > > void *PEM_ASN1_read(d2i_of_void *d2i, const char
> > > *name, FILE *fp, void **x,
> > >                   pem_password_cb *cb, void *u)
> > >       {
> > >         BIO *b;
> > >         void *ret;
> > >
> > >         if ((b=BIO_new(BIO_s_file())) == NULL)
> > >               {
> > >
> PEMerr(PEM_F_PEM_ASN1_READ,ERR_R_BUF_LIB);
> > >                 return(0);
> > >               }
> > >         BIO_set_fp(b,fp,BIO_NOCLOSE);
> > >
> ret=PEM_ASN1_read_bio(d2i,name,b,x,cb,u);
> > >         BIO_free(b);
> > >         return(ret);
> > >       }
> > > then i goto
> > > void *PEM_ASN1_read_bio(d2i_of_void *d2i, const
> char
> > > *name, BIO *bp, void
> > > **x,
> > >                       pem_password_cb *cb, void
> *u)
> > >       {
> > >       const unsigned char *p=NULL;
> > >       unsigned char *data=NULL;
> > >       long len;
> > >       char *ret=NULL;
> > >
> > >       if (!PEM_bytes_read_bio(&data, &len, NULL,
> name,
> > > bp, cb, u))
> > >               return NULL;
> > >       p = data;
> > >       ret=d2i(x,&p,len);
> > >       if (ret == NULL)
> > >
> PEMerr(PEM_F_PEM_ASN1_READ_BIO,ERR_R_ASN1_LIB);
> > >       OPENSSL_free(data);
> > >       return(ret);
> > >       }
> > > i found the ret=d2i(x,&p,len);
> > > but the function is
> > > EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a,
> > > const unsigned char **pp,
> > >            long length)
> > > i think d2i must have 4 parameter but is only
> > > three,why? Thanks a lot!
> > >
> > >
> >
>
_________________________________________________________________
> > > 锟斤拷锟斤拷锟斤拷锟?MSN Explorer:
> > > http://explorer.msn.com/lccn/
> > >
> > >
> >
>
______________________________________________________________________
> > > OpenSSL Project
> > > http://www.openssl.org
> > > User Support Mailing List
> > > openssl-users@openssl.org
> > > Automated List Manager
> > > [EMAIL PROTECTED]
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
>
______________________________________________________________________
> > OpenSSL Project
> http://www.openssl.org
> > User Support Mailing List
> openssl-users@openssl.org
> > Automated List Manager
> [EMAIL PROTECTED]
> >
>
>
>
> --
> Njoy
> RSJ
> "When life does not find a singer to sing her heart,
>   she produces a philosopher to speak her mind."
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
______________________________________________________________________
OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]




--
Njoy
RSJ
"When life does not find a singer to sing her heart,
 she produces a philosopher to speak her mind."

_________________________________________________________________
免费下载 MSN Explorer: http://explorer.msn.com/lccn/
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to