Skip to contentSkip to conversation

crypto: DRBG - switch to HMAC SHA512 DRBG as default DRBG

PATCH In review Stephan Müller 4 participants 8 messages May 20, 2021 – Jun 28, 2021 1 message not in the archive

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

PATCH 1/1 crypto: DRBG - switch to HMAC SHA512 DRBG as default DRBG

The default DRBG is the one that has the highest priority. The priority is defined based on the order of the list drbg_cores[] where the highest priority is given to the last entry by drbg_fill_array.

With this patch the default DRBG is switched from HMAC SHA256 to HMAC SHA512 to support compliance with SP800-90B and SP800-90C (current draft).

The user of the crypto API is completely unaffected by the change.

---
 crypto/drbg.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
crypto/drbg.c +6 -6
index 1b4587e0ddad..ea85d4a0fe9e 100644
@@ -176,18 +176,18 @@ static const struct drbg_core drbg_cores[] = {
 		.blocklen_bytes = 48,
 		.cra_name = "hmac_sha384",
 		.backend_cra_name = "hmac(sha384)",
-	}, {
-		.flags = DRBG_HMAC | DRBG_STRENGTH256,
-		.statelen = 64, /* block length of cipher */
-		.blocklen_bytes = 64,
-		.cra_name = "hmac_sha512",
-		.backend_cra_name = "hmac(sha512)",
 	}, {
 		.flags = DRBG_HMAC | DRBG_STRENGTH256,
 		.statelen = 32, /* block length of cipher */
 		.blocklen_bytes = 32,
 		.cra_name = "hmac_sha256",
 		.backend_cra_name = "hmac(sha256)",
+	}, {
+		.flags = DRBG_HMAC | DRBG_STRENGTH256,
+		.statelen = 64, /* block length of cipher */
+		.blocklen_bytes = 64,
+		.cra_name = "hmac_sha512",
+		.backend_cra_name = "hmac(sha512)",
 	},
 #endif /* CONFIG_CRYPTO_DRBG_HMAC */
 };
Signature · 1 line
2.31.1
Acked-by on v1 1/1
#1 lore raw
Quoted 41 lines · Stephan Müller

The default DRBG is the one that has the highest priority. The priority is defined based on the order of the list drbg_cores[] where the highest priority is given to the last entry by drbg_fill_array.

With this patch the default DRBG is switched from HMAC SHA256 to HMAC SHA512 to support compliance with SP800-90B and SP800-90C (current draft).

The user of the crypto API is completely unaffected by the change.

---
 crypto/drbg.c | 12 ++++++------

 1 file changed, 6 insertions(+), 6 deletions(-)
crypto/drbg.c +0 -6
index 1b4587e0ddad..ea85d4a0fe9e 100644
@@ -176,18 +176,18 @@ static const struct drbg_core drbg_cores[] = {
  		.blocklen_bytes = 48,
  		.cra_name = "hmac_sha384",
  		.backend_cra_name = "hmac(sha384)",
-	}, {
-		.flags = DRBG_HMAC | DRBG_STRENGTH256,
-		.statelen = 64, /* block length of cipher */
-		.blocklen_bytes = 64,
-		.cra_name = "hmac_sha512",
-		.backend_cra_name = "hmac(sha512)",
  	}, {
  		.flags = DRBG_HMAC | DRBG_STRENGTH256,

  .statelen = 32, /* block length of cipher */ .blocklen_bytes = 32,
  .cra_name = "hmac_sha256", .backend_cra_name = "hmac(sha256)",

crypto/drbg.c +6 -0
+	}, {
+		.flags = DRBG_HMAC | DRBG_STRENGTH256,
+		.statelen = 64, /* block length of cipher */
+		.blocklen_bytes = 64,
+		.cra_name = "hmac_sha512",
+		.backend_cra_name = "hmac(sha512)",
Quoted 3 lines

  },
 #endif /* CONFIG_CRYPTO_DRBG_HMAC */
 };

We'd like this to ease certification pains.

Signature · 3 lines
Simo Sorce
RHEL Crypto Team
Red Hat, Inc
maintainer
#2 lore raw
In reply to Stephan Müller
Quoted 8 lines · Stephan Müller

The default DRBG is the one that has the highest priority. The priority is defined based on the order of the list drbg_cores[] where the highest priority is given to the last entry by drbg_fill_array.

With this patch the default DRBG is switched from HMAC SHA256 to HMAC SHA512 to support compliance with SP800-90B and SP800-90C (current draft).

Quoted 6 lines

The user of the crypto API is completely unaffected by the change.

---
 crypto/drbg.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch applied. 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
