diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2000-01-01 16:42:49 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2000-01-01 16:42:49 +0000 |
commit | 20432eae41e35ea28a4d43c0dfc7acfdd9672812 (patch) | |
tree | ab6b92cdf2f38923e3e106968aa0dca236e0b4f9 /crypto/x509 | |
parent | 47134b7864fd5e31dbdbc789d9e073742ad4c3ee (diff) | |
download | openssl-20432eae41e35ea28a4d43c0dfc7acfdd9672812.tar.gz |
Fix some of the command line password stuff. New function
that can automatically determine the type of a DER encoded
"traditional" format private key and change some of the
d2i functions to use it instead of requiring the application
to work out the key type.
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/x509.h | 4 | ||||
-rw-r--r-- | crypto/x509/x_all.c | 61 |
2 files changed, 8 insertions, 57 deletions
diff --git a/crypto/x509/x509.h b/crypto/x509/x509.h index a11f9bc02c..2e6d2072af 100644 --- a/crypto/x509/x509.h +++ b/crypto/x509/x509.h @@ -656,7 +656,7 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, 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_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, int type, EVP_PKEY **a); +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); #endif #ifdef HEADER_BIO_H @@ -687,7 +687,7 @@ PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, 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); +EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); #endif X509 *X509_dup(X509 *x509); diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index e1d70dfdfe..d2bf3c8e1c 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -486,17 +486,10 @@ 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) +EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, 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; + return((EVP_PKEY *)ASN1_d2i_fp((char *(*)())EVP_PKEY_new, + (char *(*)())d2i_AutoPrivateKey, (fp),(unsigned char **)(a))); } #endif @@ -531,50 +524,8 @@ 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 *d2i_PrivateKey_bio(BIO *bp, 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); + return((EVP_PKEY *)ASN1_d2i_bio((char *(*)())EVP_PKEY_new, + (char *(*)())d2i_AutoPrivateKey, (bp),(unsigned char **)(a))); } |