Skip to contentSkip to conversation

xfrm: add ARIA CBC and CTR support

PATCH In review Hong In-su 2 participants 4 messages Sep 16 – Oct 14

Subsystems (3)
lore
Share & tools
lore

Hong In-su

author
#0 lore raw

PATCH v2 1/1 xfrm: add ARIA CBC and CTR support

The kernel crypto API already provides ARIA implementations, but XFRM does not have algorithm descriptors for them. Consequently, ARIA cannot be selected for ESP through XFRM.

Add XFRM algorithm descriptors for CBC and RFC3686 CTR modes using the existing cbc(aria) and rfc3686(ctr(aria)) crypto algorithms.

The CBC and CTR modes have been tested with IPsec using strongSwan.

---
Changes in v2:
- Drop the duplicate "aria" compatibility alias from the CTR entry.
- Use a 128-bit default key size for CBC.
- Document that the CTR default key size includes the 32-bit nonce.

v1: https://lore.kernel.org/netdev/[email protected]/

 net/xfrm/xfrm_algo.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
net/xfrm/xfrm_algo.c +27 -0
index 70434495f23f..7ed84220ad5d 100644
@@ -512,6 +512,33 @@ static struct xfrm_algo_desc ealg_list[] = {
 		.sadb_alg_maxbits = 256
 	}
 },
+{
+	.name = "cbc(aria)",
+	.compat = "aria",
+
+	.uinfo = {
+		.encr = {
+			.geniv = "echainiv",
+			.blockbits = 128,
+			.defkeybits = 128,
+		}
+	},
+
+	.pfkey_supported = 0,
+},
+{
+	.name = "rfc3686(ctr(aria))",
+
+	.uinfo = {
+		.encr = {
+			.geniv = "seqiv",
+			.blockbits = 128,
+			.defkeybits = 160, /* 128-bit key + 32-bit nonce */
+		}
+	},
+
+	.pfkey_supported = 0,
+},
 {
 	.name = "cbc(twofish)",
 	.compat = "twofish",
Signature · 1 line
2.43.0
#1 lore raw

Note: for IPsec patches, the subject prefix should be [PATCH ipsec] or [PATCH ipsec-next] instead of net/net-next (with the same bugfix/feature split).

Quoted 6 lines · Hong In-su

The kernel crypto API already provides ARIA implementations, but XFRM does not have algorithm descriptors for them. Consequently, ARIA cannot be selected for ESP through XFRM.

Add XFRM algorithm descriptors for CBC and RFC3686 CTR modes using the existing cbc(aria) and rfc3686(ctr(aria)) crypto algorithms.

Why only those, and not for example gcm(aria)? (just to mention one that I know is a "valid" combination, since it's used in ktls, but I guess all the combinations that are supported for AES would also be valid)

Quoted 19 lines

The CBC and CTR modes have been tested with IPsec using strongSwan.

---
Changes in v2:
- Drop the duplicate "aria" compatibility alias from the CTR entry.
- Use a 128-bit default key size for CBC.
- Document that the CTR default key size includes the 32-bit nonce.

v1: https://lore.kernel.org/netdev/[email protected]/

 net/xfrm/xfrm_algo.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
net/xfrm/xfrm_algo.c +0 -0
index 70434495f23f..7ed84220ad5d 100644

net/xfrm/xfrm_algo.c static struct xfrm_algo_desc ealg_list[] = { · line 517

Quoted 6 lines
net/xfrm/xfrm_algo.c +3 -0
@@ -512,6 +512,33 @@ static struct xfrm_algo_desc ealg_list[] = {
 		.sadb_alg_maxbits = 256
 	}
 },
+{
+	.name = "cbc(aria)",
+	.compat = "aria",

I missed v1 and the bot's feedback, but I'm wondering: Steffen, do we still want to add "compat" names for new algorithms? SM3/SM4 are the only additions post-2010 that got an alias. It saves a few characters on the way in, and then we get the full name back during dumps, which is probably more confusing than helpful.

Signature · 1 line
Sabrina
author
#2 lore raw

CBC and CTR are the modes I have tested with IPsec using strongSwan. GCM has not been tested yet, so I plan to test it separately and submit a follow-up patch once it has been validated.

Thanks for the review.

author
#3 lore raw

I'd like to follow up on the compatibility alias discussion.

Steffen, would you prefer to remove the .compat = "aria" entry for CBC in v3?

I'm happy to follow your preference.

Thanks,
Hong In-su