libceph: Re-establish the FIPS keylength check in the Ceph code
PATCH 1/1 libceph: Re-establish the FIPS keylength check in the Ceph code
When the Ceph code had been updated to use the libcrypto hmac_sha256 functions instead of the "hmac(sha256)" crypto shash driver, we lost the FIPS key length check from hmac_setkey() in crypto/hmac.c. Since libcrypto won't support this FIPS check (it should be done in the calling sites instead), add the check now to the Ceph code instead to make this code more FIPS friendly again.
--- net/ceph/messenger_v2.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ceph/messenger_v2.c +4 -0
@@ -12,6 +12,7 @@#include <crypto/utils.h> #include <linux/bvec.h> #include <linux/crc32c.h> +#include <linux/fips.h> #include <linux/net.h> #include <linux/scatterlist.h> #include <linux/socket.h>
@@ -721,6 +722,9 @@ static int setup_crypto(struct ceph_connection *con,return 0 ;/* auth_none */ } +if (fips_enabled && session_key_len <112 /8 ) +return -EKEYREJECTED ; +hmac_sha256_preparekey (&con->v2.hmac_key, session_key, session_key_len); con->v2.hmac_key_set = true;
Signature · 1 line
2.55.0
Quoted 3 lines · Thomas Huth
When the Ceph code had been updated to use the libcrypto
hmac_sha256functions instead of the "hmac(sha256)" crypto shash driver, we lost the FIPS key length check fromhmac_setkey()incrypto/hmac.c.
Well, except on s390 which already didn't do the FIPS key length check.
net/ceph/messenger_v2.c static int setup_crypto(struct ceph_connection *con, · line 727
Quoted 7 lines
net/ceph/messenger_v2.c +3
-0@@ -720,6 +722,9 @@ static int setup_crypto(struct ceph_connection *con,return 0 ;/* auth_none */ } +if (fips_enabled && session_key_len <112 /8 ) +return -EKEYREJECTED ; +
I assume it's intentional that auth_none is still FIPS-allowed? Kind of ironic.
Do Ceph session keys shorter than 128 bits even actually occur in practice? It seems that the Ceph authenticated modes support only AES-based cipher suites, where the minimum valid session key length is 128 bits.
I wonder if the client should just reject session_key_len < 16 regardless of fips_enabled.
- Eric
Quoted 7 lines · Eric Biggers
Do Ceph session keys shorter than 128 bits even actually occur in practice? It seems that the Ceph authenticated modes support only AES-based cipher suites, where the minimum valid session key length is 128 bits.
I wonder if the client should just reject
session_key_len< 16 regardless offips_enabled.
It looks like this is theoretically possible only when CEPH_AUTH_CEPHX is being used but the session key uses CEPH_CRYPTO_NONE, which seems insecure and contradictory, and likely not ever used by the server. I suspect the ceph client should just reject that combination outright (and also session_key_len < 16 as defense-in-depth). It is up to the ceph folks who are the experts here, but if there are unnecessary footguns like this, they should just be fixed for everyone.
- Eric