Skip to contentSkip to conversation

esp: select CRYPTO_SEQIV

PATCH Superseded Eric Biggers 4 participants 10 messages Jun 4, 2020 – Jun 8, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 esp: select CRYPTO_SEQIV

From: Eric Biggers <[email protected]>

Since CRYPTO_CTR no longer selects CRYPTO_SEQIV, it should be selected by INET_ESP and INET6_ESP -- similar to CRYPTO_ECHAINIV.

Fixes f23efcbcc523 ("crypto: ctr - no longer needs CRYPTO_SEQIV")
Cc Corentin Labbe <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Steffen Klassert <[email protected]>
---
 net/ipv4/Kconfig | 1 +
 net/ipv6/Kconfig | 1 +
 2 files changed, 2 insertions(+)
net/ipv4/Kconfig +1 -0
index 23ba5045e3d3..d393e8132aa1 100644
@@ -361,6 +361,7 @@ config INET_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV
 	---help---
 	  Support for IPsec ESP.
 
net/ipv6/Kconfig +1 -0
index 4f03aece2980..f2f4563c8dbf 100644
@@ -70,6 +70,7 @@ config INET6_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV
 	---help---
 	  Support for IPsec ESP.
 
Signature · 1 line
2.27.0.278.ge193c7cf3a9-goog
maintainer
#1 lore raw
Quoted 21 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Since CRYPTO_CTR no longer selects CRYPTO_SEQIV, it should be selected by INET_ESP and INET6_ESP -- similar to CRYPTO_ECHAINIV.

Fixes f23efcbcc523 ("crypto: ctr - no longer needs CRYPTO_SEQIV")
Cc Corentin Labbe <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Steffen Klassert <[email protected]>
---
 net/ipv4/Kconfig | 1 +
 net/ipv6/Kconfig | 1 +
 2 files changed, 2 insertions(+)
net/ipv4/Kconfig +0 -0
index 23ba5045e3d3..d393e8132aa1 100644

net/ipv4/Kconfig config INET_ESP · line 366

Quoted 6 lines
net/ipv4/Kconfig +1 -0
@@ -361,6 +361,7 @@ config INET_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV
 	---help---
 	  Support for IPsec ESP.

Hmm, the selection list doesn't include CTR so just adding SEQIV per se makes no sense. I'm not certain that we really want to include every algorithm under the sun. Steffen, what do you think?

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#2 lore raw
Quoted 4 lines · Herbert Xu

Hmm, the selection list doesn't include CTR so just adding SEQIV per se makes no sense. I'm not certain that we really want to include every algorithm under the sun. Steffen, what do you think?

Or how about

select CRYPTO_SEQIV if CRYPTO_CTR

That would make more sense.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw
Quoted 6 lines · Herbert Xu
Quoted 4 lines · Herbert Xu

Hmm, the selection list doesn't include CTR so just adding SEQIV per se makes no sense. I'm not certain that we really want to include every algorithm under the sun. Steffen, what do you think?

Quoted 7 lines

Or how about

select CRYPTO_SEQIV if CRYPTO_CTR

That would make more sense.

Cheers,

There's also a case where "seqiv" is used without counter mode:

net/xfrm/xfrm_algo.c:

{
        .name = "rfc7539esp(chacha20,poly1305)",

        .uinfo = {
                .aead = {
                        .geniv = "seqiv",
                        .icv_truncbits = 128,
                }
        },

        .pfkey_supported = 0,
},

FWIW, we make CONFIG_FS_ENCRYPTION select only the algorithms that we consider the "default", and any "non-default" algorithms need to be explicitly enabled.

Is something similar going on here with INET_ESP and INET_ESP6? Should "seqiv" be considered a "default" for IPsec?

- Eric

maintainer
#4 lore raw
Quoted 7 lines · Eric Biggers

There's also a case where "seqiv" is used without counter mode:

net/xfrm/xfrm_algo.c:

