summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/n_pkey.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/n_pkey.c')
-rw-r--r--src/lib/libcrypto/asn1/n_pkey.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/lib/libcrypto/asn1/n_pkey.c b/src/lib/libcrypto/asn1/n_pkey.c
index a59640582e..0a378759f9 100644
--- a/src/lib/libcrypto/asn1/n_pkey.c
+++ b/src/lib/libcrypto/asn1/n_pkey.c
@@ -159,8 +159,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
159 if ((enckey->enckey->algor->parameter=ASN1_TYPE_new()) == NULL) goto err; 159 if ((enckey->enckey->algor->parameter=ASN1_TYPE_new()) == NULL) goto err;
160 enckey->enckey->algor->parameter->type=V_ASN1_NULL; 160 enckey->enckey->algor->parameter->type=V_ASN1_NULL;
161 161
162 if (pp == NULL) 162 if (pp == NULL) {
163 {
164 olen = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, NULL); 163 olen = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, NULL);
165 NETSCAPE_PKEY_free(pkey); 164 NETSCAPE_PKEY_free(pkey);
166 NETSCAPE_ENCRYPTED_PKEY_free(enckey); 165 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
@@ -169,8 +168,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
169 168
170 169
171 /* Since its RC4 encrypted length is actual length */ 170 /* Since its RC4 encrypted length is actual length */
172 if ((zz=(unsigned char *)malloc(rsalen)) == NULL) 171 if ((zz=(unsigned char *)malloc(rsalen)) == NULL) {
173 {
174 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE); 172 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE);
175 goto err; 173 goto err;
176 } 174 }
@@ -179,14 +177,12 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
179 /* Write out private key encoding */ 177 /* Write out private key encoding */
180 i2d_RSAPrivateKey(a,&zz); 178 i2d_RSAPrivateKey(a,&zz);
181 179
182 if ((zz=malloc(pkeylen)) == NULL) 180 if ((zz=malloc(pkeylen)) == NULL) {
183 {
184 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE); 181 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE);
185 goto err; 182 goto err;
186 } 183 }
187 184
188 if (!ASN1_STRING_set(enckey->os, "private-key", -1)) 185 if (!ASN1_STRING_set(enckey->os, "private-key", -1)) {
189 {
190 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE); 186 ASN1err(ASN1_F_I2D_RSA_NET,ERR_R_MALLOC_FAILURE);
191 goto err; 187 goto err;
192 } 188 }
@@ -199,8 +195,7 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp,
199 if (cb == NULL) 195 if (cb == NULL)
200 cb=EVP_read_pw_string; 196 cb=EVP_read_pw_string;
201 i=cb((char *)buf,256,"Enter Private Key password:",1); 197 i=cb((char *)buf,256,"Enter Private Key password:",1);
202 if (i != 0) 198 if (i != 0) {
203 {
204 ASN1err(ASN1_F_I2D_RSA_NET,ASN1_R_BAD_PASSWORD_READ); 199 ASN1err(ASN1_F_I2D_RSA_NET,ASN1_R_BAD_PASSWORD_READ);
205 goto err; 200 goto err;
206 } 201 }
@@ -259,14 +254,12 @@ RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,
259} 254}
260 255
261 if ((enckey->os->length != 11) || (strncmp("private-key", 256 if ((enckey->os->length != 11) || (strncmp("private-key",
262 (char *)enckey->os->data,11) != 0)) 257 (char *)enckey->os->data,11) != 0)) {
263 {
264 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_PRIVATE_KEY_HEADER_MISSING); 258 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_PRIVATE_KEY_HEADER_MISSING);
265 NETSCAPE_ENCRYPTED_PKEY_free(enckey); 259 NETSCAPE_ENCRYPTED_PKEY_free(enckey);
266 return NULL; 260 return NULL;
267 } 261 }
268 if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) 262 if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) {
269 {
270 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM); 263 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM);
271 goto err; 264 goto err;
272} 265}
@@ -296,8 +289,7 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,
296 EVP_CIPHER_CTX_init(&ctx); 289 EVP_CIPHER_CTX_init(&ctx);
297 290
298 i=cb((char *)buf,256,"Enter Private Key password:",0); 291 i=cb((char *)buf,256,"Enter Private Key password:",0);
299 if (i != 0) 292 if (i != 0) {
300 {
301 ASN1err(ASN1_F_D2I_RSA_NET_2,ASN1_R_BAD_PASSWORD_READ); 293 ASN1err(ASN1_F_D2I_RSA_NET_2,ASN1_R_BAD_PASSWORD_READ);
302 goto err; 294 goto err;
303 } 295 }
@@ -324,15 +316,13 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os,
324 316
325 zz=os->data; 317 zz=os->data;
326 318
327 if ((pkey=d2i_NETSCAPE_PKEY(NULL,&zz,os->length)) == NULL) 319 if ((pkey=d2i_NETSCAPE_PKEY(NULL,&zz,os->length)) == NULL) {
328 {
329 ASN1err(ASN1_F_D2I_RSA_NET_2,ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY); 320 ASN1err(ASN1_F_D2I_RSA_NET_2,ASN1_R_UNABLE_TO_DECODE_RSA_PRIVATE_KEY);
330 goto err; 321 goto err;
331 } 322 }
332 323
333 zz=pkey->private_key->data; 324 zz=pkey->private_key->data;
334 if ((ret=d2i_RSAPrivateKey(a,&zz,pkey->private_key->length)) == NULL) 325 if ((ret=d2i_RSAPrivateKey(a,&zz,pkey->private_key->length)) == NULL) {
335 {
336 ASN1err(ASN1_F_D2I_RSA_NET_2,ASN1_R_UNABLE_TO_DECODE_RSA_KEY); 326 ASN1err(ASN1_F_D2I_RSA_NET_2,ASN1_R_UNABLE_TO_DECODE_RSA_KEY);
337 goto err; 327 goto err;
338 } 328 }