summaryrefslogtreecommitdiff
path: root/cipher/mac.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2023-01-04 12:44:06 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2023-01-04 12:52:09 +0200
commitd1ccc409d4c655f695c7dc042a629a8898bd14eb (patch)
treee7573e07e6c2712875e48f2c1aca6aa7f652d6bc /cipher/mac.c
parentf2153d797f43a5fc8b80c2d908bf7dd6ad1fcc2a (diff)
downloadlibgcrypt-d1ccc409d4c655f695c7dc042a629a8898bd14eb.tar.gz
Add GMAC-SM4 and Poly1305-SM4
* cipher/cipher.c (cipher_list_algo301): Remove comma at the end of last entry. * cipher/mac-gmac.c (map_mac_algo_to_cipher): Add SM4. (_gcry_mac_type_spec_gmac_sm4): New. * cipher/max-internal.h (_gcry_mac_type_spec_gmac_sm4) (_gcry_mac_type_spec_poly1305mac_sm4): New. * cipher/mac-poly1305.c (poly1305mac_open): Add SM4. (_gcry_mac_type_spec_poly1305mac_sm4): New. * cipher/mac.c (mac_list, mac_list_algo401, mac_list_algo501): Add GMAC-SM4 and Poly1304-SM4. (mac_list_algo101): Remove comma at the end of last entry. * cipher/md.c (digest_list_algo301): Remove comma at the end of last entry. * doc/gcrypt.texi: Add GCRY_MAC_GMAC_SM4 and GCRY_MAC_POLY1305_SM4. * src/gcrypt.h.in (GCRY_MAC_GMAC_SM4, GCRY_MAC_POLY1305_SM4): New. * tests/bench-slope.c (bench_mac_init): Setup IV for GCRY_MAC_POLY1305_SM4. * tests/benchmark.c (mac_bench): Likewise. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/mac.c')
-rw-r--r--cipher/mac.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/cipher/mac.c b/cipher/mac.c
index ba1eb300..05d2c64c 100644
--- a/cipher/mac.c
+++ b/cipher/mac.c
@@ -132,8 +132,10 @@ static const gcry_mac_spec_t * const mac_list[] = {
&_gcry_mac_type_spec_poly1305mac,
#if USE_SM4
&_gcry_mac_type_spec_cmac_sm4,
+ &_gcry_mac_type_spec_gmac_sm4,
+ &_gcry_mac_type_spec_poly1305mac_sm4,
#endif
- NULL,
+ NULL
};
/* HMAC implementations start with index 101 (enum gcry_mac_algos) */
@@ -242,10 +244,10 @@ static const gcry_mac_spec_t * const mac_list_algo101[] =
#endif
#if USE_SHA512
&_gcry_mac_type_spec_hmac_sha512_256,
- &_gcry_mac_type_spec_hmac_sha512_224,
+ &_gcry_mac_type_spec_hmac_sha512_224
#else
NULL,
- NULL,
+ NULL
#endif
};
@@ -338,7 +340,12 @@ static const gcry_mac_spec_t * const mac_list_algo401[] =
NULL,
#endif
#if USE_SEED
- &_gcry_mac_type_spec_gmac_seed
+ &_gcry_mac_type_spec_gmac_seed,
+#else
+ NULL,
+#endif
+#if USE_SM4
+ &_gcry_mac_type_spec_gmac_sm4
#else
NULL
#endif
@@ -369,7 +376,12 @@ static const gcry_mac_spec_t * const mac_list_algo501[] =
NULL,
#endif
#if USE_SEED
- &_gcry_mac_type_spec_poly1305mac_seed
+ &_gcry_mac_type_spec_poly1305mac_seed,
+#else
+ NULL,
+#endif
+#if USE_SM4
+ &_gcry_mac_type_spec_poly1305mac_sm4
#else
NULL
#endif