{
        .name = "rfc7539esp(chacha20,poly1305)",

So

	select CRYPTO_SEQIV if CRYPTO_CTR || CRYPTO_CHACHA20POLY1305

and if the list gets too long we could create another symbol that is selected by the algorithms, say CRYPTO_SEQIV_ESP which could then be used as the condition:

config CRYPTO_SEQIV_ESP
bool

config CRYPTO_CTR
select CRYPTO_SEQIV_ESP

config INET_ESP
select CRYPTO_SEQIV if CRYPTO_SEQIV_ESP

Quoted 5 lines

FWIW, we make CONFIG_FS_ENCRYPTION select only the algorithms that we consider the "default", and any "non-default" algorithms need to be explicitly enabled.

Is something similar going on here with INET_ESP and INET_ESP6? Should "seqiv" be considered a "default" for IPsec?

The default with IPsec is up to the user-space IPsec manager, e.g., libreswan. So the kernel has no idea what the default is. Also, unlike filesystems IPsec is about interoperability so the default is actually a list of algorithms.

If you were using libreswan then top of the list is gcm(aes), followed by aes(cbc)+sha256, and then aes(cbc)+sha1.

Incidentally we should probably prune the INET_ESP select list. At least MD5/SHA1/DES shouldn't be on it. We probably should add AES, SHA256 and GCM to the list.

Another potential improvement is to merge the two select lists between ESP and ESP6. Perhaps move them to a new tristate say XFRM_ESP that would then be selected by ESP and ESP6.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#5 lore raw

PATCH v2 1/1 esp: select CRYPTO_SEQIV when useful

From: Eric Biggers <[email protected]>

CRYPTO_CTR no longer selects CRYPTO_SEQIV, which breaks IPsec for users who need any of the algorithms that use seqiv. These users now would need to explicitly enable CRYPTO_SEQIV.

There doesn't seem to be a clear rule on what algorithms the IPsec options (INET_ESP and INET6_ESP) actually select, as apparently none is *always* required. They currently select just a particular subset, along with CRYPTO_ECHAINIV which is the other IV generator template.

As a compromise between too many and too few selections, select CRYPTO_SEQIV if either CRYPTO_CTR or CRYPTO_CHACHA20POLY1305 is enabled. These are the algorithms that can use seqiv for IPsec. (Note: GCM and CCM can too, but those both use CTR.)

Fixes f23efcbcc523 ("crypto: ctr - no longer needs CRYPTO_SEQIV")
Cc Corentin Labbe <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Steffen Klassert <[email protected]>

---

v2: added the 'if' condition and updated commit message

 net/ipv4/Kconfig | 1 +
 net/ipv6/Kconfig | 1 +
 2 files changed, 2 insertions(+)
net/ipv4/Kconfig +1 -0
index 23ba5045e3d3..6520b30883cf 100644
@@ -361,6 +361,7 @@ config INET_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV if CRYPTO_CTR || CRYPTO_CHACHA20POLY1305
 	---help---
 	  Support for IPsec ESP.
 
net/ipv6/Kconfig +1 -0
index 4f03aece2980..c78adb0f5339 100644
@@ -70,6 +70,7 @@ config INET6_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV if CRYPTO_CTR || CRYPTO_CHACHA20POLY1305
 	---help---
 	  Support for IPsec ESP.
 
Signature · 1 line
2.27.0.278.ge193c7cf3a9-goog
#6 lore raw

Re: [PATCH net v2] esp: select CRYPTO_SEQIV when useful

Quoted 35 lines · Eric Biggers

From: Eric Biggers <[email protected]>

CRYPTO_CTR no longer selects CRYPTO_SEQIV, which breaks IPsec for users who need any of the algorithms that use seqiv. These users now would need to explicitly enable CRYPTO_SEQIV.

There doesn't seem to be a clear rule on what algorithms the IPsec options (INET_ESP and INET6_ESP) actually select, as apparently none is *always* required. They currently select just a particular subset, along with CRYPTO_ECHAINIV which is the other IV generator template.

As a compromise between too many and too few selections, select CRYPTO_SEQIV if either CRYPTO_CTR or CRYPTO_CHACHA20POLY1305 is enabled. These are the algorithms that can use seqiv for IPsec. (Note: GCM and CCM can too, but those both use CTR.)

Fixes f23efcbcc523 ("crypto: ctr - no longer needs CRYPTO_SEQIV")
Cc Corentin Labbe <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Steffen Klassert <[email protected]>

---

v2: added the 'if' condition and updated commit message

 net/ipv4/Kconfig | 1 +
 net/ipv6/Kconfig | 1 +
 2 files changed, 2 insertions(+)
net/ipv4/Kconfig +0 -0
index 23ba5045e3d3..6520b30883cf 100644

net/ipv4/Kconfig config INET_ESP · line 367

Quoted 7 lines
net/ipv4/Kconfig +1 -0
@@ -361,6 +361,7 @@ config INET_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV if CRYPTO_CTR || CRYPTO_CHACHA20POLY1305
 	---help---
 	  Support for IPsec ESP.
 

Oops, this doesn't actually work:

scripts/kconfig/conf --olddefconfig Kconfig crypto/Kconfig:1799:error: recursive dependency detected!
crypto/Kconfig:1799: symbol CRYPTO_DRBG_MENU is selected by CRYPTO_RNG_DEFAULT
crypto/Kconfig:83: symbol CRYPTO_RNG_DEFAULT is selected by CRYPTO_SEQIV
crypto/Kconfig:330: symbol CRYPTO_SEQIV is selected by CRYPTO_CTR
crypto/Kconfig:370: symbol CRYPTO_CTR is selected by CRYPTO_DRBG_CTR
crypto/Kconfig:1819: symbol CRYPTO_DRBG_CTR depends on CRYPTO_DRBG_MENU
For a resolution refer to Documentation/kbuild/kconfig-language.rst subsection "Kconfig recursive dependency limitations"

I guess we need to go with v1 (which just had 'select CRYPTO_SEQIV'), or else make users explicitly select CRYPTO_SEQIV?

- Eric

#7 lore raw

Re: [PATCH net v2] esp: select CRYPTO_SEQIV when useful

Quoted 29 lines · Eric Biggers
Quoted 7 lines · Eric Biggers

From: Eric Biggers <[email protected]>

net/ipv4/Kconfig +0 -0
index 23ba5045e3d3..6520b30883cf 100644

net/ipv4/Kconfig config INET_ESP · line 367

Quoted 7 lines
net/ipv4/Kconfig +1 -0
@@ -361,6 +361,7 @@ config INET_ESP
 	select CRYPTO_SHA1
 	select CRYPTO_DES
 	select CRYPTO_ECHAINIV
+	select CRYPTO_SEQIV if CRYPTO_CTR || CRYPTO_CHACHA20POLY1305
 	---help---
 	  Support for IPsec ESP.
 

Oops, this doesn't actually work:

scripts/kconfig/conf --olddefconfig Kconfig crypto/Kconfig:1799:error: recursive dependency detected!
crypto/Kconfig:1799: symbol CRYPTO_DRBG_MENU is selected by CRYPTO_RNG_DEFAULT
crypto/Kconfig:83: symbol CRYPTO_RNG_DEFAULT is selected by CRYPTO_SEQIV
crypto/Kconfig:330: symbol CRYPTO_SEQIV is selected by CRYPTO_CTR
crypto/Kconfig:370: symbol CRYPTO_CTR is selected by CRYPTO_DRBG_CTR
crypto/Kconfig:1819: symbol CRYPTO_DRBG_CTR depends on CRYPTO_DRBG_MENU
For a resolution refer to Documentation/kbuild/kconfig-language.rst subsection "Kconfig recursive dependency limitations"

Quoted 2 lines

I guess we need to go with v1 (which just had 'select CRYPTO_SEQIV'), or else make users explicitly select CRYPTO_SEQIV?

I think we should make INET_ESP to select everything that is needed to instantiate the ciphers marked as 'MUST' in RFC 8221 and let the users explicitly select everything else.

maintainer
#8 lore raw

Re: [PATCH net v2] esp: select CRYPTO_SEQIV when useful

In reply to Eric Biggers
Quoted 13 lines · Eric Biggers

Oops, this doesn't actually work:

scripts/kconfig/conf --olddefconfig Kconfig crypto/Kconfig:1799:error: recursive dependency detected!
crypto/Kconfig:1799: symbol CRYPTO_DRBG_MENU is selected by CRYPTO_RNG_DEFAULT
crypto/Kconfig:83: symbol CRYPTO_RNG_DEFAULT is selected by CRYPTO_SEQIV
crypto/Kconfig:330: symbol CRYPTO_SEQIV is selected by CRYPTO_CTR
crypto/Kconfig:370: symbol CRYPTO_CTR is selected by CRYPTO_DRBG_CTR
crypto/Kconfig:1819: symbol CRYPTO_DRBG_CTR depends on CRYPTO_DRBG_MENU
For a resolution refer to Documentation/kbuild/kconfig-language.rst subsection "Kconfig recursive dependency limitations"

Quoted 2 lines

I guess we need to go with v1 (which just had 'select CRYPTO_SEQIV'), or else make users explicitly select CRYPTO_SEQIV?

OK, let's just go with the unconditional select on SEQIV since Steffen recommended RFC8221 which lists GCM and CBC as MUST and GCM requires SEQIV to work.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Tested-by on v1 1/1
#9 lore raw
In reply to Eric Biggers
Quoted 11 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Since CRYPTO_CTR no longer selects CRYPTO_SEQIV, it should be selected by INET_ESP and INET6_ESP -- similar to CRYPTO_ECHAINIV.

Fixes f23efcbcc523 ("crypto: ctr - no longer needs CRYPTO_SEQIV")
Cc Corentin Labbe <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Steffen Klassert <[email protected]>