| OLD | NEW |
| 1 /* crypto/asn1/n_pkey.c */ | 1 /* crypto/asn1/n_pkey.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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 int verify)) | 235 int verify)) |
| 236 { | 236 { |
| 237 return d2i_RSA_NET(a, pp, length, cb, 0); | 237 return d2i_RSA_NET(a, pp, length, cb, 0); |
| 238 } | 238 } |
| 239 | 239 |
| 240 RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, | 240 RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, |
| 241 int (*cb)(char *buf, int len, const char *prompt, int verify), | 241 int (*cb)(char *buf, int len, const char *prompt, int verify), |
| 242 int sgckey) | 242 int sgckey) |
| 243 { | 243 { |
| 244 RSA *ret=NULL; | 244 RSA *ret=NULL; |
| 245 » const unsigned char *p, *kp; | 245 » const unsigned char *p; |
| 246 NETSCAPE_ENCRYPTED_PKEY *enckey = NULL; | 246 NETSCAPE_ENCRYPTED_PKEY *enckey = NULL; |
| 247 | 247 |
| 248 p = *pp; | 248 p = *pp; |
| 249 | 249 |
| 250 enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length); | 250 enckey = d2i_NETSCAPE_ENCRYPTED_PKEY(NULL, &p, length); |
| 251 if(!enckey) { | 251 if(!enckey) { |
| 252 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_DECODING_ERROR); | 252 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_DECODING_ERROR); |
| 253 return NULL; | 253 return NULL; |
| 254 } | 254 } |
| 255 | 255 |
| 256 if ((enckey->os->length != 11) || (strncmp("private-key", | 256 if ((enckey->os->length != 11) || (strncmp("private-key", |
| 257 (char *)enckey->os->data,11) != 0)) | 257 (char *)enckey->os->data,11) != 0)) |
| 258 { | 258 { |
| 259 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_PRIVATE_KEY_HEADER_MISSING); | 259 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_PRIVATE_KEY_HEADER_MISSING); |
| 260 NETSCAPE_ENCRYPTED_PKEY_free(enckey); | 260 NETSCAPE_ENCRYPTED_PKEY_free(enckey); |
| 261 return NULL; | 261 return NULL; |
| 262 } | 262 } |
| 263 if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) | 263 if (OBJ_obj2nid(enckey->enckey->algor->algorithm) != NID_rc4) |
| 264 { | 264 { |
| 265 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORIT
HM); | 265 ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORIT
HM); |
| 266 goto err; | 266 goto err; |
| 267 } | 267 } |
| 268 kp = enckey->enckey->digest->data; | |
| 269 if (cb == NULL) | 268 if (cb == NULL) |
| 270 cb=EVP_read_pw_string; | 269 cb=EVP_read_pw_string; |
| 271 if ((ret=d2i_RSA_NET_2(a, enckey->enckey->digest,cb, sgckey)) == NULL) g
oto err; | 270 if ((ret=d2i_RSA_NET_2(a, enckey->enckey->digest,cb, sgckey)) == NULL) g
oto err; |
| 272 | 271 |
| 273 *pp = p; | 272 *pp = p; |
| 274 | 273 |
| 275 err: | 274 err: |
| 276 NETSCAPE_ENCRYPTED_PKEY_free(enckey); | 275 NETSCAPE_ENCRYPTED_PKEY_free(enckey); |
| 277 return ret; | 276 return ret; |
| 278 | 277 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 334 |
| 336 #endif /* OPENSSL_NO_RC4 */ | 335 #endif /* OPENSSL_NO_RC4 */ |
| 337 | 336 |
| 338 #else /* !OPENSSL_NO_RSA */ | 337 #else /* !OPENSSL_NO_RSA */ |
| 339 | 338 |
| 340 # if PEDANTIC | 339 # if PEDANTIC |
| 341 static void *dummy=&dummy; | 340 static void *dummy=&dummy; |
| 342 # endif | 341 # endif |
| 343 | 342 |
| 344 #endif | 343 #endif |
| OLD | NEW |