diff options
Diffstat (limited to 'src/lib/libcrypto/pkcs7/pk7_lib.c')
-rw-r--r-- | src/lib/libcrypto/pkcs7/pk7_lib.c | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c index ee1817c7af..985b07245c 100644 --- a/src/lib/libcrypto/pkcs7/pk7_lib.c +++ b/src/lib/libcrypto/pkcs7/pk7_lib.c | |||
@@ -164,12 +164,7 @@ int PKCS7_set_type(PKCS7 *p7, int type) | |||
164 | p7->type=obj; | 164 | p7->type=obj; |
165 | if ((p7->d.sign=PKCS7_SIGNED_new()) == NULL) | 165 | if ((p7->d.sign=PKCS7_SIGNED_new()) == NULL) |
166 | goto err; | 166 | goto err; |
167 | if (!ASN1_INTEGER_set(p7->d.sign->version,1)) | 167 | ASN1_INTEGER_set(p7->d.sign->version,1); |
168 | { | ||
169 | PKCS7_SIGNED_free(p7->d.sign); | ||
170 | p7->d.sign=NULL; | ||
171 | goto err; | ||
172 | } | ||
173 | break; | 168 | break; |
174 | case NID_pkcs7_data: | 169 | case NID_pkcs7_data: |
175 | p7->type=obj; | 170 | p7->type=obj; |
@@ -181,8 +176,6 @@ int PKCS7_set_type(PKCS7 *p7, int type) | |||
181 | if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new()) | 176 | if ((p7->d.signed_and_enveloped=PKCS7_SIGN_ENVELOPE_new()) |
182 | == NULL) goto err; | 177 | == NULL) goto err; |
183 | ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1); | 178 | ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1); |
184 | if (!ASN1_INTEGER_set(p7->d.signed_and_enveloped->version,1)) | ||
185 | goto err; | ||
186 | p7->d.signed_and_enveloped->enc_data->content_type | 179 | p7->d.signed_and_enveloped->enc_data->content_type |
187 | = OBJ_nid2obj(NID_pkcs7_data); | 180 | = OBJ_nid2obj(NID_pkcs7_data); |
188 | break; | 181 | break; |
@@ -190,8 +183,7 @@ int PKCS7_set_type(PKCS7 *p7, int type) | |||
190 | p7->type=obj; | 183 | p7->type=obj; |
191 | if ((p7->d.enveloped=PKCS7_ENVELOPE_new()) | 184 | if ((p7->d.enveloped=PKCS7_ENVELOPE_new()) |
192 | == NULL) goto err; | 185 | == NULL) goto err; |
193 | if (!ASN1_INTEGER_set(p7->d.enveloped->version,0)) | 186 | ASN1_INTEGER_set(p7->d.enveloped->version,0); |
194 | goto err; | ||
195 | p7->d.enveloped->enc_data->content_type | 187 | p7->d.enveloped->enc_data->content_type |
196 | = OBJ_nid2obj(NID_pkcs7_data); | 188 | = OBJ_nid2obj(NID_pkcs7_data); |
197 | break; | 189 | break; |
@@ -199,8 +191,7 @@ int PKCS7_set_type(PKCS7 *p7, int type) | |||
199 | p7->type=obj; | 191 | p7->type=obj; |
200 | if ((p7->d.encrypted=PKCS7_ENCRYPT_new()) | 192 | if ((p7->d.encrypted=PKCS7_ENCRYPT_new()) |
201 | == NULL) goto err; | 193 | == NULL) goto err; |
202 | if (!ASN1_INTEGER_set(p7->d.encrypted->version,0)) | 194 | ASN1_INTEGER_set(p7->d.encrypted->version,0); |
203 | goto err; | ||
204 | p7->d.encrypted->enc_data->content_type | 195 | p7->d.encrypted->enc_data->content_type |
205 | = OBJ_nid2obj(NID_pkcs7_data); | 196 | = OBJ_nid2obj(NID_pkcs7_data); |
206 | break; | 197 | break; |
@@ -327,18 +318,15 @@ int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, | |||
327 | if (pkey->type == EVP_PKEY_DSA) is_dsa = 1; | 318 | if (pkey->type == EVP_PKEY_DSA) is_dsa = 1; |
328 | else is_dsa = 0; | 319 | else is_dsa = 0; |
329 | /* We now need to add another PKCS7_SIGNER_INFO entry */ | 320 | /* We now need to add another PKCS7_SIGNER_INFO entry */ |
330 | if (!ASN1_INTEGER_set(p7i->version,1)) | 321 | ASN1_INTEGER_set(p7i->version,1); |
331 | goto err; | 322 | X509_NAME_set(&p7i->issuer_and_serial->issuer, |
332 | if (!X509_NAME_set(&p7i->issuer_and_serial->issuer, | 323 | X509_get_issuer_name(x509)); |
333 | X509_get_issuer_name(x509))) | ||
334 | goto err; | ||
335 | 324 | ||
336 | /* because ASN1_INTEGER_set is used to set a 'long' we will do | 325 | /* because ASN1_INTEGER_set is used to set a 'long' we will do |
337 | * things the ugly way. */ | 326 | * things the ugly way. */ |
338 | M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial); | 327 | M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial); |
339 | if (!(p7i->issuer_and_serial->serial= | 328 | p7i->issuer_and_serial->serial= |
340 | M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) | 329 | M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)); |
341 | goto err; | ||
342 | 330 | ||
343 | /* lets keep the pkey around for a while */ | 331 | /* lets keep the pkey around for a while */ |
344 | CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY); | 332 | CRYPTO_add(&pkey->references,1,CRYPTO_LOCK_EVP_PKEY); |
@@ -435,20 +423,16 @@ int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri) | |||
435 | 423 | ||
436 | int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) | 424 | int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509) |
437 | { | 425 | { |
438 | if (!ASN1_INTEGER_set(p7i->version,0)) | 426 | ASN1_INTEGER_set(p7i->version,0); |
439 | return 0; | 427 | X509_NAME_set(&p7i->issuer_and_serial->issuer, |
440 | if (!X509_NAME_set(&p7i->issuer_and_serial->issuer, | 428 | X509_get_issuer_name(x509)); |
441 | X509_get_issuer_name(x509))) | ||
442 | return 0; | ||
443 | 429 | ||
444 | M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial); | 430 | M_ASN1_INTEGER_free(p7i->issuer_and_serial->serial); |
445 | if (!(p7i->issuer_and_serial->serial= | 431 | p7i->issuer_and_serial->serial= |
446 | M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)))) | 432 | M_ASN1_INTEGER_dup(X509_get_serialNumber(x509)); |
447 | return 0; | ||
448 | 433 | ||
449 | X509_ALGOR_free(p7i->key_enc_algor); | 434 | X509_ALGOR_free(p7i->key_enc_algor); |
450 | if (!(p7i->key_enc_algor= X509_ALGOR_dup(x509->cert_info->key->algor))) | 435 | p7i->key_enc_algor= X509_ALGOR_dup(x509->cert_info->key->algor); |
451 | return 0; | ||
452 | 436 | ||
453 | CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509); | 437 | CRYPTO_add(&x509->references,1,CRYPTO_LOCK_X509); |
454 | p7i->cert=x509; | 438 | p7i->cert=x509; |