summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/pem/pem_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/pem/pem_info.c')
-rw-r--r--src/lib/libcrypto/pem/pem_info.c58
1 files changed, 13 insertions, 45 deletions
diff --git a/src/lib/libcrypto/pem/pem_info.c b/src/lib/libcrypto/pem/pem_info.c
index 3a273f6f70..9e4af29c95 100644
--- a/src/lib/libcrypto/pem/pem_info.c
+++ b/src/lib/libcrypto/pem/pem_info.c
@@ -63,12 +63,6 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/pem.h> 65#include <openssl/pem.h>
66#ifndef OPENSSL_NO_RSA
67#include <openssl/rsa.h>
68#endif
69#ifndef OPENSSL_NO_DSA
70#include <openssl/dsa.h>
71#endif
72 66
73#ifndef OPENSSL_NO_FP_API 67#ifndef OPENSSL_NO_FP_API
74STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) 68STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u)
@@ -91,15 +85,13 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, pem_p
91STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u) 85STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u)
92 { 86 {
93 X509_INFO *xi=NULL; 87 X509_INFO *xi=NULL;
94 char *name=NULL,*header=NULL; 88 char *name=NULL,*header=NULL,**pp;
95 void *pp; 89 unsigned char *data=NULL,*p;
96 unsigned char *data=NULL;
97 const unsigned char *p;
98 long len,error=0; 90 long len,error=0;
99 int ok=0; 91 int ok=0;
100 STACK_OF(X509_INFO) *ret=NULL; 92 STACK_OF(X509_INFO) *ret=NULL;
101 unsigned int i,raw; 93 unsigned int i,raw;
102 d2i_of_void *d2i; 94 char *(*d2i)();
103 95
104 if (sk == NULL) 96 if (sk == NULL)
105 { 97 {
@@ -131,42 +123,42 @@ start:
131 if ( (strcmp(name,PEM_STRING_X509) == 0) || 123 if ( (strcmp(name,PEM_STRING_X509) == 0) ||
132 (strcmp(name,PEM_STRING_X509_OLD) == 0)) 124 (strcmp(name,PEM_STRING_X509_OLD) == 0))
133 { 125 {
134 d2i=(D2I_OF(void))d2i_X509; 126 d2i=(char *(*)())d2i_X509;
135 if (xi->x509 != NULL) 127 if (xi->x509 != NULL)
136 { 128 {
137 if (!sk_X509_INFO_push(ret,xi)) goto err; 129 if (!sk_X509_INFO_push(ret,xi)) goto err;
138 if ((xi=X509_INFO_new()) == NULL) goto err; 130 if ((xi=X509_INFO_new()) == NULL) goto err;
139 goto start; 131 goto start;
140 } 132 }
141 pp=&(xi->x509); 133 pp=(char **)&(xi->x509);
142 } 134 }
143 else if ((strcmp(name,PEM_STRING_X509_TRUSTED) == 0)) 135 else if ((strcmp(name,PEM_STRING_X509_TRUSTED) == 0))
144 { 136 {
145 d2i=(D2I_OF(void))d2i_X509_AUX; 137 d2i=(char *(*)())d2i_X509_AUX;
146 if (xi->x509 != NULL) 138 if (xi->x509 != NULL)
147 { 139 {
148 if (!sk_X509_INFO_push(ret,xi)) goto err; 140 if (!sk_X509_INFO_push(ret,xi)) goto err;
149 if ((xi=X509_INFO_new()) == NULL) goto err; 141 if ((xi=X509_INFO_new()) == NULL) goto err;
150 goto start; 142 goto start;
151 } 143 }
152 pp=&(xi->x509); 144 pp=(char **)&(xi->x509);
153 } 145 }
154 else if (strcmp(name,PEM_STRING_X509_CRL) == 0) 146 else if (strcmp(name,PEM_STRING_X509_CRL) == 0)
155 { 147 {
156 d2i=(D2I_OF(void))d2i_X509_CRL; 148 d2i=(char *(*)())d2i_X509_CRL;
157 if (xi->crl != NULL) 149 if (xi->crl != NULL)
158 { 150 {
159 if (!sk_X509_INFO_push(ret,xi)) goto err; 151 if (!sk_X509_INFO_push(ret,xi)) goto err;
160 if ((xi=X509_INFO_new()) == NULL) goto err; 152 if ((xi=X509_INFO_new()) == NULL) goto err;
161 goto start; 153 goto start;
162 } 154 }
163 pp=&(xi->crl); 155 pp=(char **)&(xi->crl);
164 } 156 }
165 else 157 else
166#ifndef OPENSSL_NO_RSA 158#ifndef OPENSSL_NO_RSA
167 if (strcmp(name,PEM_STRING_RSA) == 0) 159 if (strcmp(name,PEM_STRING_RSA) == 0)
168 { 160 {
169 d2i=(D2I_OF(void))d2i_RSAPrivateKey; 161 d2i=(char *(*)())d2i_RSAPrivateKey;
170 if (xi->x_pkey != NULL) 162 if (xi->x_pkey != NULL)
171 { 163 {
172 if (!sk_X509_INFO_push(ret,xi)) goto err; 164 if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -181,7 +173,7 @@ start:
181 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) 173 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL)
182 goto err; 174 goto err;
183 xi->x_pkey->dec_pkey->type=EVP_PKEY_RSA; 175 xi->x_pkey->dec_pkey->type=EVP_PKEY_RSA;
184 pp=&(xi->x_pkey->dec_pkey->pkey.rsa); 176 pp=(char **)&(xi->x_pkey->dec_pkey->pkey.rsa);
185 if ((int)strlen(header) > 10) /* assume encrypted */ 177 if ((int)strlen(header) > 10) /* assume encrypted */
186 raw=1; 178 raw=1;
187 } 179 }
@@ -190,7 +182,7 @@ start:
190#ifndef OPENSSL_NO_DSA 182#ifndef OPENSSL_NO_DSA
191 if (strcmp(name,PEM_STRING_DSA) == 0) 183 if (strcmp(name,PEM_STRING_DSA) == 0)
192 { 184 {
193 d2i=(D2I_OF(void))d2i_DSAPrivateKey; 185 d2i=(char *(*)())d2i_DSAPrivateKey;
194 if (xi->x_pkey != NULL) 186 if (xi->x_pkey != NULL)
195 { 187 {
196 if (!sk_X509_INFO_push(ret,xi)) goto err; 188 if (!sk_X509_INFO_push(ret,xi)) goto err;
@@ -205,36 +197,12 @@ start:
205 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL) 197 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL)
206 goto err; 198 goto err;
207 xi->x_pkey->dec_pkey->type=EVP_PKEY_DSA; 199 xi->x_pkey->dec_pkey->type=EVP_PKEY_DSA;
208 pp=&xi->x_pkey->dec_pkey->pkey.dsa; 200 pp=(char **)&(xi->x_pkey->dec_pkey->pkey.dsa);
209 if ((int)strlen(header) > 10) /* assume encrypted */ 201 if ((int)strlen(header) > 10) /* assume encrypted */
210 raw=1; 202 raw=1;
211 } 203 }
212 else 204 else
213#endif 205#endif
214#ifndef OPENSSL_NO_EC
215 if (strcmp(name,PEM_STRING_ECPRIVATEKEY) == 0)
216 {
217 d2i=(D2I_OF(void))d2i_ECPrivateKey;
218 if (xi->x_pkey != NULL)
219 {
220 if (!sk_X509_INFO_push(ret,xi)) goto err;
221 if ((xi=X509_INFO_new()) == NULL) goto err;
222 goto start;
223 }
224
225 xi->enc_data=NULL;
226 xi->enc_len=0;
227
228 xi->x_pkey=X509_PKEY_new();
229 if ((xi->x_pkey->dec_pkey=EVP_PKEY_new()) == NULL)
230 goto err;
231 xi->x_pkey->dec_pkey->type=EVP_PKEY_EC;
232 pp=&(xi->x_pkey->dec_pkey->pkey.ec);
233 if ((int)strlen(header) > 10) /* assume encrypted */
234 raw=1;
235 }
236 else
237#endif
238 { 206 {
239 d2i=NULL; 207 d2i=NULL;
240 pp=NULL; 208 pp=NULL;