From bddb7c686e3d1aeb156722adc64b6c35ae720f87 Mon Sep 17 00:00:00 2001 From: beck <> Date: Thu, 17 Apr 2014 13:37:50 +0000 Subject: Change library to use intrinsic memory allocation functions instead of OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free --- src/lib/libcrypto/cms/cms_asn1.c | 4 ++-- src/lib/libcrypto/cms/cms_enc.c | 10 +++++----- src/lib/libcrypto/cms/cms_env.c | 20 ++++++++++---------- src/lib/libcrypto/cms/cms_ess.c | 2 +- src/lib/libcrypto/cms/cms_pwri.c | 10 +++++----- src/lib/libcrypto/cms/cms_sd.c | 14 +++++++------- 6 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/lib/libcrypto/cms') diff --git a/src/lib/libcrypto/cms/cms_asn1.c b/src/lib/libcrypto/cms/cms_asn1.c index cfe67fb6c1..bd7466cc1d 100644 --- a/src/lib/libcrypto/cms/cms_asn1.c +++ b/src/lib/libcrypto/cms/cms_asn1.c @@ -234,7 +234,7 @@ static int cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, if (kekri->key) { OPENSSL_cleanse(kekri->key, kekri->keylen); - OPENSSL_free(kekri->key); + free(kekri->key); } } else if (ri->type == CMS_RECIPINFO_PASS) @@ -243,7 +243,7 @@ static int cms_ri_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, if (pwri->pass) { OPENSSL_cleanse(pwri->pass, pwri->passlen); - OPENSSL_free(pwri->pass); + free(pwri->pass); } } } diff --git a/src/lib/libcrypto/cms/cms_enc.c b/src/lib/libcrypto/cms/cms_enc.c index bebeaf29c7..612fce6dde 100644 --- a/src/lib/libcrypto/cms/cms_enc.c +++ b/src/lib/libcrypto/cms/cms_enc.c @@ -143,7 +143,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) /* Generate random session key */ if (!enc || !ec->key) { - tkey = OPENSSL_malloc(tkeylen); + tkey = malloc(tkeylen); if (!tkey) { CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, @@ -184,7 +184,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) { /* Use random key */ OPENSSL_cleanse(ec->key, ec->keylen); - OPENSSL_free(ec->key); + free(ec->key); ec->key = tkey; ec->keylen = tkeylen; tkey = NULL; @@ -222,13 +222,13 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) if (ec->key && !keep_key) { OPENSSL_cleanse(ec->key, ec->keylen); - OPENSSL_free(ec->key); + free(ec->key); ec->key = NULL; } if (tkey) { OPENSSL_cleanse(tkey, tkeylen); - OPENSSL_free(tkey); + free(tkey); } if (ok) return b; @@ -243,7 +243,7 @@ int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, ec->cipher = cipher; if (key) { - ec->key = OPENSSL_malloc(keylen); + ec->key = malloc(keylen); if (!ec->key) return 0; memcpy(ec->key, key, keylen); diff --git a/src/lib/libcrypto/cms/cms_env.c b/src/lib/libcrypto/cms/cms_env.c index be20b1c024..78fa2aa7b7 100644 --- a/src/lib/libcrypto/cms/cms_env.c +++ b/src/lib/libcrypto/cms/cms_env.c @@ -334,7 +334,7 @@ static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, if (EVP_PKEY_encrypt(pctx, NULL, &eklen, ec->key, ec->keylen) <= 0) goto err; - ek = OPENSSL_malloc(eklen); + ek = malloc(eklen); if (ek == NULL) { @@ -355,7 +355,7 @@ static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, if (pctx) EVP_PKEY_CTX_free(pctx); if (ek) - OPENSSL_free(ek); + free(ek); return ret; } @@ -399,7 +399,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, ktri->encryptedKey->length) <= 0) goto err; - ek = OPENSSL_malloc(eklen); + ek = malloc(eklen); if (ek == NULL) { @@ -421,7 +421,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (ec->key) { OPENSSL_cleanse(ec->key, ec->keylen); - OPENSSL_free(ec->key); + free(ec->key); } ec->key = ek; @@ -431,7 +431,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, if (pctx) EVP_PKEY_CTX_free(pctx); if (!ret && ek) - OPENSSL_free(ek); + free(ek); return ret; } @@ -671,7 +671,7 @@ static int cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms, goto err; } - wkey = OPENSSL_malloc(ec->keylen + 8); + wkey = malloc(ec->keylen + 8); if (!wkey) { @@ -695,7 +695,7 @@ static int cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms, err: if (!r && wkey) - OPENSSL_free(wkey); + free(wkey); OPENSSL_cleanse(&actx, sizeof(actx)); return r; @@ -748,7 +748,7 @@ static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, goto err; } - ukey = OPENSSL_malloc(kekri->encryptedKey->length - 8); + ukey = malloc(kekri->encryptedKey->length - 8); if (!ukey) { @@ -776,7 +776,7 @@ static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, err: if (!r && ukey) - OPENSSL_free(ukey); + free(ukey); OPENSSL_cleanse(&actx, sizeof(actx)); return r; @@ -864,7 +864,7 @@ BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms) if (ec->key) { OPENSSL_cleanse(ec->key, ec->keylen); - OPENSSL_free(ec->key); + free(ec->key); ec->key = NULL; ec->keylen = 0; } diff --git a/src/lib/libcrypto/cms/cms_ess.c b/src/lib/libcrypto/cms/cms_ess.c index 90c0b82fb5..99a4da6356 100644 --- a/src/lib/libcrypto/cms/cms_ess.c +++ b/src/lib/libcrypto/cms/cms_ess.c @@ -157,7 +157,7 @@ int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr) CMSerr(CMS_F_CMS_ADD1_RECEIPTREQUEST, ERR_R_MALLOC_FAILURE); if (rrder) - OPENSSL_free(rrder); + free(rrder); return r; diff --git a/src/lib/libcrypto/cms/cms_pwri.c b/src/lib/libcrypto/cms/cms_pwri.c index b79612a12d..36a5db04b8 100644 --- a/src/lib/libcrypto/cms/cms_pwri.c +++ b/src/lib/libcrypto/cms/cms_pwri.c @@ -237,7 +237,7 @@ static int kek_unwrap_key(unsigned char *out, size_t *outlen, /* Invalid size */ return 0; } - tmp = OPENSSL_malloc(inlen); + tmp = malloc(inlen); /* setup IV by decrypting last two blocks */ EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl, in + inlen - 2 * blocklen, blocklen * 2); @@ -270,7 +270,7 @@ static int kek_unwrap_key(unsigned char *out, size_t *outlen, rv = 1; err: OPENSSL_cleanse(tmp, inlen); - OPENSSL_free(tmp); + free(tmp); return rv; } @@ -405,7 +405,7 @@ int 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) goto err; @@ -417,7 +417,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, } else { - key = OPENSSL_malloc(pwri->encryptedKey->length); + key = malloc(pwri->encryptedKey->length); if (!key) { @@ -446,7 +446,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, EVP_CIPHER_CTX_cleanup(&kekctx); if (!r && key) - 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 77fbd13596..d852af596d 100644 --- a/src/lib/libcrypto/cms/cms_sd.c +++ b/src/lib/libcrypto/cms/cms_sd.c @@ -658,7 +658,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, { unsigned char *sig; unsigned int siglen; - sig = OPENSSL_malloc(EVP_PKEY_size(si->pkey)); + sig = malloc(EVP_PKEY_size(si->pkey)); if (!sig) { CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, @@ -669,7 +669,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, { CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, CMS_R_SIGNFINAL_ERROR); - OPENSSL_free(sig); + free(sig); goto err; } ASN1_STRING_set0(si->signature, sig, siglen); @@ -738,8 +738,8 @@ int 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) goto err; if (EVP_DigestSignFinal(&mctx, abuf, &siglen) <= 0) @@ -760,7 +760,7 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si) err: if (abuf) - OPENSSL_free(abuf); + free(abuf); EVP_MD_CTX_cleanup(&mctx); return 0; @@ -792,7 +792,7 @@ int 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; @@ -917,7 +917,7 @@ int 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