summaryrefslogtreecommitdiff
path: root/cipher/mac.c
diff options
context:
space:
mode:
authorTianjia Zhang <tianjia.zhang@linux.alibaba.com>2020-06-16 17:09:28 +0800
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2020-06-16 21:44:37 +0300
commitddcce166ab8bc6f51f5b509bcbea13a8746384ec (patch)
tree31d7d8338be1c2399b4dddc78be6ef0fc90ceedc /cipher/mac.c
parent6c571bfda6409d7d668f5d44cea0c6c31e2688be (diff)
downloadlibgcrypt-ddcce166ab8bc6f51f5b509bcbea13a8746384ec.tar.gz
Add SM4 symmetric cipher algorithm
* cipher/Makefile.am (EXTRA_libcipher_la_SOURCES): Add sm4.c. * cipher/cipher.c (cipher_list, cipher_list_algo301): Add _gcry_cipher_spec_sm4. * cipher/mac-cmac.c (map_mac_algo_to_cipher): Add cmac SM4. (_gcry_mac_type_spec_cmac_sm4): Add cmac SM4. * cipher/mac-internal.h: Declare spec_cmac_sm4. * cipher/mac.c (mac_list, mac_list_algo201): Add cmac SM4. * cipher/sm4.c: New. * configure.ac (available_ciphers): Add sm4. * doc/gcrypt.texi: Add SM4 document. * src/cipher.h: Add declarations for SM4 and cmac SM4. * src/gcrypt.h.in (gcry_cipher_algos): Add algorithm ID for SM4. -- Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> [jk: add missing mapping in mac-cmac.c:map_mac_algo_to_cipher] [jk: add GCRY_MAC_CMAC_SM4 to gcrypt.texi] Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/mac.c')
-rw-r--r--cipher/mac.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/cipher/mac.c b/cipher/mac.c
index 0abc0d33..933be74c 100644
--- a/cipher/mac.c
+++ b/cipher/mac.c
@@ -130,6 +130,9 @@ static gcry_mac_spec_t * const mac_list[] = {
&_gcry_mac_type_spec_gost28147_imit,
#endif
&_gcry_mac_type_spec_poly1305mac,
+#if USE_SM4
+ &_gcry_mac_type_spec_cmac_sm4,
+#endif
NULL,
};
@@ -300,7 +303,12 @@ static gcry_mac_spec_t * const mac_list_algo201[] =
NULL,
#endif
#if USE_GOST28147
- &_gcry_mac_type_spec_cmac_gost28147
+ &_gcry_mac_type_spec_cmac_gost28147,
+#else
+ NULL,
+#endif
+#if USE_SM4
+ &_gcry_mac_type_spec_cmac_sm4
#else
NULL
#endif