From 40ce59403b918c4baa975308e0e0fed2d27b9012 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 11 Aug 2019 10:41:49 +0000 Subject: Use malloc(3) and free(3), rather than OPENSSL_{malloc,free}(). --- src/lib/libcrypto/cms/cms_enc.c | 6 +++--- src/lib/libcrypto/cms/cms_env.c | 18 +++++++++--------- src/lib/libcrypto/cms/cms_ess.c | 4 ++-- src/lib/libcrypto/cms/cms_kari.c | 8 ++++---- src/lib/libcrypto/cms/cms_pwri.c | 10 +++++----- src/lib/libcrypto/cms/cms_sd.c | 20 ++++++++++---------- 6 files changed, 33 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/cms/cms_enc.c b/src/lib/libcrypto/cms/cms_enc.c index a04c831f95..a032c801f5 100644 --- a/src/lib/libcrypto/cms/cms_enc.c +++ b/src/lib/libcrypto/cms/cms_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_enc.c,v 1.15 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_enc.c,v 1.16 2019/08/11 10:41:49 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -128,7 +128,7 @@ cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) tkeylen = EVP_CIPHER_CTX_key_length(ctx); /* Generate random session key */ if (!enc || !ec->key) { - tkey = OPENSSL_malloc(tkeylen); + tkey = malloc(tkeylen); if (tkey == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); goto err; @@ -209,7 +209,7 @@ cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, { ec->cipher = cipher; if (key) { - if ((ec->key = OPENSSL_malloc(keylen)) == NULL) { + if ((ec->key = malloc(keylen)) == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); return 0; } diff --git a/src/lib/libcrypto/cms/cms_env.c b/src/lib/libcrypto/cms/cms_env.c index d6bf34c02a..38d6b5649c 100644 --- a/src/lib/libcrypto/cms/cms_env.c +++ b/src/lib/libcrypto/cms/cms_env.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_env.c,v 1.17 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_env.c,v 1.18 2019/08/11 10:41:49 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -392,7 +392,7 @@ cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) if (EVP_PKEY_encrypt(pctx, NULL, &eklen, ec->key, ec->keylen) <= 0) goto err; - ek = OPENSSL_malloc(eklen); + ek = malloc(eklen); if (ek == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); @@ -410,7 +410,7 @@ cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) err: EVP_PKEY_CTX_free(pctx); ktri->pctx = NULL; - OPENSSL_free(ek); + free(ek); return ret; } @@ -454,7 +454,7 @@ cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) ktri->encryptedKey->length) <= 0) goto err; - ek = OPENSSL_malloc(eklen); + ek = malloc(eklen); if (ek == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); @@ -477,7 +477,7 @@ cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) EVP_PKEY_CTX_free(ktri->pctx); ktri->pctx = NULL; if (!ret) - OPENSSL_free(ek); + free(ek); return ret; } @@ -697,7 +697,7 @@ cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) goto err; } - wkey = OPENSSL_malloc(ec->keylen + 8); + wkey = malloc(ec->keylen + 8); if (wkey == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); goto err; @@ -715,7 +715,7 @@ cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) err: if (!r) - OPENSSL_free(wkey); + free(wkey); OPENSSL_cleanse(&actx, sizeof(actx)); return r; @@ -759,7 +759,7 @@ cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) goto err; } - ukey = OPENSSL_malloc(kekri->encryptedKey->length - 8); + ukey = malloc(kekri->encryptedKey->length - 8); if (ukey == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); goto err; @@ -781,7 +781,7 @@ cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri) err: if (!r) - OPENSSL_free(ukey); + free(ukey); OPENSSL_cleanse(&actx, sizeof(actx)); return r; diff --git a/src/lib/libcrypto/cms/cms_ess.c b/src/lib/libcrypto/cms/cms_ess.c index 1d3f092ae8..d488297c87 100644 --- a/src/lib/libcrypto/cms/cms_ess.c +++ b/src/lib/libcrypto/cms/cms_ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_ess.c,v 1.16 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_ess.c,v 1.17 2019/08/11 10:41:49 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -172,7 +172,7 @@ CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr) if (!r) CMSerror(ERR_R_MALLOC_FAILURE); - OPENSSL_free(rrder); + free(rrder); return r; } diff --git a/src/lib/libcrypto/cms/cms_kari.c b/src/lib/libcrypto/cms/cms_kari.c index e1f22cc43a..19513e3658 100644 --- a/src/lib/libcrypto/cms/cms_kari.c +++ b/src/lib/libcrypto/cms/cms_kari.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_kari.c,v 1.7 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_kari.c,v 1.8 2019/08/11 10:41:49 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -256,7 +256,7 @@ cms_kek_cipher(unsigned char **pout, size_t *poutlen, const unsigned char *in, /* obtain output length of ciphered key */ if (!EVP_CipherUpdate(kari->ctx, NULL, &outlen, in, inlen)) goto err; - out = OPENSSL_malloc(outlen); + out = malloc(outlen); if (out == NULL) goto err; if (!EVP_CipherUpdate(kari->ctx, out, &outlen, in, inlen)) @@ -268,7 +268,7 @@ cms_kek_cipher(unsigned char **pout, size_t *poutlen, const unsigned char *in, err: OPENSSL_cleanse(kek, keklen); if (!rv) - OPENSSL_free(out); + free(out); EVP_CIPHER_CTX_reset(kari->ctx); /* FIXME: WHY IS kari->pctx freed here? /RL */ EVP_PKEY_CTX_free(kari->pctx); @@ -303,7 +303,7 @@ CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, rv = 1; err: - OPENSSL_free(cek); + free(cek); return rv; } diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c index dd66541409..30c5ce0618 100644 --- a/src/lib/libcrypto/cms/cms_pwri.c +++ b/src/lib/libcrypto/cms/cms_pwri.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_pwri.c,v 1.20 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_pwri.c,v 1.21 2019/08/11 10:41:49 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -232,7 +232,7 @@ kek_unwrap_key(unsigned char *out, size_t *outlen, const unsigned char *in, /* Invalid size */ return 0; } - if ((tmp = OPENSSL_malloc(inlen)) == NULL) { + if ((tmp = malloc(inlen)) == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); return 0; } @@ -391,7 +391,7 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, if (!kek_wrap_key(NULL, &keylen, ec->key, ec->keylen, kekctx)) goto err; - key = OPENSSL_malloc(keylen); + key = malloc(keylen); if (key == NULL) goto err; @@ -400,7 +400,7 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, pwri->encryptedKey->data = key; pwri->encryptedKey->length = keylen; } else { - key = OPENSSL_malloc(pwri->encryptedKey->length); + key = malloc(pwri->encryptedKey->length); if (key == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); goto err; @@ -421,7 +421,7 @@ cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, err: EVP_CIPHER_CTX_free(kekctx); if (!r) - OPENSSL_free(key); + free(key); X509_ALGOR_free(kekalg); return r; 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 @@ -/* $OpenBSD: cms_sd.c,v 1.19 2019/08/11 10:38:27 jsing Exp $ */ +/* $OpenBSD: cms_sd.c,v 1.20 2019/08/11 10:41:49 jsing Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -650,13 +650,13 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain if (!EVP_DigestFinal_ex(mctx, md, &mdlen)) goto err; siglen = EVP_PKEY_size(si->pkey); - sig = OPENSSL_malloc(siglen); + sig = malloc(siglen); if (sig == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (EVP_PKEY_sign(pctx, sig, &siglen, md, mdlen) <= 0) { - OPENSSL_free(sig); + free(sig); goto err; } ASN1_STRING_set0(si->signature, sig, siglen); @@ -664,14 +664,14 @@ cms_SignerInfo_content_sign(CMS_ContentInfo *cms, CMS_SignerInfo *si, BIO *chain unsigned char *sig; unsigned int siglen; - sig = OPENSSL_malloc(EVP_PKEY_size(si->pkey)); + sig = malloc(EVP_PKEY_size(si->pkey)); if (sig == NULL) { CMSerror(ERR_R_MALLOC_FAILURE); goto err; } if (!EVP_SignFinal(mctx, sig, &siglen, si->pkey)) { CMSerror(CMS_R_SIGNFINAL_ERROR); - OPENSSL_free(sig); + free(sig); goto err; } ASN1_STRING_set0(si->signature, sig, siglen); @@ -746,8 +746,8 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si) goto err; if (EVP_DigestSignFinal(mctx, NULL, &siglen) <= 0) goto err; - OPENSSL_free(abuf); - abuf = OPENSSL_malloc(siglen); + free(abuf); + abuf = malloc(siglen); if (abuf == NULL) goto err; if (EVP_DigestSignFinal(mctx, abuf, &siglen) <= 0) @@ -766,7 +766,7 @@ CMS_SignerInfo_sign(CMS_SignerInfo *si) return 1; err: - OPENSSL_free(abuf); + free(abuf); EVP_MD_CTX_reset(mctx); return 0; @@ -804,7 +804,7 @@ CMS_SignerInfo_verify(CMS_SignerInfo *si) if (!abuf) goto err; r = EVP_DigestVerifyUpdate(mctx, abuf, alen); - OPENSSL_free(abuf); + free(abuf); if (r <= 0) { r = -1; goto err; @@ -941,7 +941,7 @@ CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs) return 0; r = CMS_signed_add1_attr_by_NID(si, NID_SMIMECapabilities, V_ASN1_SEQUENCE, smder, smderlen); - OPENSSL_free(smder); + free(smder); return r; } -- cgit v1.2.3-55-g6feb