xfrm: Add support for SM4 symmetric cipher algorithm
authorXu Jia <xujia39@huawei.com>
Wed, 22 Dec 2021 09:06:59 +0000 (17:06 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 23 Dec 2021 08:32:51 +0000 (09:32 +0100)
This patch adds SM4 encryption algorithm entry to ealg_list.

Signed-off-by: Xu Jia <xujia39@huawei.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/uapi/linux/pfkeyv2.h
net/xfrm/xfrm_algo.c

index 798ba9ffd48c7b95ebd3f93ccc0271036855262d..8abae1f6749c59b10029009bb081fa03bcf71981 100644 (file)
@@ -330,6 +330,7 @@ struct sadb_x_filter {
 #define SADB_X_EALG_AES_GCM_ICV16      20
 #define SADB_X_EALG_CAMELLIACBC                22
 #define SADB_X_EALG_NULL_AES_GMAC      23
+#define SADB_X_EALG_SM4CBC             24
 #define SADB_EALG_MAX                   253 /* last EALG */
 /* private allocations should use 249-255 (RFC2407) */
 #define SADB_X_EALG_SERPENTCBC  252     /* draft-ietf-ipsec-ciph-aes-cbc-00 */
index 00b5444a4d86def5defb39760ec4a9fa6e5ef675..094734fbec9675053c45f71eda6162d22b4564d1 100644 (file)
@@ -572,6 +572,27 @@ static struct xfrm_algo_desc ealg_list[] = {
                .sadb_alg_maxbits = 288
        }
 },
+{
+       .name = "cbc(sm4)",
+       .compat = "sm4",
+
+       .uinfo = {
+               .encr = {
+                       .geniv = "echainiv",
+                       .blockbits = 128,
+                       .defkeybits = 128,
+               }
+       },
+
+       .pfkey_supported = 1,
+
+       .desc = {
+               .sadb_alg_id = SADB_X_EALG_SM4CBC,
+               .sadb_alg_ivlen = 16,
+               .sadb_alg_minbits = 128,
+               .sadb_alg_maxbits = 256
+       }
+},
 };
 
 static struct xfrm_algo_desc calg_list[] = {