projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adapt the rest of the source to the removal of (EVP_MD_CTX|HMAC_CTX)_cleanup
[openssl.git]
/
crypto
/
cms
/
cms_pwri.c
diff --git
a/crypto/cms/cms_pwri.c
b/crypto/cms/cms_pwri.c
index 4f1b31d8ae86b27a19b5136d94a59628b01ab374..d662938768cb268d3e60056de19330576f173c7f 100644
(file)
--- a/
crypto/cms/cms_pwri.c
+++ b/
crypto/cms/cms_pwri.c
@@
-52,7
+52,7
@@
* ====================================================================
*/
* ====================================================================
*/
-#include "cryptlib.h"
+#include "
internal/
cryptlib.h"
#include <openssl/asn1t.h>
#include <openssl/pem.h>
#include <openssl/x509v3.h>
#include <openssl/asn1t.h>
#include <openssl/pem.h>
#include <openssl/x509v3.h>
@@
-121,6
+121,9
@@
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
/* Setup algorithm identifier for cipher */
encalg = X509_ALGOR_new();
/* Setup algorithm identifier for cipher */
encalg = X509_ALGOR_new();
+ if (encalg == NULL) {
+ goto merr;
+ }
EVP_CIPHER_CTX_init(&ctx);
if (EVP_EncryptInit_ex(&ctx, kekciph, NULL, NULL, NULL) <= 0) {
EVP_CIPHER_CTX_init(&ctx);
if (EVP_EncryptInit_ex(&ctx, kekciph, NULL, NULL, NULL) <= 0) {
@@
-155,11
+158,11
@@
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
/* Initialize recipient info */
ri = M_ASN1_new_of(CMS_RecipientInfo);
/* Initialize recipient info */
ri = M_ASN1_new_of(CMS_RecipientInfo);
- if (
!ri
)
+ if (
ri == NULL
)
goto merr;
ri->d.pwri = M_ASN1_new_of(CMS_PasswordRecipientInfo);
goto merr;
ri->d.pwri = M_ASN1_new_of(CMS_PasswordRecipientInfo);
- if (
!ri->d.pwri
)
+ if (
ri->d.pwri == NULL
)
goto merr;
ri->type = CMS_RECIPINFO_PASS;
goto merr;
ri->type = CMS_RECIPINFO_PASS;
@@
-167,11
+170,11
@@
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
/* Since this is overwritten, free up empty structure already there */
X509_ALGOR_free(pwri->keyEncryptionAlgorithm);
pwri->keyEncryptionAlgorithm = X509_ALGOR_new();
/* Since this is overwritten, free up empty structure already there */
X509_ALGOR_free(pwri->keyEncryptionAlgorithm);
pwri->keyEncryptionAlgorithm = X509_ALGOR_new();
- if (
!pwri->keyEncryptionAlgorithm
)
+ if (
pwri->keyEncryptionAlgorithm == NULL
)
goto merr;
pwri->keyEncryptionAlgorithm->algorithm = OBJ_nid2obj(wrap_nid);
pwri->keyEncryptionAlgorithm->parameter = ASN1_TYPE_new();
goto merr;
pwri->keyEncryptionAlgorithm->algorithm = OBJ_nid2obj(wrap_nid);
pwri->keyEncryptionAlgorithm->parameter = ASN1_TYPE_new();
- if (
!pwri->keyEncryptionAlgorithm->parameter
)
+ if (
pwri->keyEncryptionAlgorithm->parameter == NULL
)
goto merr;
if (!ASN1_item_pack(encalg, ASN1_ITEM_rptr(X509_ALGOR),
goto merr;
if (!ASN1_item_pack(encalg, ASN1_ITEM_rptr(X509_ALGOR),
@@
-204,8
+207,7
@@
CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
EVP_CIPHER_CTX_cleanup(&ctx);
if (ri)
M_ASN1_free_of(ri, CMS_RecipientInfo);
EVP_CIPHER_CTX_cleanup(&ctx);
if (ri)
M_ASN1_free_of(ri, CMS_RecipientInfo);
- if (encalg)
- X509_ALGOR_free(encalg);
+ X509_ALGOR_free(encalg);
return NULL;
}
return NULL;
}
@@
-231,7
+233,7
@@
static int kek_unwrap_key(unsigned char *out, size_t *outlen,
return 0;
}
tmp = OPENSSL_malloc(inlen);
return 0;
}
tmp = OPENSSL_malloc(inlen);
- if
(!tmp
)
+ if
(tmp == NULL
)
return 0;
/* setup IV by decrypting last two blocks */
if (!EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl,
return 0;
/* setup IV by decrypting last two blocks */
if (!EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl,
@@
-264,8
+266,7
@@
static int kek_unwrap_key(unsigned char *out, size_t *outlen,
memcpy(out, tmp + 4, *outlen);
rv = 1;
err:
memcpy(out, tmp + 4, *outlen);
rv = 1;
err:
- OPENSSL_cleanse(tmp, inlen);
- OPENSSL_free(tmp);
+ OPENSSL_clear_free(tmp, inlen);
return rv;
}
return rv;
}
@@
-390,7
+391,7
@@
int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
key = OPENSSL_malloc(keylen);
key = OPENSSL_malloc(keylen);
- if (
!key
)
+ if (
key == NULL
)
goto err;
if (!kek_wrap_key(key, &keylen, ec->key, ec->keylen, &kekctx))
goto err;
if (!kek_wrap_key(key, &keylen, ec->key, ec->keylen, &kekctx))
@@
-400,7
+401,7
@@
int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
} else {
key = OPENSSL_malloc(pwri->encryptedKey->length);
} else {
key = OPENSSL_malloc(pwri->encryptedKey->length);
- if (
!key
) {
+ if (
key == NULL
) {
CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, ERR_R_MALLOC_FAILURE);
goto err;
}
CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, ERR_R_MALLOC_FAILURE);
goto err;
}
@@
-422,7
+423,7
@@
int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
EVP_CIPHER_CTX_cleanup(&kekctx);
EVP_CIPHER_CTX_cleanup(&kekctx);
- if (!r
&& key
)
+ if (!r)
OPENSSL_free(key);
X509_ALGOR_free(kekalg);
OPENSSL_free(key);
X509_ALGOR_free(kekalg);