summaryrefslogtreecommitdiff
path: root/lib/nettle
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2018-09-21 22:11:51 +0300
committerDmitry Baryshkov <dbaryshkov@gmail.com>2020-06-07 00:59:24 +0300
commita78c95a8e5c201f4b41664c6edb94048b8ac5b4b (patch)
tree097935349b84246f45f91e828bc3147255a6cd1f /lib/nettle
parent4abbdc5cfe17b6d40c39d485453daf256aac581c (diff)
downloadgnutls-a78c95a8e5c201f4b41664c6edb94048b8ac5b4b.tar.gz
lib: add Magma/Kuznyechik OMAC support
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'lib/nettle')
-rw-r--r--lib/nettle/mac.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c
index e2ba0cb4d6..07a218ea48 100644
--- a/lib/nettle/mac.c
+++ b/lib/nettle/mac.c
@@ -52,6 +52,7 @@
#endif
#ifndef HAVE_NETTLE_GOST28147_SET_KEY
#include "gost/gost28147.h"
+#include "gost/cmac.h"
#endif
#include "gost/cmac.h"
#endif
@@ -123,6 +124,8 @@ struct nettle_mac_ctx {
struct hmac_streebog256_ctx streebog256;
struct hmac_streebog512_ctx streebog512;
struct gost28147_imit_ctx gost28147_imit;
+ struct cmac_magma_ctx magma;
+ struct cmac_kuznyechik_ctx kuznyechik;
#endif
struct umac96_ctx umac96;
struct umac128_ctx umac128;
@@ -147,6 +150,18 @@ _wrap_gost28147_imit_set_key_tc26z(void *ctx, size_t len, const uint8_t * key)
gost28147_imit_set_param(ctx, &gost28147_param_TC26_Z);
gost28147_imit_set_key(ctx, len, key);
}
+
+static void
+_wrap_cmac_magma_set_key(void *ctx, size_t len, const uint8_t * key)
+{
+ cmac_magma_set_key(ctx, key);
+}
+
+static void
+_wrap_cmac_kuznyechik_set_key(void *ctx, size_t len, const uint8_t * key)
+{
+ cmac_kuznyechik_set_key(ctx, key);
+}
#endif
static void
@@ -342,6 +357,20 @@ static int _mac_ctx_init(gnutls_mac_algorithm_t algo,
ctx->ctx_ptr = &ctx->ctx.gost28147_imit;
ctx->length = GOST28147_IMIT_DIGEST_SIZE;
break;
+ case GNUTLS_MAC_MAGMA_OMAC:
+ ctx->update = (update_func) cmac_magma_update;
+ ctx->digest = (digest_func) cmac_magma_digest;
+ ctx->set_key = _wrap_cmac_magma_set_key;
+ ctx->ctx_ptr = &ctx->ctx.magma;
+ ctx->length = CMAC64_DIGEST_SIZE;
+ break;
+ case GNUTLS_MAC_KUZNYECHIK_OMAC:
+ ctx->update = (update_func) cmac_kuznyechik_update;
+ ctx->digest = (digest_func) cmac_kuznyechik_digest;
+ ctx->set_key = _wrap_cmac_kuznyechik_set_key;
+ ctx->ctx_ptr = &ctx->ctx.kuznyechik;
+ ctx->length = CMAC128_DIGEST_SIZE;
+ break;
#endif
case GNUTLS_MAC_UMAC_96:
ctx->update = (update_func) umac96_update;
@@ -457,6 +486,8 @@ static int wrap_nettle_mac_exists(gnutls_mac_algorithm_t algo)
case GNUTLS_MAC_STREEBOG_256:
case GNUTLS_MAC_STREEBOG_512:
case GNUTLS_MAC_GOST28147_TC26Z_IMIT:
+ case GNUTLS_MAC_MAGMA_OMAC:
+ case GNUTLS_MAC_KUZNYECHIK_OMAC:
#endif
return 1;
default: