summaryrefslogtreecommitdiff
path: root/src/lib/libssl/src/crypto/asn1/d2i_pu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/src/crypto/asn1/d2i_pu.c')
-rw-r--r--src/lib/libssl/src/crypto/asn1/d2i_pu.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/src/lib/libssl/src/crypto/asn1/d2i_pu.c b/src/lib/libssl/src/crypto/asn1/d2i_pu.c
index ccd03c066f..564f0945b5 100644
--- a/src/lib/libssl/src/crypto/asn1/d2i_pu.c
+++ b/src/lib/libssl/src/crypto/asn1/d2i_pu.c
@@ -5,21 +5,21 @@
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
11 * apply to all code found in this distribution, be it the RC4, RSA, 11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used. 19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or 20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -72,31 +72,31 @@
72#include <openssl/ec.h> 72#include <openssl/ec.h>
73#endif 73#endif
74 74
75EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, 75EVP_PKEY *
76 long length) 76d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, long length)
77{ 77{
78 EVP_PKEY *ret; 78 EVP_PKEY *ret;
79 79
80 if ((a == NULL) || (*a == NULL)) { 80 if ((a == NULL) || (*a == NULL)) {
81 if ((ret=EVP_PKEY_new()) == NULL) { 81 if ((ret = EVP_PKEY_new()) == NULL) {
82 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB); 82 ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB);
83 return(NULL); 83 return (NULL);
84 } 84 }
85 } 85 } else
86 else ret= *a; 86 ret = *a;
87 87
88 if (!EVP_PKEY_set_type(ret, type)) { 88 if (!EVP_PKEY_set_type(ret, type)) {
89 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_EVP_LIB); 89 ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_EVP_LIB);
90 goto err; 90 goto err;
91 } 91 }
92 92
93 switch (EVP_PKEY_id(ret)) { 93 switch (EVP_PKEY_id(ret)) {
94#ifndef OPENSSL_NO_RSA 94#ifndef OPENSSL_NO_RSA
95 case EVP_PKEY_RSA: 95 case EVP_PKEY_RSA:
96 if ((ret->pkey.rsa=d2i_RSAPublicKey(NULL, 96 if ((ret->pkey.rsa = d2i_RSAPublicKey(NULL,
97 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */ 97 (const unsigned char **)pp,length)) == NULL) /* TMP UGLY CAST */
98 { 98 {
99 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB); 99 ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB);
100 goto err; 100 goto err;
101 } 101 }
102 break; 102 break;
@@ -104,9 +104,9 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
104#ifndef OPENSSL_NO_DSA 104#ifndef OPENSSL_NO_DSA
105 case EVP_PKEY_DSA: 105 case EVP_PKEY_DSA:
106 if (!d2i_DSAPublicKey(&(ret->pkey.dsa), 106 if (!d2i_DSAPublicKey(&(ret->pkey.dsa),
107 (const unsigned char **)pp,length)) /* TMP UGLY CAST */ 107 (const unsigned char **)pp,length)) /* TMP UGLY CAST */
108 { 108 {
109 ASN1err(ASN1_F_D2I_PUBLICKEY,ERR_R_ASN1_LIB); 109 ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB);
110 goto err; 110 goto err;
111 } 111 }
112 break; 112 break;
@@ -114,22 +114,23 @@ EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
114#ifndef OPENSSL_NO_EC 114#ifndef OPENSSL_NO_EC
115 case EVP_PKEY_EC: 115 case EVP_PKEY_EC:
116 if (!o2i_ECPublicKey(&(ret->pkey.ec), 116 if (!o2i_ECPublicKey(&(ret->pkey.ec),
117 (const unsigned char **)pp, length)) 117 (const unsigned char **)pp, length)) {
118 {
119 ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB); 118 ASN1err(ASN1_F_D2I_PUBLICKEY, ERR_R_ASN1_LIB);
120 goto err; 119 goto err;
121 } 120 }
122 break; 121 break;
123#endif 122#endif
124 default: 123 default:
125 ASN1err(ASN1_F_D2I_PUBLICKEY,ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE); 124 ASN1err(ASN1_F_D2I_PUBLICKEY, ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE);
126 goto err; 125 goto err;
127 /* break; */ 126 /* break; */
128 } 127 }
129 if (a != NULL) (*a)=ret; 128 if (a != NULL)
130 return(ret); 129 (*a) = ret;
130 return (ret);
131
131err: 132err:
132 if ((ret != NULL) && ((a == NULL) || (*a != ret))) EVP_PKEY_free(ret); 133 if ((ret != NULL) && ((a == NULL) || (*a != ret)))
133 return(NULL); 134 EVP_PKEY_free(ret);
135 return (NULL);
134} 136}
135