summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-03-26 14:42:14 +0000
committerMatt Caswell <matt@openssl.org>2019-03-27 10:31:05 +0000
commite7a621d57b69014490574ffb3f9ba5bb9b0a61fc (patch)
treef9f08c3f1a74d0bfb7edbd561a620d98a6001184 /crypto/evp
parent9437fe0b01fee8dfd23303d66ad45c2f523a8f25 (diff)
Fix a memory leak in ARIA GCM
Fixes #8567 Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8586) (cherry picked from commit 183f52e29af27285ea4ed7c947b71c83618f8702)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/e_aria.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/crypto/evp/e_aria.c b/crypto/evp/e_aria.c
index 81c8a7eaf1..ac890d606e 100644
--- a/crypto/evp/e_aria.c
+++ b/crypto/evp/e_aria.c
@@ -486,6 +486,16 @@ static int aria_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
return 0;
}
+static int aria_gcm_cleanup(EVP_CIPHER_CTX *ctx)
+{
+ EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX, ctx);
+
+ if (gctx->iv != EVP_CIPHER_CTX_iv_noconst(ctx))
+ OPENSSL_free(gctx->iv);
+
+ return 1;
+}
+
static int aria_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
@@ -727,6 +737,8 @@ static int aria_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
}
}
+#define aria_ccm_cleanup NULL
+
#define ARIA_AUTH_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 \
| EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \
| EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \
@@ -739,7 +751,7 @@ static const EVP_CIPHER aria_##keylen##_##mode = { \
ARIA_AUTH_FLAGS|EVP_CIPH_##MODE##_MODE, \
aria_##mode##_init_key, \
aria_##mode##_cipher, \
- NULL, \
+ aria_##mode##_cleanup, \
sizeof(EVP_ARIA_##MODE##_CTX), \
NULL,NULL,aria_##mode##_ctrl,NULL }; \
const EVP_CIPHER *EVP_aria_##keylen##_##mode(void) \