summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2024-01-05 17:29:20 +0100
committerTomas Mraz <tomas@openssl.org>2024-01-08 12:04:07 +0100
commit5802de95768aabec92b1f09a1c5ae13763a8da86 (patch)
tree7e8f33a74c4ca553d0618c0384b445e040bdd506
parent143a0915e34553912ee37331b189e78096861bfb (diff)
Add missing sm4_ccm_dupctx() and sm4_gcm_dupctx()
Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/23217)
-rw-r--r--providers/implementations/ciphers/cipher_sm4_ccm.c15
-rw-r--r--providers/implementations/ciphers/cipher_sm4_gcm.c15
2 files changed, 30 insertions, 0 deletions
diff --git a/providers/implementations/ciphers/cipher_sm4_ccm.c b/providers/implementations/ciphers/cipher_sm4_ccm.c
index 38e75016e9..0332b5627a 100644
--- a/providers/implementations/ciphers/cipher_sm4_ccm.c
+++ b/providers/implementations/ciphers/cipher_sm4_ccm.c
@@ -28,6 +28,21 @@ static void *sm4_ccm_newctx(void *provctx, size_t keybits)
return ctx;
}
+static void *sm4_ccm_dupctx(void *provctx)
+{
+ PROV_SM4_CCM_CTX *ctx = provctx;
+ PROV_SM4_CCM_CTX *dctx = NULL;
+
+ if (ctx == NULL)
+ return NULL;
+
+ dctx = OPENSSL_memdup(ctx, sizeof(*ctx));
+ if (dctx != NULL && dctx->base.ccm_ctx.key != NULL)
+ dctx->base.ccm_ctx.key = &dctx->ks.ks;
+
+ return dctx;
+}
+
static void sm4_ccm_freectx(void *vctx)
{
PROV_SM4_CCM_CTX *ctx = (PROV_SM4_CCM_CTX *)vctx;
diff --git a/providers/implementations/ciphers/cipher_sm4_gcm.c b/providers/implementations/ciphers/cipher_sm4_gcm.c
index ce1aa2b07d..edbeaeb849 100644
--- a/providers/implementations/ciphers/cipher_sm4_gcm.c
+++ b/providers/implementations/ciphers/cipher_sm4_gcm.c
@@ -29,6 +29,21 @@ static void *sm4_gcm_newctx(void *provctx, size_t keybits)
return ctx;
}
+static void *sm4_gcm_dupctx(void *provctx)
+{
+ PROV_SM4_GCM_CTX *ctx = provctx;
+ PROV_SM4_GCM_CTX *dctx = NULL;
+
+ if (ctx == NULL)
+ return NULL;
+
+ dctx = OPENSSL_memdup(ctx, sizeof(*ctx));
+ if (dctx != NULL && dctx->base.gcm.key != NULL)
+ dctx->base.gcm.key = &dctx->ks.ks;
+
+ return dctx;
+}
+
static void sm4_gcm_freectx(void *vctx)
{
PROV_SM4_GCM_CTX *ctx = (PROV_SM4_GCM_CTX *)vctx;