aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/asn1/d2i_pr.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2006-03-23 18:02:23 +0000
committerDr. Stephen Henson <steve@openssl.org>2006-03-23 18:02:23 +0000
commite42633140e98c7c07a5bc013127e1e6a251995ed (patch)
tree512218e4d8b50fb52630ce69ee534a485e3fbb76 /crypto/asn1/d2i_pr.c
parentbd50e31325516bcdd45627f5d76f96c38be89eba (diff)
downloadopenssl-e42633140e98c7c07a5bc013127e1e6a251995ed.tar.gz
Add support for legacy PEM format private keys in EVP_PKEY_ASN1_METHOD.
Diffstat (limited to 'crypto/asn1/d2i_pr.c')
-rw-r--r--crypto/asn1/d2i_pr.c44
1 files changed, 7 insertions, 37 deletions
diff --git a/crypto/asn1/d2i_pr.c b/crypto/asn1/d2i_pr.c
index bb6582b7cf..b4e47d4819 100644
--- a/crypto/asn1/d2i_pr.c
+++ b/crypto/asn1/d2i_pr.c
@@ -62,15 +62,7 @@
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/asn1.h>
-#ifndef OPENSSL_NO_RSA
-#include <openssl/rsa.h>
-#endif
-#ifndef OPENSSL_NO_DSA
-#include <openssl/dsa.h>
-#endif
-#ifndef OPENSSL_NO_EC
-#include <openssl/ec.h>
-#endif
+#include "asn1_locl.h"
EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
long length)
@@ -90,39 +82,17 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
ret->save_type=type;
ret->type=EVP_PKEY_type(type);
ret->ameth = EVP_PKEY_asn1_find(type);
- switch (ret->type)
+ if (ret->ameth)
{
-#ifndef OPENSSL_NO_RSA
- case EVP_PKEY_RSA:
- if ((ret->pkey.rsa=d2i_RSAPrivateKey(NULL,
- (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
+ if (!ret->ameth->old_priv_decode ||
+ !ret->ameth->old_priv_decode(ret, pp, length))
{
ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB);
goto err;
}
- break;
-#endif
-#ifndef OPENSSL_NO_DSA
- case EVP_PKEY_DSA:
- if ((ret->pkey.dsa=d2i_DSAPrivateKey(NULL,
- (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
- {
- ASN1err(ASN1_F_D2I_PRIVATEKEY,ERR_R_ASN1_LIB);
- goto err;
- }
- break;
-#endif
-#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
- default:
+ }
+ else
+ {
ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
goto err;
/* break; */