OLD | NEW |
1 /* crypto/asn1/d2i_pu.c */ | 1 /* crypto/asn1/d2i_pu.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 if ((a == NULL) || (*a == NULL)) | 80 if ((a == NULL) || (*a == NULL)) |
81 { | 81 { |
82 if ((ret=EVP_PKEY_new()) == NULL) | 82 if ((ret=EVP_PKEY_new()) == NULL) |
83 { | 83 { |
84 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB); | 84 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB); |
85 return(NULL); | 85 return(NULL); |
86 } | 86 } |
87 } | 87 } |
88 else ret= *a; | 88 else ret= *a; |
89 | 89 |
90 » ret->save_type=type; | 90 » if (!EVP_PKEY_set_type(ret, type)) |
91 » ret->type=EVP_PKEY_type(type); | 91 » » { |
92 » switch (ret->type) | 92 » » ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB); |
| 93 » » goto err; |
| 94 » » } |
| 95 |
| 96 » switch (EVP_PKEY_id(ret)) |
93 { | 97 { |
94 #ifndef OPENSSL_NO_RSA | 98 #ifndef OPENSSL_NO_RSA |
95 case EVP_PKEY_RSA: | 99 case EVP_PKEY_RSA: |
96 if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL, | 100 if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL, |
97 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY
CAST */ | 101 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY
CAST */ |
98 { | 102 { |
99 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB); | 103 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB); |
100 goto err; | 104 goto err; |
101 } | 105 } |
102 break; | 106 break; |
(...skipping 23 matching lines...) Expand all Loading... |
126 goto err; | 130 goto err; |
127 /* break; */ | 131 /* break; */ |
128 } | 132 } |
129 if (a != NULL) (*a)=ret; | 133 if (a != NULL) (*a)=ret; |
130 return(ret); | 134 return(ret); |
131 err: | 135 err: |
132 if ((ret != NULL) && ((a == NULL) || (*a != ret))) EVP_PKEY_free(ret); | 136 if ((ret != NULL) && ((a == NULL) || (*a != ret))) EVP_PKEY_free(ret); |
133 return(NULL); | 137 return(NULL); |
134 } | 138 } |
135 | 139 |
OLD | NEW |