| OLD | NEW |
| 1 /* crypto/cms/cms_lib.c */ | 1 /* crypto/cms/cms_lib.c */ |
| 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 * project. | 3 * project. |
| 4 */ | 4 */ |
| 5 /* ==================================================================== | 5 /* ==================================================================== |
| 6 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 2008 The OpenSSL Project. All rights reserved. |
| 7 * | 7 * |
| 8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
| 9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
| 10 * are met: | 10 * are met: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 #include <openssl/asn1t.h> | 54 #include <openssl/asn1t.h> |
| 55 #include <openssl/x509.h> | 55 #include <openssl/x509.h> |
| 56 #include <openssl/err.h> | 56 #include <openssl/err.h> |
| 57 #include <openssl/pem.h> | 57 #include <openssl/pem.h> |
| 58 #include <openssl/bio.h> | 58 #include <openssl/bio.h> |
| 59 #include <openssl/asn1.h> | 59 #include <openssl/asn1.h> |
| 60 #include "cms.h" | 60 #include "cms.h" |
| 61 #include "cms_lcl.h" | 61 #include "cms_lcl.h" |
| 62 | 62 |
| 63 IMPLEMENT_ASN1_FUNCTIONS_const(CMS_ContentInfo) | 63 IMPLEMENT_ASN1_FUNCTIONS(CMS_ContentInfo) |
| 64 IMPLEMENT_ASN1_PRINT_FUNCTION(CMS_ContentInfo) |
| 64 | 65 |
| 65 DECLARE_ASN1_ITEM(CMS_CertificateChoices) | 66 DECLARE_ASN1_ITEM(CMS_CertificateChoices) |
| 66 DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice) | 67 DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice) |
| 67 DECLARE_STACK_OF(CMS_CertificateChoices) | 68 DECLARE_STACK_OF(CMS_CertificateChoices) |
| 68 DECLARE_STACK_OF(CMS_RevocationInfoChoice) | 69 DECLARE_STACK_OF(CMS_RevocationInfoChoice) |
| 69 | 70 |
| 70 const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms) | 71 const ASN1_OBJECT *CMS_get0_type(CMS_ContentInfo *cms) |
| 71 { | 72 { |
| 72 return cms->contentType; | 73 return cms->contentType; |
| 73 } | 74 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 CMSerr(CMS_F_CMS_SET_DETACHED, ERR_R_MALLOC_FAILURE); | 340 CMSerr(CMS_F_CMS_SET_DETACHED, ERR_R_MALLOC_FAILURE); |
| 340 return 0; | 341 return 0; |
| 341 } | 342 } |
| 342 | 343 |
| 343 /* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */ | 344 /* Set up an X509_ALGOR DigestAlgorithmIdentifier from an EVP_MD */ |
| 344 | 345 |
| 345 void cms_DigestAlgorithm_set(X509_ALGOR *alg, const EVP_MD *md) | 346 void cms_DigestAlgorithm_set(X509_ALGOR *alg, const EVP_MD *md) |
| 346 { | 347 { |
| 347 int param_type; | 348 int param_type; |
| 348 | 349 |
| 349 » switch (EVP_MD_type(md)) | 350 » if (md->flags & EVP_MD_FLAG_DIGALGID_ABSENT) |
| 350 » » { | |
| 351 » » case NID_sha1: | |
| 352 » » case NID_sha224: | |
| 353 » » case NID_sha256: | |
| 354 » » case NID_sha384: | |
| 355 » » case NID_sha512: | |
| 356 param_type = V_ASN1_UNDEF; | 351 param_type = V_ASN1_UNDEF; |
| 357 » » break; | 352 » else |
| 358 » | |
| 359 » » default: | |
| 360 param_type = V_ASN1_NULL; | 353 param_type = V_ASN1_NULL; |
| 361 break; | |
| 362 } | |
| 363 | 354 |
| 364 X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL); | 355 X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_MD_type(md)), param_type, NULL); |
| 365 | 356 |
| 366 } | 357 } |
| 367 | 358 |
| 368 /* Create a digest BIO from an X509_ALGOR structure */ | 359 /* Create a digest BIO from an X509_ALGOR structure */ |
| 369 | 360 |
| 370 BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm) | 361 BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm) |
| 371 { | 362 { |
| 372 BIO *mdbio = NULL; | 363 BIO *mdbio = NULL; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 { | 545 { |
| 555 CMS_RevocationInfoChoice *rch; | 546 CMS_RevocationInfoChoice *rch; |
| 556 rch = CMS_add0_RevocationInfoChoice(cms); | 547 rch = CMS_add0_RevocationInfoChoice(cms); |
| 557 if (!rch) | 548 if (!rch) |
| 558 return 0; | 549 return 0; |
| 559 rch->type = CMS_REVCHOICE_CRL; | 550 rch->type = CMS_REVCHOICE_CRL; |
| 560 rch->d.crl = crl; | 551 rch->d.crl = crl; |
| 561 return 1; | 552 return 1; |
| 562 } | 553 } |
| 563 | 554 |
| 555 int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl) |
| 556 { |
| 557 int r; |
| 558 r = CMS_add0_crl(cms, crl); |
| 559 if (r > 0) |
| 560 CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL); |
| 561 return r; |
| 562 } |
| 563 |
| 564 STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms) | 564 STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms) |
| 565 { | 565 { |
| 566 STACK_OF(X509) *certs = NULL; | 566 STACK_OF(X509) *certs = NULL; |
| 567 CMS_CertificateChoices *cch; | 567 CMS_CertificateChoices *cch; |
| 568 STACK_OF(CMS_CertificateChoices) **pcerts; | 568 STACK_OF(CMS_CertificateChoices) **pcerts; |
| 569 int i; | 569 int i; |
| 570 pcerts = cms_get0_certificate_choices(cms); | 570 pcerts = cms_get0_certificate_choices(cms); |
| 571 if (!pcerts) | 571 if (!pcerts) |
| 572 return NULL; | 572 return NULL; |
| 573 for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) | 573 for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 { | 618 { |
| 619 sk_X509_CRL_pop_free(crls, X509_CRL_free); | 619 sk_X509_CRL_pop_free(crls, X509_CRL_free); |
| 620 return NULL; | 620 return NULL; |
| 621 } | 621 } |
| 622 CRYPTO_add(&rch->d.crl->references, | 622 CRYPTO_add(&rch->d.crl->references, |
| 623 1, CRYPTO_LOCK_X509_CRL); | 623 1, CRYPTO_LOCK_X509_CRL); |
| 624 } | 624 } |
| 625 } | 625 } |
| 626 return crls; | 626 return crls; |
| 627 } | 627 } |
| OLD | NEW |