Skip to content

Commit

Permalink
xfrm: Add support for SM4 symmetric cipher algorithm
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Xu Jia authored and Steffen Klassert committed Dec 23, 2021
1 parent e6911af commit 23b6a6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/uapi/linux/pfkeyv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
21 changes: 21 additions & 0 deletions net/xfrm/xfrm_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down

0 comments on commit 23b6a6d

Please sign in to comment.