summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/d2i_pr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/d2i_pr.c')
-rw-r--r--src/lib/libcrypto/asn1/d2i_pr.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/src/lib/libcrypto/asn1/d2i_pr.c b/src/lib/libcrypto/asn1/d2i_pr.c
index 207ccda5ac..2e7d96af90 100644
--- a/src/lib/libcrypto/asn1/d2i_pr.c
+++ b/src/lib/libcrypto/asn1/d2i_pr.c
@@ -68,11 +68,8 @@
68#ifndef OPENSSL_NO_DSA 68#ifndef OPENSSL_NO_DSA
69#include <openssl/dsa.h> 69#include <openssl/dsa.h>
70#endif 70#endif
71#ifndef OPENSSL_NO_EC
72#include <openssl/ec.h>
73#endif
74 71
75EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, 72EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, unsigned char **pp,
76 long length) 73 long length)
77 { 74 {
78 EVP_PKEY *ret; 75 EVP_PKEY *ret;
@@ -111,16 +108,6 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
111 } 108 }
112 break; 109 break;
113#endif 110#endif
114#ifndef OPENSSL_NO_EC
115 case EVP_PKEY_EC:
116 if ((ret->pkey.ec = d2i_ECPrivateKey(NULL,
117 (const unsigned char **)pp, length)) == NULL)
118 {
119 ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
120 goto err;
121 }
122 break;
123#endif
124 default: 111 default:
125 ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); 112 ASN1err(ASN1_F_D2I_PRIVATEKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
126 goto err; 113 goto err;
@@ -135,11 +122,11 @@ err:
135 122
136/* This works like d2i_PrivateKey() except it automatically works out the type */ 123/* This works like d2i_PrivateKey() except it automatically works out the type */
137 124
138EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, 125EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
139 long length) 126 long length)
140{ 127{
141 STACK_OF(ASN1_TYPE) *inkey; 128 STACK_OF(ASN1_TYPE) *inkey;
142 const unsigned char *p; 129 unsigned char *p;
143 int keytype; 130 int keytype;
144 p = *pp; 131 p = *pp;
145 /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE): 132 /* Dirty trick: read in the ASN1 data into a STACK_OF(ASN1_TYPE):
@@ -151,10 +138,7 @@ EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
151 /* Since we only need to discern "traditional format" RSA and DSA 138 /* Since we only need to discern "traditional format" RSA and DSA
152 * keys we can just count the elements. 139 * keys we can just count the elements.
153 */ 140 */
154 if(sk_ASN1_TYPE_num(inkey) == 6) 141 if(sk_ASN1_TYPE_num(inkey) == 6) keytype = EVP_PKEY_DSA;
155 keytype = EVP_PKEY_DSA;
156 else if (sk_ASN1_TYPE_num(inkey) == 4)
157 keytype = EVP_PKEY_EC;
158 else keytype = EVP_PKEY_RSA; 142 else keytype = EVP_PKEY_RSA;
159 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free); 143 sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
160 return d2i_PrivateKey(keytype, a, pp, length); 144 return d2i_PrivateKey(keytype, a, pp, length);