New {i2d,d2i}_PrivateKey_{bio, fp} functions.
This commit is contained in:
parent
b96eb06f79
commit
e6f3c5850e
6
CHANGES
6
CHANGES
@ -4,9 +4,13 @@
|
|||||||
|
|
||||||
Changes between 0.9.4 and 0.9.5 [xx XXX 1999]
|
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
|
*) 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
|
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.
|
environment or config files in a few more utilities.
|
||||||
[Steve Henson]
|
[Steve Henson]
|
||||||
|
|
||||||
|
@ -890,6 +890,8 @@ void ASN1_STRING_TABLE_cleanup(void);
|
|||||||
#define ASN1_F_D2I_POLICYINFO 269
|
#define ASN1_F_D2I_POLICYINFO 269
|
||||||
#define ASN1_F_D2I_POLICYQUALINFO 270
|
#define ASN1_F_D2I_POLICYQUALINFO 270
|
||||||
#define ASN1_F_D2I_PRIVATEKEY 155
|
#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_PUBLICKEY 156
|
||||||
#define ASN1_F_D2I_RSAPRIVATEKEY 157
|
#define ASN1_F_D2I_RSAPRIVATEKEY 157
|
||||||
#define ASN1_F_D2I_RSAPUBLICKEY 158
|
#define ASN1_F_D2I_RSAPUBLICKEY 158
|
||||||
|
@ -163,6 +163,8 @@ static ERR_STRING_DATA ASN1_str_functs[]=
|
|||||||
{ERR_PACK(0,ASN1_F_D2I_POLICYINFO,0), "d2i_POLICYINFO"},
|
{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_POLICYQUALINFO,0), "d2i_POLICYQUALINFO"},
|
||||||
{ERR_PACK(0,ASN1_F_D2I_PRIVATEKEY,0), "d2i_PrivateKey"},
|
{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_PUBLICKEY,0), "d2i_PublicKey"},
|
||||||
{ERR_PACK(0,ASN1_F_D2I_RSAPRIVATEKEY,0), "d2i_RSAPrivateKey"},
|
{ERR_PACK(0,ASN1_F_D2I_RSAPRIVATEKEY,0), "d2i_RSAPrivateKey"},
|
||||||
{ERR_PACK(0,ASN1_F_D2I_RSAPUBLICKEY,0), "d2i_RSAPublicKey"},
|
{ERR_PACK(0,ASN1_F_D2I_RSAPUBLICKEY,0), "d2i_RSAPublicKey"},
|
||||||
|
@ -658,13 +658,15 @@ DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa);
|
|||||||
int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
|
int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa);
|
||||||
DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
|
DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa);
|
||||||
int i2d_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);
|
X509_SIG *d2i_PKCS8_fp(FILE *fp,X509_SIG **p8);
|
||||||
int i2d_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 *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp,
|
||||||
PKCS8_PRIV_KEY_INFO **p8inf);
|
PKCS8_PRIV_KEY_INFO **p8inf);
|
||||||
int i2d_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);
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef HEADER_BIO_H
|
#ifdef HEADER_BIO_H
|
||||||
@ -694,6 +696,8 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
|
|||||||
PKCS8_PRIV_KEY_INFO **p8inf);
|
PKCS8_PRIV_KEY_INFO **p8inf);
|
||||||
int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,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_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
|
#endif
|
||||||
|
|
||||||
X509 *X509_dup(X509 *x509);
|
X509 *X509_dup(X509 *x509);
|
||||||
|
@ -481,6 +481,24 @@ int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key)
|
|||||||
return ret;
|
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
|
#endif
|
||||||
|
|
||||||
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
|
PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp,
|
||||||
@ -507,3 +525,56 @@ int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key)
|
|||||||
PKCS8_PRIV_KEY_INFO_free(p8inf);
|
PKCS8_PRIV_KEY_INFO_free(p8inf);
|
||||||
return ret;
|
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);
|
||||||
|
}
|
||||||
|
@ -2152,3 +2152,7 @@ i2d_PKCS8PrivateKey_nid_bio 2176
|
|||||||
i2d_PKCS8PrivateKeyInfo_fp 2177
|
i2d_PKCS8PrivateKeyInfo_fp 2177
|
||||||
i2d_PKCS8PrivateKeyInfo_bio 2178
|
i2d_PKCS8PrivateKeyInfo_bio 2178
|
||||||
PEM_cb 2179
|
PEM_cb 2179
|
||||||
|
i2d_PrivateKey_fp 2180
|
||||||
|
d2i_PrivateKey_bio 2181
|
||||||
|
d2i_PrivateKey_fp 2182
|
||||||
|
i2d_PrivateKey_bio 2183
|
||||||
|
Loading…
x
Reference in New Issue
Block a user