Hi all

I had been in trouble in reading PKCS8 Private Key

by calling PEM_read_bio_PrivateKey(bp,NULL,NULL,pass)

I finally found that p12_key.c PKCS12_key_gen_asc following function should be replace 
by

int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
        int saltlen, int id, int iter, int n, unsigned char *out,
        const EVP_MD *md_type)
{
   int ret;
   unsigned char *unipass;
   int uniplen;
   if(!pass) {
      unipass = NULL;
      uniplen = 0;
   } else {
      pass[passlen]=0x00;   /* modified */
      if (!asc2uni(pass, &unipass, &uniplen)) {
         PKCS12err(PKCS12_F_PKCS12_KEY_GEN_ASC,ERR_R_MALLOC_FAILURE);
         return 0;
      }
   }
   ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen,
                   id, iter, n, out, md_type);
   if(unipass) {
      memset(unipass, 0, uniplen);  /* Clear password from memory */
      OPENSSL_free(unipass);
   }
   return ret;
}

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

Reply via email to