summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/cms/cms_sd.c
diff options
context:
space:
mode:
authorjsing <>2019-08-11 10:41:49 +0000
committerjsing <>2019-08-11 10:41:49 +0000
commit40ce59403b918c4baa975308e0e0fed2d27b9012 (patch)
treebf1fe6334200e35a37c7fb725d2e49bb688cda57 /src/lib/libcrypto/cms/cms_sd.c
parent66c480d1798005c797335d0f02a75fc501efcc7f (diff)
downloadopenbsd-40ce59403b918c4baa975308e0e0fed2d27b9012.tar.gz
openbsd-40ce59403b918c4baa975308e0e0fed2d27b9012.tar.bz2
openbsd-40ce59403b918c4baa975308e0e0fed2d27b9012.zip
Use malloc(3) and free(3), rather than OPENSSL_{malloc,free}().
Diffstat (limited to 'src/lib/libcrypto/cms/cms_sd.c')
-rw-r--r--src/lib/libcrypto/cms/cms_sd.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/libcrypto/cms/cms_sd.c b/src/lib/libcrypto/cms/cms_sd.c
index 7072ce7dac..0681bf2759 100644
--- a/src/lib/libcrypto/cms/cms_sd.c
+++ b/src/lib/libcrypto/cms/cms_sd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_sd.c,v 1.19 2019/08/11 10:38:27 jsing Exp $ */ 1/* $OpenBSD: cms_sd.c,v 1.20 2019/08/11 10:41:49 jsing Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -650,13 +650,13 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain
650 if (!EVP_DigestFinal_ex(mctx, md, &mdlen)) 650 if (!EVP_DigestFinal_ex(mctx, md, &mdlen))
651 goto err; 651 goto err;
652 siglen = EVP_PKEY_size(si->pkey); 652 siglen = EVP_PKEY_size(si->pkey);
653 sig = OPENSSL_malloc(siglen); 653 sig = malloc(siglen);
654 if (sig == NULL) { 654 if (sig == NULL) {
655 CMSerror(ERR_R_MALLOC_FAILURE); 655 CMSerror(ERR_R_MALLOC_FAILURE);
656 goto err; 656 goto err;
657 } 657 }
658 if (EVP_PKEY_sign(pctx, sig, &siglen, md, mdlen) <= 0) { 658 if (EVP_PKEY_sign(pctx, sig, &siglen, md, mdlen) <= 0) {
659 OPENSSL_free(sig); 659 free(sig);
660 goto err; 660 goto err;
661 } 661 }
662 ASN1_STRING_set0(si->signature, sig, siglen); 662 ASN1_STRING_set0(si->signature, sig, siglen);
@@ -664,14 +664,14 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain
664 unsigned char *sig; 664 unsigned char *sig;
665 unsigned int siglen; 665 unsigned int siglen;
666 666
667 sig = OPENSSL_malloc(EVP_PKEY_size(si->pkey)); 667 sig = malloc(EVP_PKEY_size(si->pkey));
668 if (sig == NULL) { 668 if (sig == NULL) {
669 CMSerror(ERR_R_MALLOC_FAILURE); 669 CMSerror(ERR_R_MALLOC_FAILURE);
670 goto err; 670 goto err;
671 } 671 }
672 if (!EVP_SignFinal(mctx, sig, &siglen, si->pkey)) { 672 if (!EVP_SignFinal(mctx, sig, &siglen, si->pkey)) {
673 CMSerror(CMS_R_SIGNFINAL_ERROR); 673 CMSerror(CMS_R_SIGNFINAL_ERROR);
674 OPENSSL_free(sig); 674 free(sig);
675 goto err; 675 goto err;
676 } 676 }
677 ASN1_STRING_set0(si->signature, sig, siglen); 677 ASN1_STRING_set0(si->signature, sig, siglen);
@@ -746,8 +746,8 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si)
746 goto err; 746 goto err;
747 if (EVP_DigestSignFinal(mctx, NULL, &siglen) <= 0) 747 if (EVP_DigestSignFinal(mctx, NULL, &siglen) <= 0)
748 goto err; 748 goto err;
749 OPENSSL_free(abuf); 749 free(abuf);
750 abuf = OPENSSL_malloc(siglen); 750 abuf = malloc(siglen);
751 if (abuf == NULL) 751 if (abuf == NULL)
752 goto err; 752 goto err;
753 if (EVP_DigestSignFinal(mctx, abuf, &siglen) <= 0) 753 if (EVP_DigestSignFinal(mctx, abuf, &siglen) <= 0)
@@ -766,7 +766,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si)
766 return 1; 766 return 1;
767 767
768 err: 768 err:
769 OPENSSL_free(abuf); 769 free(abuf);
770 EVP_MD_CTX_reset(mctx); 770 EVP_MD_CTX_reset(mctx);
771 771
772 return 0; 772 return 0;
@@ -804,7 +804,7 @@ CMS_SignerInfo_verify(CMS_SignerInfo *si)
804 if (!abuf) 804 if (!abuf)
805 goto err; 805 goto err;
806 r = EVP_DigestVerifyUpdate(mctx, abuf, alen); 806 r = EVP_DigestVerifyUpdate(mctx, abuf, alen);
807 OPENSSL_free(abuf); 807 free(abuf);
808 if (r <= 0) { 808 if (r <= 0) {
809 r = -1; 809 r = -1;
810 goto err; 810 goto err;
@@ -941,7 +941,7 @@ CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs)
941 return 0; 941 return 0;
942 r = CMS_signed_add1_attr_by_NID(si, NID_SMIMECapabilities, 942 r = CMS_signed_add1_attr_by_NID(si, NID_SMIMECapabilities,
943 V_ASN1_SEQUENCE, smder, smderlen); 943 V_ASN1_SEQUENCE, smder, smderlen);
944 OPENSSL_free(smder); 944 free(smder);
945 945
946 return r; 946 return r;
947} 947}