Changes between 0.9.4 and 0.9.5 [xx XXX 1999]
+ *) Add d2i,i2d bio/fp functions for PrivateKey: these convert the
+ traditional format into an EVP_PKEY structure.
+ [Steve Henson]
+
*) Add a password callback function PEM_cb() which either prompts for
a password if usr_data is NULL or otherwise assumes it is a null
- terminate password. Allow passwords to be passed on command line
+ terminated password. Allow passwords to be passed on command line
environment or config files in a few more utilities.
[Steve Henson]
#define ASN1_F_D2I_POLICYINFO 269
#define ASN1_F_D2I_POLICYQUALINFO 270
#define ASN1_F_D2I_PRIVATEKEY 155
+#define ASN1_F_D2I_PRIVATEKEY_BIO 293
+#define ASN1_F_D2I_PRIVATEKEY_FP 294
#define ASN1_F_D2I_PUBLICKEY 156
#define ASN1_F_D2I_RSAPRIVATEKEY 157
#define ASN1_F_D2I_RSAPUBLICKEY 158
{ERR_PACK(0,ASN1_F_D2I_POLICYINFO,0), "d2i_POLICYINFO"},
{ERR_PACK(0,ASN1_F_D2I_POLICYQUALINFO,0), "d2i_POLICYQUALINFO"},
{ERR_PACK(0,ASN1_F_D2I_PRIVATEKEY,0), "d2i_PrivateKey"},
+{ERR_PACK(0,ASN1_F_D2I_PRIVATEKEY_BIO,0), "d2i_PrivateKey_bio"},
+{ERR_PACK(0,ASN1_F_D2I_PRIVATEKEY_FP,0), "d2i_PrivateKey_fp"},
{ERR_PACK(0,ASN1_F_D2I_PUBLICKEY,0), "d2i_PublicKey"},
{ERR_PACK(0,ASN1_F_D2I_RSAPRIVATEKEY,0), "d2i_RSAPrivateKey"},
{ERR_PACK(0,ASN1_F_D2I_RSAPUBLICKEY,0), "d2i_RSAPublicKey"},
int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa);
+#endif
X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
int i2d_PKCS8_fp(FILE *fp,X509_SIG *p8);
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
PKCS8_PRIV_KEY_INFO **p8inf);
int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,PKCS8_PRIV_KEY_INFO *p8inf);
int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key);
-#endif
+int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey);
+EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, int type, EVP_PKEY **a);
#endif
#ifdef HEADER_BIO_H
PKCS8_PRIV_KEY_INFO **p8inf);
int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,PKCS8_PRIV_KEY_INFO *p8inf);
int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key);
+int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey);
+EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, int type, EVP_PKEY **a);
#endif
X509 *X509_dup(X509 *x509);
return ret;
}
+int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey)
+ {
+ return(ASN1_i2d_fp(i2d_PrivateKey,fp,(unsigned char *)pkey));
+ }
+
+EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, int type, EVP_PKEY **a)
+{
+ BIO *bp;
+ EVP_PKEY *ret;
+ if(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {
+ ASN1err(ASN1_F_D2I_PRIVATEKEY_FP,ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
+ ret = d2i_PrivateKey_bio(bp, type, a);
+ BIO_free(bp);
+ return ret;
+}
+
#endif
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
PKCS8_PRIV_KEY_INFO_free(p8inf);
return ret;
}
+
+int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey)
+ {
+ return(ASN1_i2d_bio(i2d_PrivateKey,bp,(unsigned char *)pkey));
+ }
+
+EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, int type, EVP_PKEY **a)
+ {
+ EVP_PKEY *ret;
+
+ if ((a == NULL) || (*a == NULL))
+ {
+ if ((ret=EVP_PKEY_new()) == NULL)
+ {
+ ASN1err(ASN1_F_D2I_PRIVATEKEY_BIO,ERR_R_EVP_LIB);
+ return(NULL);
+ }
+ }
+ else ret= *a;
+
+ ret->save_type=type;
+ ret->type=EVP_PKEY_type(type);
+ switch (ret->type)
+ {
+#ifndef NO_RSA
+ case EVP_PKEY_RSA:
+ if ((ret->pkey.rsa=d2i_RSAPrivateKey_bio(bp,NULL)) == NULL)
+ {
+ ASN1err(ASN1_F_D2I_PRIVATEKEY_BIO,ERR_R_ASN1_LIB);
+ goto err;
+ }
+ break;
+#endif
+#ifndef NO_DSA
+ case EVP_PKEY_DSA:
+ if ((ret->pkey.dsa=d2i_DSAPrivateKey_bio(bp, NULL)) == NULL)
+ {
+ ASN1err(ASN1_F_D2I_PRIVATEKEY_BIO,ERR_R_ASN1_LIB);
+ goto err;
+ }
+ break;
+#endif
+ default:
+ ASN1err(ASN1_F_D2I_PRIVATEKEY_BIO,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
+ goto err;
+ /* break; */
+ }
+ if (a != NULL) (*a)=ret;
+ return(ret);
+err:
+ if ((ret != NULL) && ((a == NULL) || (*a != ret))) EVP_PKEY_free(ret);
+ return(NULL);
+ }
i2d_PKCS8PrivateKeyInfo_fp 2177
i2d_PKCS8PrivateKeyInfo_bio 2178
PEM_cb 2179
+i2d_PrivateKey_fp 2180
+d2i_PrivateKey_bio 2181
+d2i_PrivateKey_fp 2182
+i2d_PrivateKey_bio 2183