#3 lore raw
In reply to Stephan Müller
Quoted 18 lines · Stephan Müller
crypto/drbg.c +0 -6
index 1b4587e0ddad..ea85d4a0fe9e 100644
@@ -176,18 +176,18 @@ static const struct drbg_core drbg_cores[] = {
 		.blocklen_bytes = 48,
 		.cra_name = "hmac_sha384",
 		.backend_cra_name = "hmac(sha384)",
-	}, {
-		.flags = DRBG_HMAC | DRBG_STRENGTH256,
-		.statelen = 64, /* block length of cipher */
-		.blocklen_bytes = 64,
-		.cra_name = "hmac_sha512",
-		.backend_cra_name = "hmac(sha512)",
 	}, {
 		.flags = DRBG_HMAC | DRBG_STRENGTH256,
 		.statelen = 32, /* block length of cipher */

crypto/drbg.c static const struct drbg_core drbg_cores[] = { · line 191

Quoted 10 lines
crypto/drbg.c +6 -0
 		.blocklen_bytes = 32,
 		.cra_name = "hmac_sha256",
 		.backend_cra_name = "hmac(sha256)",
+	}, {
+		.flags = DRBG_HMAC | DRBG_STRENGTH256,
+		.statelen = 64, /* block length of cipher */
+		.blocklen_bytes = 64,
+		.cra_name = "hmac_sha512",
+		.backend_cra_name = "hmac(sha512)",
 	},

Hi Stephan:

I just noticed that unlike hmac(sha256) drbg with hmac(sha512) doesn't have a self-test. Could you add one for it please?

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
#4 lore raw

Am Donnerstag, dem 24.06.2021 um 22:30 +0800 schrieb Herbert Xu:

Quoted 32 lines · Stephan Müller
Quoted 20 lines
crypto/drbg.c +0 -6
index 1b4587e0ddad..ea85d4a0fe9e 100644
@@ -176,18 +176,18 @@ static const struct drbg_core drbg_cores[] = {
                 .blocklen_bytes = 48,
                 .cra_name = "hmac_sha384",
                 .backend_cra_name = "hmac(sha384)",
-       }, {
-               .flags = DRBG_HMAC | DRBG_STRENGTH256,
-               .statelen = 64, /* block length of cipher */
-               .blocklen_bytes = 64,
-               .cra_name = "hmac_sha512",
-               .backend_cra_name = "hmac(sha512)",
         }, {
                 .flags = DRBG_HMAC | DRBG_STRENGTH256,

                .statelen = 32, /* block length of cipher */ .blocklen_bytes = 32,
                .cra_name = "hmac_sha256",

Quoted 8 lines

                .backend_cra_name = "hmac(sha256)", +       }, {
+               .flags = DRBG_HMAC | DRBG_STRENGTH256, +               .statelen = 64, /* block length of cipher */ +               .blocklen_bytes = 64,
+               .cra_name = "hmac_sha512",
+               .backend_cra_name = "hmac(sha512)", },

Hi Stephan:

Quoted 2 lines

I just noticed that unlike hmac(sha256) drbg with hmac(sha512) doesn't have a self-test.  Could you add one for it please?

Thank you very much for pointing this out. I will prepare one asap.

Thanks
Stephan

Quoted 2 lines

Thanks,

#5 lore raw

PATCH 1/1 crypto: DRBG - self test for HMAC(SHA-512)

In reply to Herbert Xu

Considering that the HMAC(SHA-512) DRBG is the default DRBG now, a self test is to be provided.

The test vector is obtained from a successful NIST ACVP test run.

---
 crypto/testmgr.c |  5 ++++-
 crypto/testmgr.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
crypto/testmgr.c +4 -1
index 1f7f63e836ae..c978e41f11a1 100644
@@ -4686,8 +4686,11 @@ static const struct alg_test_desc alg_test_descs[] = {
 		.test = alg_test_null,
 	}, {
 		.alg = "drbg_nopr_hmac_sha512",
-		.test = alg_test_null,
+		.test = alg_test_drbg,
 		.fips_allowed = 1,
+		.suite = {
+			.drbg = __VECS(drbg_nopr_hmac_sha512_tv_template)
+		}
 	}, {
 		.alg = "drbg_nopr_sha1",
 		.fips_allowed = 1,
crypto/testmgr.h +49 -0

55 lines not on this page · raw message

Signature · 1 line
2.31.1

A message that is not in the archive (sent off-list or not yet received): CAMusb+TVdPRtDCY88kREZgWNH8XtrJS4yLkK3UJFqhXgn36raw@mail.gmail.com

#7 lore raw

Re: [PATCH] crypto: DRBG - self test for HMAC(SHA-512)

Hello, Stephan, Herbert,

Thank you for posting this patch. I would like to confirm that it fixes the issue
in the RHEL8, i.e. RHEL8 kernel boots up in the FIPS mode with your patch.

Herbert, could you please consider adding this patch to your cryptodev-2.6.git?

Best regards,
Vladis Dronov | Red Hat, Inc. | The Core Kernel | Senior Software Engineer

Quoted 13 lines · Stephan Müller

Considering that the HMAC(SHA-512) DRBG is the default DRBG now, a self test is to be provided.

The test vector is obtained from a successful NIST ACVP test run.

---
 crypto/testmgr.c |  5 ++++-
 crypto/testmgr.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

...

maintainer
#8 lore raw

Re: [PATCH] crypto: DRBG - self test for HMAC(SHA-512)

In reply to Stephan Müller
Quoted 10 lines · Stephan Müller

Considering that the HMAC(SHA-512) DRBG is the default DRBG now, a self test is to be provided.

The test vector is obtained from a successful NIST ACVP test run.

---
 crypto/testmgr.c |  5 ++++-
 crypto/testmgr.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

Patch applied. 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