crypto: Make the DRBG compliant with NIST SP800-90A rev1
PATCH 1/1 crypto: Make the DRBG compliant with NIST SP800-90A rev1
From: Mickaël Salaün <[email protected]>
Starting from November 2020, the first revision of NIST SP800-90A (June 2015) is required for FIPS 140-2. One of the changes brought by this first revision is that nonces used for seeding (instantiation) and re-seeding must come from entropy sources compliant with NIST SP800-90B (cf. NIST SP800-90A rev1, section 8.6.7). However, this seeding is currently done with the Linux RNG (i.e. in-kernel /dev/urandom) that uses ChaCha20, a non-approved algorithm.
Cf. https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
However, only using the Jitter RNG may not provide adequate security as it could be possible for an attacker to know the state of the CPU and predict this RNG output. To avoid this threat, we are making this both FIPS compliant and secure thanks to the use of Linux RNG as a random source (but not entropy per se) for the personalization string (instantiation) and the additional input (re-seeding). These extra inputs have a length equal to the DRBG strength. The original user-supplied personalization string and additional input are still used but potentially truncated to fit with the 2**35 limit (cf. NIST SP800-90A rev1, table 2 and 3).
This new DRBG uses the same random and entropy sources as the current version but in a way that makes is compliant with FIPS 140-2.
---
Do you prefer to truncate the user-supplied personalization string and the additional input, or to return an error if they are greater than 2**27 (instead of 2**35)?
Another solution to avoid truncating the personalization string and the additional input would be to hash them with SHA-512 and concatenate the resulting fixed-size buffers.
--- crypto/drbg.c | 77 ++++++++++++++++++++++++++++++++----------- include/crypto/drbg.h | 2 +- 2 files changed, 58 insertions(+), 21 deletions(-)
crypto/drbg.c +57 -20
@@ -1119,9 +1119,10 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers, bool reseed) {int ret; -unsigned char entropy[((32 +16 ) *2 )]; -unsigned int entropylen =drbg_sec_strength (drbg->core->flags); -struct drbg_string data1; +unsigned char entropy[((32 *2 ) +16 )]; +const unsigned int strength =drbg_sec_strength (drbg->core->flags); +unsigned int entropylen = strength; +struct drbg_string data1, data2;LIST_HEAD (seedlist);/* 9.1 / 9.2 / 9.3.1 step 3 */
@@ -1147,21 +1148,32 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,BUG_ON (!entropylen);if (!reseed) entropylen = ((entropylen +1 ) /2 ) *3 ; -BUG_ON ((entropylen *2 ) >sizeof (entropy)); - -/* Get seed from in-kernel /dev/urandom */ - ret =drbg_get_random_bytes (drbg, entropy, entropylen); -if (ret) - goto out; +/* +* Check that a minimal automatic personalization string +* (instantiation) or additional input (re-seeding) of strength +* length fits in. +*/ +BUG_ON ((entropylen + strength) >sizeof (entropy));if (!drbg->jent) { -drbg_string_fill (&data1, entropy, entropylen); -pr_devel ("DRBG: (re)seeding with %u bytes of entropy\n" , - entropylen); +/* +* Get entropy, nonce, personalization string or +* additional input from in-kernel /dev/urandom +*/ + ret =drbg_get_random_bytes (drbg, entropy, entropylen + strength); +if (ret) + goto out; + +drbg_string_fill (&data1, entropy, entropylen + strength); +pr_devel ("DRBG: (re)seeding with %u bytes of random\n" , + entropylen + strength); }else { -/* Get seed from Jitter RNG */ - ret =crypto_rng_get_bytes (drbg->jent, - entropy + entropylen, +/* +* Get entropy (strength length), concatenated with a +* nonce (half strength length) when instantiating, +* both from the SP800-90B compliant Jitter RNG. +*/ + ret =crypto_rng_get_bytes (drbg->jent, entropy, entropylen);if (ret) {pr_devel ("DRBG: jent failed with %d\n" , ret);
@@ -1184,9 +1196,25 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers, goto out; } -drbg_string_fill (&data1, entropy, entropylen *2 ); -pr_devel ("DRBG: (re)seeding with %u bytes of entropy\n" , - entropylen *2 ); +/* +* To improve security while still be compliant with +* SP800-90A rev1, automatically append a minimal +* personalization string (instantiation) or additional +* input (re-seeding) of strength length from in-kernel +* /dev/urandom (random source). This may then replace +* a (small) part of the supplied pers according to +* drbg_max_addtl(). +*/ + ret =drbg_get_random_bytes (drbg, entropy + entropylen, + strength); +if (ret) + goto out; + +drbg_string_fill (&data1, entropy, entropylen + strength); + +pr_devel ("DRBG: (re)seeding with %u bytes of entropy " +"and %u bytes of random\n" , entropylen, + strength); } }list_add_tail (&data1.list, &seedlist);
@@ -1197,7 +1225,16 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,* contents whether it is appropriate */ if (pers && pers->buf &&0 < pers->len) { -list_add_tail (&pers->list, &seedlist); +const size_t available =drbg_max_addtl (drbg) - pers->len; + + data2 = *pers; +/* +* Make sure that the drbg_max_addtl() limit is still respected +* according to the automatically appended random values. +*/ +if (available < strength) + data2.len -= strength - available; +list_add_tail (&data2.list, &seedlist);pr_devel ("DRBG: using personalization string\n" ); }
@@ -1209,7 +1246,7 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers, ret =__drbg_seed (drbg, &seedlist, reseed); out: -memzero_explicit (entropy, entropylen *2 ); +memzero_explicit (entropy,sizeof (entropy));return ret; }
include/crypto/drbg.h +1 -1
@@ -168,7 +168,7 @@ static inline size_t drbg_max_request_bytes(struct drbg_state *drbg)static inline size_t drbg_max_addtl (struct drbg_state *drbg) { -/* SP800-90A requires 2**35 bytes additional info str / pers str */ +/* SP800-90A requires 2**35 bits of additional info str / pers str */ #if (__BITS_PER_LONG ==32 )/* * SP800-90A allows smaller maximum numbers to be returned -- we
base-commit: 13311e74253fe64329390df80bed3f07314ddd61
Signature · 1 line
2.32.0
Am Mittwoch, dem 23.06.2021 um 14:07 +0200 schrieb Mickaël Salaün:
Quoted 4 lines
From: Mickaël Salaün <[email protected]>
Starting from November 2020, the first revision of NIST SP800-90A (June 2015) is required for FIPS 140-2.
Starting from November 7, 2020, SP800-90B is mandated. SP800-90A was always required since 2015 which sunset the ANSI X9.31 DRNG.
Quoted 4 lines
One of the changes brought by this
first revision is that nonces used for seeding (instantiation) and re-seeding must come from entropy sources compliant with NIST SP800-90B (cf. NIST SP800-90A rev1, section 8.6.7).
Nonces do not need to be derived from SP800-90B entropy sources. The construction methods 2 through 4 clearly allow a nonce to be derived from a deterministic source.
Quoted 6 lines
However, this seeding is
currently done with the Linux RNG (i.e. in-kernel/dev/urandom) that uses ChaCha20, a non-approved algorithm.
Cf.
https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf
I do not think this statement is correct.
With the patches that went into the DRBG in kernel version 5.8, the DRBG seeding is performed as follows when the kernel is booted in FIPS mode (fips=1):
- get a buffer of 384 bits from get_random_bytes
- get a buffer of 384 bits from the Jitter RNG
Both buffers are concatenated and used to seed the DRBG.
So, in total, the DRBG receives a buffer of 768 bits.
Assume for your FIPS work that /dev/urandom cannot be claimed to have entropy, you can only look at the Jitter RNG. This entropy source alone provides 384 bits which *may* be interpreted as follows:
- 256 bits forming the entropy string as mandated by SP800-90A
- 128 bits forming the nonce as mandated by SP800-90A following 8.6.7 bullet 1 with the deviation that it uses a 90B entropy source instead of an approved random bit generator (a deviation that is allowed according to 8.6.7).
You also may interpret the 384 bits as follows:
- 384 bits as mandated by the current draft from January this year of SP800- 90C mandating that the initial seed is s+128 bits
Quoted 3 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
Can you please help me understand what is missing in the current code which seemingly already has achieved this goal?
Quoted 6 lines
However, only using the Jitter RNG may not provide adequate security as it could be possible for an attacker to know the state of the CPU and predict this RNG output. To avoid this threat, we are making this both FIPS compliant and secure thanks to the use of Linux RNG as a random source (but not entropy per se) for the personalization string
Why do you need a personalization string beyond the 384 bits coming from get_random_bytes as mentioned above?
Quoted 1 line
(instantiation) and the additional input (re-seeding).
Why do you need a personalization string beyond the 384 bits coming from get_random_bytes as mentioned above?
But maybe this is only a terminology issue where the existing 384 bits drawn from get_random_bytes are called personalization string / additional info string.
Quoted 73 lines
These extra
inputs have a length equal to the DRBG strength. The original user-supplied personalization string and additional input are still used but potentially truncated to fit with the 2**35 limit (cf. NIST SP800-90A rev1, table 2 and 3).This new DRBG uses the same random and entropy sources as the current version but in a way that makes is compliant with FIPS 140-2.
Cc David S. Miller <[email protected]>Cc Herbert Xu <[email protected]>Cc James Morris <[email protected]>Cc John Haxby <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc Simo Sorce <[email protected]>Cc Stephan Müller <[email protected]>Signed-off-by Mickaël Salaün <[email protected]>---
Do you prefer to truncate the user-supplied personalization string and the additional input, or to return an error if they are greater than 2**27 (instead of 2**35)?
Another solution to avoid truncating the personalization string and the additional input would be to hash them with SHA-512 and concatenate the resulting fixed-size buffers.
---
crypto/drbg.c | 77 ++++++++++++++++++++++++++++++++-----------include/crypto/drbg.h| 2 +-2 files changed, 58 insertions(+), 21 deletions(-)crypto/drbg.c +4
-3@@ -1119,9 +1119,10 @@ static int drbg_seed(struct drbg_state *drbg, structdrbg_string *pers, bool reseed) { int ret; - unsigned char entropy[((32 + 16) * 2)]; - unsigned int entropylen = drbg_sec_strength(drbg->core->flags); - struct drbg_string data1; + unsigned char entropy[((32 * 2) + 16)]; + const unsigned int strength = drbg_sec_strength(drbg->core->flags); + unsigned int entropylen = strength; + struct drbg_string data1, data2; LIST_HEAD(seedlist);
/* 9.1 / 9.2 / 9.3.1 step 3 */crypto/drbg.c +3
-6@@ -1147,21 +1148,32 @@ static int drbg_seed(struct drbg_state *drbg, structdrbg_string *pers, BUG_ON(!entropylen); if (!reseed) entropylen = ((entropylen + 1) / 2) * 3; - BUG_ON((entropylen * 2) > sizeof(entropy)); - - /* Get seed from in-kernel /dev/urandom */ - ret = drbg_get_random_bytes(drbg, entropy, entropylen); - if (ret) - goto out; + /* +* Check that a minimal automatic personalization string +* (instantiation) or additional input (re-seeding) of strength
+ * length fits in.
+ */
+ BUG_ON((entropylen + strength) > sizeof(entropy));
if (!drbg->jent) {
Quoted 8 lines
- drbg_string_fill(&data1, entropy, entropylen); - pr_devel("DRBG: (re)seeding with %u bytes of entropy\n",
- entropylen);
+ /*
+ * Get entropy, nonce, personalization string or + * additional input from in-kernel/dev/urandom+ */
If we are in this branch, we will never be using an SP800-90B entropy source and thus I am not sure changes are warranted.
Quoted 17 lines
+ ret =
drbg_get_random_bytes(drbg, entropy, entropylen + strength);+ if (ret)
+ goto out;
+
+ drbg_string_fill(&data1, entropy, entropylen + strength);
+ pr_devel("DRBG: (re)seeding with %u bytes of random\n",
+ entropylen + strength);
} else {
- /* Get seed from Jitter RNG */
- ret = crypto_rng_get_bytes(drbg->jent, - entropy + entropylen,
Quoted 8 lines
+ /*
+ * Get entropy (strength length), concatenated with a
+ * nonce (half strength length) when instantiating, + * both from the SP800-90B compliant Jitter RNG. + */
+ ret =crypto_rng_get_bytes(drbg->jent, entropy, entropylen);
So, here you would get 384 bits from the Jitter RNG.
Quoted 19 lines
if (ret) {
pr_devel("DRBG: jent failed with %d\n", ret);crypto/drbg.c +0
-0@@ -1184,9 +1196,25 @@ static int drbg_seed(struct drbg_state *drbg, structdrbg_string *pers, goto out; }
- drbg_string_fill(&data1, entropy, entropylen * 2); - pr_devel("DRBG: (re)seeding with %u bytes of entropy\n",
- entropylen * 2);
+ /*
+ * To improve security while still be compliant with + * SP800-90A rev1, automatically append a minimal + * personalization string (instantiation) or additional
+ * input (re-seeding) of strength length from in- kernel
Quoted 8 lines
+ *
/dev/urandom(random source). This may then replace
+ * a (small) part of the supplied pers according to + *drbg_max_addtl().
+ */
+ ret = drbg_get_random_bytes(drbg, entropy + entropylen,
+ strength);
Here you would get 256 bits from get_random_bytes.
So, compared to the original code, you now just draw 256 bits of data instead of 384 bits of data.
With these code changes, I fail to see what benefits these changes bring compared to the existing code.
Quoted 14 lines
+ if (ret)
+ goto out;
+
+ drbg_string_fill(&data1, entropy, entropylen + strength);
+
+ pr_devel("DRBG: (re)seeding with %u bytes of entropy "
+ "and %u bytes of random\n", entropylen, + strength);
}
}
list_add_tail(&data1.list, &seedlist);
crypto/drbg.c static int drbg_seed(struct drbg_state *drbg, struct · line 1229
Quoted 6 lines
crypto/drbg.c +1
-1@@ -1197,7 +1225,16 @@ static int drbg_seed(struct drbg_state *drbg, structdrbg_string *pers, * contents whether it is appropriate */ if (pers && pers->buf && 0 < pers->len) { - list_add_tail(&pers->list, &seedlist); + const size_t available = drbg_max_addtl(drbg) - pers->len;
I am uneasy about subtractions without sanity checks and I am not sure what is the purpose of this work here. Truncating the personalization string here is wrong IMHO. If there is a need that the personalization string should be checked for size, the code receiving the personalization string to begin with should make the check, i.e. drbg_kcapi_seed and drbg_kcapi_random. But a truncation here is not right as this changes the data provided by the caller.
Thanks
Stephan
Quoted 40 lines
crypto/drbg.c +4
-0+ + data2 = *pers; + /* +* Make sure that the drbg_max_addtl() limit is still respected
+ * according to the automatically appended random values. + */
+ if (available < strength)
+ data2.len -= strength - available;
+ list_add_tail(&data2.list, &seedlist);pr_devel("DRBG: using personalization string\n"); }crypto/drbg.c +0
-0@@ -1209,7 +1246,7 @@ static int drbg_seed(struct drbg_state *drbg, structdrbg_string *pers, ret = __drbg_seed(drbg, &seedlist, reseed);
out:
- memzero_explicit(entropy, entropylen * 2); + memzero_explicit(entropy, sizeof(entropy));
return ret;
}include/crypto/drbg.h +0
-0@@ -168,7 +168,7 @@ static inline size_t drbg_max_request_bytes(struct drbg_state *drbg)
static inlinesize_tdrbg_max_addtl(struct drbg_state *drbg)
{
- /* SP800-90A requires 2**35 bytes additional info str / pers str */ + /* SP800-90A requires 2**35 bits of additional info str / pers str */
#if (__BITS_PER_LONG== 32)
/*
* SP800-90A allows smaller maximum numbers to be returned -- webase-commit:
13311e74253fe64329390df80bed3f07314ddd61
Quoted 7 lines · Stephan Mueller
Quoted 4 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
Can you please help me understand what is missing in the current code which seemingly already has achieved this goal?
The advice we have is that if an attacker knows the internal state of the CPU, then the output of the Jitter RNG can be predicted.
Signature · 2 lines
James Morris <[email protected]>
Am Mittwoch, 23. Juni 2021, 19:00:29 CEST schrieb James Morris:
Hi James,
Quoted 11 lines · Stephan Mueller
Quoted 7 lines
Quoted 3 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
Can you please help me understand what is missing in the current code which
seemingly already has achieved this goal?The advice we have is that if an attacker knows the internal state of the CPU, then the output of the Jitter RNG can be predicted.
Thank you for the hint. And I think such goal is worthwhile (albeit I have to admit that if an attacker is able to gain the internal state of a CPU, I would assume we have more pressing problems that a bit of entropy).
Anyways, the current code does:
- in regular mode: seed the DRBG with 384 bits of data from get_random_bytes
- in FIPS mode: seed the DRBG with 384 bits of data from get_random_bytes concatenated with 384 bits from the Jitter RNG
If I understand the suggested changes right, I would see the following changes in the patch:
- in the regular case: 640 bits from get_random_bytes
- in FIPS mode: 256 bits of data from get_random_bytes concatenated with 384 bits from the Jitter RNG
So, I am not fully sure what the benefit of the difference is: in FIPS mode (where the Jitter RNG is used), the amount of data pulled from get_random_bytes seems to be now reduced.
Maybe I miss a point here, but I currently fail to understand why the changes should be an improvement compared to the current case.
Ciao
Stephan
Quoted 24 lines · Stephan Müller
Am Mittwoch, 23. Juni 2021, 19:00:29 CEST schrieb James Morris:
Hi James,
Quoted 11 lines · Stephan Mueller
Quoted 7 lines
Quoted 3 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
Can you please help me understand what is missing in the current code which
seemingly already has achieved this goal?The advice we have is that if an attacker knows the internal state of the CPU, then the output of the Jitter RNG can be predicted.
Thank you for the hint. And I think such goal is worthwhile (albeit I have to admit that if an attacker is able to gain the internal state of a CPU, I would assume we have more pressing problems that a bit of entropy).
Anyways, the current code does:
- in regular mode: seed the DRBG with 384 bits of data from
get_random_bytes
Quoted 8 lines
- in FIPS mode: seed the DRBG with 384 bits of data from
get_random_bytesconcatenated with 384 bits from the Jitter RNGIf I understand the suggested changes right, I would see the following changes in the patch:
- in the regular case: 640 bits from
get_random_bytes
Why 640 bits?
Quoted 3 lines
- in FIPS mode: 256 bits of data from
get_random_bytesconcatenated with 384 bits from the Jitter RNG
In both cases there are 256 bits for the entropy input and 128 bits for the nonce. If Jitter RNG is not available, then urandom is used instead, which means that the system is not FIPS compliant.
This follows the SP800-90Ar1, section 8.6.7: [a nonce shall be] "A value with at least (security_strength/2) bits of entropy".
Quoted 4 lines
So, I am not fully sure what the benefit of the difference is: in FIPS mode (where the Jitter RNG is used), the amount of data pulled from
get_random_bytesseems to be now reduced.
We can increase the amount of data pulled from get_random_bytes (how to decide the amount?), but as we understand the document, this should be part of the personalization string and additional input, not the nonce. I guess it may not change much according to the implementation, as for the order of random and entropy concatenation, but these changes align with the specifications and it should help FIPS certifications.
Quoted 8 lines
Maybe I miss a point here, but I currently fail to understand why the changes should be an improvement compared to the current case.
Ciao
Stephan
Am Mittwoch, dem 23.06.2021 um 20:04 +0200 schrieb Mickaël Salaün:
Quoted 32 lines · Stephan Müller
Quoted 30 lines
Am Mittwoch, 23. Juni 2021, 19:00:29 CEST schrieb James Morris:
Hi James,
Quoted 11 lines · Stephan Mueller
Quoted 7 lines
Quoted 3 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
Can you please help me understand what is missing in the current code which
seemingly already has achieved this goal?The advice we have is that if an attacker knows the internal state of the CPU, then the output of the Jitter RNG can be predicted.
Thank you for the hint. And I think such goal is worthwhile (albeit I have to
admit that if an attacker is able to gain the internal state of a CPU, I would
assume we have more pressing problems that a bit of entropy).Anyways, the current code does:
- in regular mode: seed the DRBG with 384 bits of data from
get_random_bytes- in FIPS mode: seed the DRBG with 384 bits of data from
get_random_bytesconcatenated with 384 bits from the Jitter RNG
Quoted 7 lines
Quoted 5 lines
If I understand the suggested changes right, I would see the following changes
in the patch:- in the regular case: 640 bits from
get_random_bytesWhy 640 bits?
if (!reseed)
entropylen = ((entropylen + 1) / 2) * 3;
-> Entropylen is 384 in case of a security strength of 256 bits.
Your code does the following if the Jitter RNG is not allocated (i.e. in non- fips mode):
ret = drbg_get_random_bytes(drbg, entropy, entropylen + strength);
so: entropylen + strength = 384 + 256, no?
Quoted 7 lines
Quoted 4 lines
- in FIPS mode: 256 bits of data from
get_random_bytesconcatenated with 384 bits from the Jitter RNGIn both cases there are 256 bits for the entropy input and 128 bits for the nonce.
I see in the code path with the Jitter RNG:
ret = crypto_rng_get_bytes(drbg->jent, entropy,
entropylen);
--> 384 bits from the Jitter RNG
ret = drbg_get_random_bytes(drbg, entropy + entropylen,
+ strength);
--> 256 bits from get_random_bytes
What am I missing here?
Quoted 2 lines
If Jitter RNG is not available, then urandom is used instead,
which means that the system is not FIPS compliant.
Agreed, the existing does does exactly the same with the exception that it pulls 384 bits from get_random_bytes instead of 640 in non-FIPS mode (i.e. when the Jitter RNG is not allocated).
In FIPS mode, the current code draws 384 bits from get_random_bytes and separately 384 bits from the Jitter RNG. So, each data block from either entropy source could completely satisfy the SP800-90A requirement.
Quoted 3 lines
This follows the SP800-90Ar1, section 8.6.7: [a nonce shall be] "A value with at least (security_strength/2) bits of entropy".
Agreed, but what is your code doing different than the existing code?
Quoted 9 lines
Quoted 5 lines
So, I am not fully sure what the benefit of the difference is: in FIPS mode (where the Jitter RNG is used), the amount of data pulled from
get_random_bytesseems to be now reduced.We can increase the amount of data pulled from
get_random_bytes(how to decide the amount?), but as we understand the document, this should be part of the personalization string and additional input, not the nonce.
There is no need to have a personalization string or additional input. Note, those two values are intended to be provided by a caller or some other environment.
If you want to stuff more seed into the DRBG, you simply enlarge the seed buffer and pull more from the entropy sources. I have no objections doing that. All I am trying to point out is that the 90A standard does not require more entropy than 256 bits during initialization plus 128 bits of nonce == 384 bits of data. But the DRBGs all allow providing more data as seed.
Quoted 3 lines
I guess it may not change much according to the implementation, as for the order of random and entropy concatenation, but these changes align with the specifications and it should help FIPS certifications.
Are you saying the order of data from the entropy sources matters in the entropy buffer? I have not seen that in the standard, but if you say this is the goal, then allow me to understand which order you want to see?
The current code contains the order of:
<384 bits get_random_bytes> || <384 bits Jitter RNG>
Thanks
Stephan
Quoted 10 lines
Quoted 10 lines
Maybe I miss a point here, but I currently fail to understand why the changes
should be an improvement compared to the current case.Ciao
Stephan
Quoted 46 lines · Stephan Mueller
Am Mittwoch, dem 23.06.2021 um 20:04 +0200 schrieb Mickaël Salaün:
Quoted 39 lines · Stephan Müller
Quoted 30 lines
Am Mittwoch, 23. Juni 2021, 19:00:29 CEST schrieb James Morris:
Hi James,
Quoted 11 lines · Stephan Mueller
Quoted 7 lines
Quoted 3 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input and a nonce as defined by FIPS.
Can you please help me understand what is missing in the current code which
seemingly already has achieved this goal?The advice we have is that if an attacker knows the internal state of the CPU, then the output of the Jitter RNG can be predicted.
Thank you for the hint. And I think such goal is worthwhile (albeit I have to
admit that if an attacker is able to gain the internal state of a CPU, I would
assume we have more pressing problems that a bit of entropy).Anyways, the current code does:
- in regular mode: seed the DRBG with 384 bits of data from
get_random_bytes- in FIPS mode: seed the DRBG with 384 bits of data from
get_random_bytesconcatenated with 384 bits from the Jitter RNGQuoted 5 lines
If I understand the suggested changes right, I would see the following changes
in the patch:- in the regular case: 640 bits from
get_random_bytesWhy 640 bits?
crypto/drbg.c +0
-1if (!reseed) entropylen = ((entropylen +1 ) /2 ) *3 ; -> Entropylen is 384 in case of a security strength of 256 bits.
Quoted 6 lines
Your code does the following if the Jitter RNG is not allocated (i.e. in non- fips mode):
ret =
drbg_get_random_bytes(drbg, entropy, entropylen + strength);so: entropylen + strength = 384 + 256, no?
Correct (for entropy + nonce + pers), I thought you were referring to just the entropy + nonce part. This change is not needed for FIPS of course but I changed it too to use the same algorithm and lengths as when Jitter RNG is available.
Do you prefer to keep the current lengths (384 bits) when there is no Jitter RNG? It seems to me that this change makes sense and could only strengthen this case though.
Quoted 21 lines
Quoted 8 lines
Quoted 5 lines
- in FIPS mode: 256 bits of data from
get_random_bytesconcatenated with 384 bits from the Jitter RNGIn both cases there are 256 bits for the entropy input and 128 bits for the nonce.
I see in the code path with the Jitter RNG:
ret = crypto_rng_get_bytes(drbg->jent, entropy,
entropylen);--> 384 bits from the Jitter RNG
ret = drbg_get_random_bytes(drbg, entropy + entropylen,
(quoted diff) +1
-1+ strength); --> 256 bits from get_random_bytes
Quoted 1 line
What am I missing here?
OK, it is just a misunderstanding of what is where. To simplify the code (with a fixed-length entropy array) I used the "entropy" array to store the entropy + nonce + the automatically generated personalization string or additional input. The user-supplied personalization string or additional input is stored (unchanged) in the pers drbg_string. I (briefly) explained this in the comments.
Another difference brought by this change is that the Jitter RNG data (i.e. entropy source) is used at the beginning (of the entropy array) and the urandom data (i.e. random source) at the end. This strictly follows the algorithm described in SP800-90Ar1 sections 8.6.1, 8.6.2, 10.1.1.2 and 10.1.1.3 .
Quoted 5 lines
Quoted 4 lines
If Jitter RNG is not available, then urandom is used instead,
which means that the system is not FIPS compliant.
Quoted 7 lines
Agreed, the existing does does exactly the same with the exception that it pulls 384 bits from
get_random_bytesinstead of 640 in non-FIPS mode (i.e. when the Jitter RNG is not allocated).In FIPS mode, the current code draws 384 bits from
get_random_bytesand separately 384 bits from the Jitter RNG. So, each data block from either entropy source could completely satisfy the SP800-90A requirement.
What is the rational of using 384 (strength * 1.5) bits to draw from get_random_bytes?
We noticed that (as explained above) the order of these sources doesn't follows SP800-90Ar1.
It is not clear which part and source is used for the entropy, nonce and (maybe) personalization string.
If the random source is indeed the personalization string or the additional input, then the pers length may not fit with the maximum lengths specified in SP800-90Ar1 table 2 and 3.
Quoted 6 lines
Quoted 4 lines
This follows the SP800-90Ar1, section 8.6.7: [a nonce shall be] "A value with at least (security_strength/2) bits of entropy".
Agreed, but what is your code doing different than the existing code?
It just fits with strength/2 for the length of the nonce.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
So, I am not fully sure what the benefit of the difference is: in FIPS mode (where the Jitter RNG is used), the amount of data pulled from
get_random_bytesseems to be now reduced.
Quoted 7 lines
Quoted 3 lines
We can increase the amount of data pulled from
get_random_bytes(how to decide the amount?), but as we understand the document, this should be part of the personalization string and additional input, not the nonce.There is no need to have a personalization string or additional input. Note, those two values are intended to be provided by a caller or some other environment.
Right, but the intent here is to strictly follow SP800-90Ar1 (hence the use of Jitter RNG for entropy and nonce) but to still use the urandom source, which seems to only fit in the personalization string according to SP800-90Ar1.
Quoted 6 lines
If you want to stuff more seed into the DRBG, you simply enlarge the seed buffer and pull more from the entropy sources. I have no objections doing that. All I am trying to point out is that the 90A standard does not require more entropy than 256 bits during initialization plus 128 bits of nonce == 384 bits of data. But the DRBGs all allow providing more data as seed.
Agreed, the user-supplied personalization string can be used to add more data. We also want to harden the default use (i.e. without user-provided personalization string) by automatically using non-entropy source (urandom) though.
Quoted 5 lines
Quoted 4 lines
I guess it may not change much according to the implementation, as for the order of random and entropy concatenation, but these changes align with the specifications and it should help FIPS certifications.
Quoted 7 lines
Are you saying the order of data from the entropy sources matters in the entropy buffer? I have not seen that in the standard, but if you say this is the goal, then allow me to understand which order you want to see?
The current code contains the order of:
<384 bits
get_random_bytes> || <384 bits Jitter RNG>
^ ^
personalization string? entropy+nonce
As described in SP800-90Ar1 section 10.1.1.2:seed_material = entropy_input || nonce || personalization_string
As described in SP800-90Ar1 section 10.1.1.3:seed_material = 0x01 || V || entropy_input || additional_input
And SP800-90Ar1 section 5 defining "X || Y" as "Concatenation of two strings X and Y. X and Y are either both bitstrings, or both byte strings".
According to that, we would like at least:
<384 bits Jitter RNG> || <256 bits get_random_bytes>
and also enforcing the maximum length for the whole personalization string and the additional input.
Thanks,
Mickaël
Am Donnerstag, dem 24.06.2021 um 12:13 +0200 schrieb Mickaël Salaün:
Quoted 196 lines · Stephan Mueller
Quoted 53 lines
Am Mittwoch, dem 23.06.2021 um 20:04 +0200 schrieb Mickaël Salaün:
Quoted 39 lines · Stephan Müller
Quoted 37 lines
Am Mittwoch, 23. Juni 2021, 19:00:29 CEST schrieb James Morris:
Hi James,
Quoted 7 lines · Stephan Mueller
Quoted 6 lines
Quoted 5 lines
These changes replace the use of the Linux RNG with the Jitter RNG,
which is NIST SP800-90B compliant, to get a proper entropy input and a
nonce as defined by FIPS.Quoted 8 lines
Quoted 4 lines
Can you please help me understand what is missing in the current code
which
seemingly already has achieved this goal?The advice we have is that if an attacker knows the internal state of the
CPU, then the output of the Jitter RNG can be predicted.Thank you for the hint. And I think such goal is worthwhile (albeit I have
to
admit that if an attacker is able to gain the internal state of a CPU, I would
assume we have more pressing problems that a bit of entropy).Anyways, the current code does:
- in regular mode: seed the DRBG with 384 bits of data from
get_random_bytes- in FIPS mode: seed the DRBG with 384 bits of data from
get_random_bytes
concatenated with 384 bits from the Jitter RNGQuoted 7 lines
Quoted 5 lines
If I understand the suggested changes right, I would see the following changes
in the patch:- in the regular case: 640 bits from
get_random_bytesWhy 640 bits?
if (!reseed)
entropylen = ((entropylen + 1) / 2) * 3;-> Entropylen is 384 in case of a security strength of 256 bits.
Quoted 7 lines
Your code does the following if the Jitter RNG is not allocated (i.e. in non-
fips mode):ret =
drbg_get_random_bytes(drbg, entropy, entropylen + strength);so: entropylen + strength = 384 + 256, no?
Correct (for entropy + nonce + pers), I thought you were referring to just the entropy + nonce part. This change is not needed for FIPS of course but I changed it too to use the same algorithm and lengths as when Jitter RNG is available.
Do you prefer to keep the current lengths (384 bits) when there is no Jitter RNG? It seems to me that this change makes sense and could only strengthen this case though.
Quoted 15 lines
Quoted 9 lines
Quoted 6 lines
- in FIPS mode: 256 bits of data from
get_random_bytesconcatenated with 384
bits from the Jitter RNGIn both cases there are 256 bits for the entropy input and 128 bits for the nonce.
I see in the code path with the Jitter RNG:
ret =
crypto_rng_get_bytes(drbg->jent, entropy, entropylen);Quoted 8 lines
--> 384 bits from the Jitter RNG
ret = drbg_get_random_bytes(drbg, entropy + entropylen, + strength);
--> 256 bits from
get_random_bytesWhat am I missing here?
OK, it is just a misunderstanding of what is where. To simplify the code (with a fixed-length entropy array) I used the "entropy" array to store the entropy + nonce + the automatically generated personalization string or additional input. The user-supplied personalization string or additional input is stored (unchanged) in the pers
drbg_string. I (briefly) explained this in the comments.Another difference brought by this change is that the Jitter RNG data (i.e. entropy source) is used at the beginning (of the entropy array) and the urandom data (i.e. random source) at the end. This strictly follows the algorithm described in SP800-90Ar1 sections 8.6.1, 8.6.2, 10.1.1.2 and 10.1.1.3 .
Quoted 5 lines
Quoted 4 lines
If Jitter RNG is not available, then urandom is used instead, which means that the system is not FIPS compliant.
Quoted 7 lines
Agreed, the existing does does exactly the same with the exception that it pulls 384 bits from
get_random_bytesinstead of 640 in non-FIPS mode (i.e. when the Jitter RNG is not allocated).In FIPS mode, the current code draws 384 bits from
get_random_bytesand separately 384 bits from the Jitter RNG. So, each data block from either entropy source could completely satisfy the SP800-90A requirement.What is the rational of using 384 (strength * 1.5) bits to draw from
get_random_bytes?We noticed that (as explained above) the order of these sources doesn't follows SP800-90Ar1.
It is not clear which part and source is used for the entropy, nonce and (maybe) personalization string.
If the random source is indeed the personalization string or the additional input, then the pers length may not fit with the maximum lengths specified in SP800-90Ar1 table 2 and 3.Quoted 6 lines
Quoted 4 lines
This follows the SP800-90Ar1, section 8.6.7: [a nonce shall be] "A value with at least (security_strength/2) bits of entropy".
Agreed, but what is your code doing different than the existing code?
It just fits with strength/2 for the length of the nonce.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
So, I am not fully sure what the benefit of the difference is: in FIPS mode
(where the Jitter RNG is used), the amount of data pulled fromget_random_bytesseems to be now reduced.Quoted 7 lines
Quoted 3 lines
We can increase the amount of data pulled from
get_random_bytes(how to decide the amount?), but as we understand the document, this should be part of the personalization string and additional input, not the nonce.There is no need to have a personalization string or additional input. Note, those two values are intended to be provided by a caller or some other environment.
Right, but the intent here is to strictly follow SP800-90Ar1 (hence the use of Jitter RNG for entropy and nonce) but to still use the urandom source, which seems to only fit in the personalization string according to SP800-90Ar1.
Quoted 7 lines
If you want to stuff more seed into the DRBG, you simply enlarge the seed buffer and pull more from the entropy sources. I have no objections doing that. All I am trying to point out is that the 90A standard does not require more entropy than 256 bits during initialization plus 128 bits of nonce == 384
bits of data. But the DRBGs all allow providing more data as seed.Agreed, the user-supplied personalization string can be used to add more data. We also want to harden the default use (i.e. without user-provided personalization string) by automatically using non-entropy source (urandom) though.
Quoted 5 lines
Quoted 4 lines
I guess it may not change much according to the implementation, as for the order of random and entropy concatenation, but these changes align with the specifications and it should help FIPS certifications.
Quoted 7 lines
Are you saying the order of data from the entropy sources matters in the entropy buffer? I have not seen that in the standard, but if you say this is the goal, then allow me to understand which order you want to see?
The current code contains the order of:
<384 bits
get_random_bytes> || <384 bits Jitter RNG>^ ^
personalization string? entropy+nonceAs described in SP800-90Ar1 section 10.1.1.2:
seed_material=entropy_input|| nonce ||personalization_stringAs described in SP800-90Ar1 section 10.1.1.3:
seed_material=0x01|| V ||entropy_input||additional_input
Quoted 7 lines
And SP800-90Ar1 section 5 defining "X || Y" as "Concatenation of two strings X and Y. X and Y are either both bitstrings, or both byte strings".
According to that, we would like at least:
<384 bits Jitter RNG> || <256 bitsget_random_bytes>
and also enforcing the maximum length for the whole personalization string and the additional input.
And I think here we found the misconception.
- SP800-90A section 8.7.1 clearly marks that a personalization string is optional. If it is not provided, the personalization string is treated as a zero-bit string in the formulas you mentioned above. This is also consistent with the CAVP testing of DRBGs conducted by NIST which allows testing of the DRBG without a personalization string. See [1] as an example (search for DRBG and click on it to see the tested options - there you see the testing with zero personalization string).
- SP800-90A section 9.1 specifies that the entropy_input is: "The maximum length of the entropy_input is implementation dependent, but shall be less than or equal to the specified maximum length for the selected DRBG mechanism". For all DRBGs except the CTR DRBG without derivation function the maximum length is 2^35 as defined in table 2. As we do not have a CTR DRBG without derivation function, we can ignore that special case.
With these considerations, the current DRBG code
- does not mandate a personalization string or even create one by itself but allows the caller to specify one
- applies an entropy_input len of 512 bits during initial seeding
- applies a nonce of 128 bits during initial seeding
entropy_input == <384 bits get_random_bytes> || <256 bits Jitter RNG>
nonce = 128 bits Jitter RNG
You asked why 384 bits from get_random_bytes. Well, the answer is exactly to cover your initial concern also raised by James Morris: some folks may not trust the Jitter RNG. Yet we need it here as it only provides 90B compliance. But folks who dislike it can treat its data providing no entropy and assume get_random_bytes provides the entropy.
As both, the get_random_bytes and Jitter RNG data is concatenated, we do not destroy entropy by this operation. This implies we cover different view points at the same time.
[1]
https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/details?validation=33056
Ciao
Stephan
Quoted 3 lines
Thanks,
Mickaël
Quoted 222 lines · Stephan Mueller
Am Donnerstag, dem 24.06.2021 um 12:13 +0200 schrieb Mickaël Salaün:
Quoted 196 lines · Stephan Mueller
Quoted 53 lines
Am Mittwoch, dem 23.06.2021 um 20:04 +0200 schrieb Mickaël Salaün:
Quoted 39 lines · Stephan Müller
Quoted 37 lines
Am Mittwoch, 23. Juni 2021, 19:00:29 CEST schrieb James Morris:
Hi James,
Quoted 7 lines · Stephan Mueller
Quoted 6 lines
Quoted 5 lines
These changes replace the use of the Linux RNG with the Jitter RNG,
which is NIST SP800-90B compliant, to get a proper entropy input and a
nonce as defined by FIPS.Quoted 8 lines
Quoted 4 lines
Can you please help me understand what is missing in the current code
which
seemingly already has achieved this goal?The advice we have is that if an attacker knows the internal state of the
CPU, then the output of the Jitter RNG can be predicted.Thank you for the hint. And I think such goal is worthwhile (albeit I have
to
admit that if an attacker is able to gain the internal state of a CPU, I would
assume we have more pressing problems that a bit of entropy).Anyways, the current code does:
- in regular mode: seed the DRBG with 384 bits of data from
get_random_bytes- in FIPS mode: seed the DRBG with 384 bits of data from
get_random_bytes
concatenated with 384 bits from the Jitter RNGQuoted 7 lines
Quoted 5 lines
If I understand the suggested changes right, I would see the following changes
in the patch:- in the regular case: 640 bits from
get_random_bytesWhy 640 bits?
if (!reseed)
entropylen = ((entropylen + 1) / 2) * 3;-> Entropylen is 384 in case of a security strength of 256 bits.
Quoted 7 lines
Your code does the following if the Jitter RNG is not allocated (i.e. in non-
fips mode):ret =
drbg_get_random_bytes(drbg, entropy, entropylen + strength);so: entropylen + strength = 384 + 256, no?
Correct (for entropy + nonce + pers), I thought you were referring to just the entropy + nonce part. This change is not needed for FIPS of course but I changed it too to use the same algorithm and lengths as when Jitter RNG is available.
Do you prefer to keep the current lengths (384 bits) when there is no Jitter RNG? It seems to me that this change makes sense and could only strengthen this case though.
Quoted 15 lines
Quoted 9 lines
Quoted 6 lines
- in FIPS mode: 256 bits of data from
get_random_bytesconcatenated with 384
bits from the Jitter RNGIn both cases there are 256 bits for the entropy input and 128 bits for the nonce.
I see in the code path with the Jitter RNG:
ret =
crypto_rng_get_bytes(drbg->jent, entropy, entropylen);Quoted 8 lines
--> 384 bits from the Jitter RNG
ret = drbg_get_random_bytes(drbg, entropy + entropylen, + strength);
--> 256 bits from
get_random_bytesWhat am I missing here?
OK, it is just a misunderstanding of what is where. To simplify the code (with a fixed-length entropy array) I used the "entropy" array to store the entropy + nonce + the automatically generated personalization string or additional input. The user-supplied personalization string or additional input is stored (unchanged) in the pers
drbg_string. I (briefly) explained this in the comments.Another difference brought by this change is that the Jitter RNG data (i.e. entropy source) is used at the beginning (of the entropy array) and the urandom data (i.e. random source) at the end. This strictly follows the algorithm described in SP800-90Ar1 sections 8.6.1, 8.6.2, 10.1.1.2 and 10.1.1.3 .
Quoted 5 lines
Quoted 4 lines
If Jitter RNG is not available, then urandom is used instead, which means that the system is not FIPS compliant.
Quoted 7 lines
Agreed, the existing does does exactly the same with the exception that it pulls 384 bits from
get_random_bytesinstead of 640 in non-FIPS mode (i.e. when the Jitter RNG is not allocated).In FIPS mode, the current code draws 384 bits from
get_random_bytesand separately 384 bits from the Jitter RNG. So, each data block from either entropy source could completely satisfy the SP800-90A requirement.What is the rational of using 384 (strength * 1.5) bits to draw from
get_random_bytes?We noticed that (as explained above) the order of these sources doesn't follows SP800-90Ar1.
It is not clear which part and source is used for the entropy, nonce and (maybe) personalization string.
If the random source is indeed the personalization string or the additional input, then the pers length may not fit with the maximum lengths specified in SP800-90Ar1 table 2 and 3.Quoted 6 lines
Quoted 4 lines
This follows the SP800-90Ar1, section 8.6.7: [a nonce shall be] "A value with at least (security_strength/2) bits of entropy".
Agreed, but what is your code doing different than the existing code?
It just fits with strength/2 for the length of the nonce.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
So, I am not fully sure what the benefit of the difference is: in FIPS mode
(where the Jitter RNG is used), the amount of data pulled fromget_random_bytesseems to be now reduced.Quoted 7 lines
Quoted 3 lines
We can increase the amount of data pulled from
get_random_bytes(how to decide the amount?), but as we understand the document, this should be part of the personalization string and additional input, not the nonce.There is no need to have a personalization string or additional input. Note, those two values are intended to be provided by a caller or some other environment.
Right, but the intent here is to strictly follow SP800-90Ar1 (hence the use of Jitter RNG for entropy and nonce) but to still use the urandom source, which seems to only fit in the personalization string according to SP800-90Ar1.
Quoted 7 lines
If you want to stuff more seed into the DRBG, you simply enlarge the seed buffer and pull more from the entropy sources. I have no objections doing that. All I am trying to point out is that the 90A standard does not require more entropy than 256 bits during initialization plus 128 bits of nonce == 384
bits of data. But the DRBGs all allow providing more data as seed.Agreed, the user-supplied personalization string can be used to add more data. We also want to harden the default use (i.e. without user-provided personalization string) by automatically using non-entropy source (urandom) though.
Quoted 5 lines
Quoted 4 lines
I guess it may not change much according to the implementation, as for the order of random and entropy concatenation, but these changes align with the specifications and it should help FIPS certifications.
Quoted 7 lines
Are you saying the order of data from the entropy sources matters in the entropy buffer? I have not seen that in the standard, but if you say this is the goal, then allow me to understand which order you want to see?
The current code contains the order of:
<384 bits
get_random_bytes> || <384 bits Jitter RNG>^ ^
personalization string? entropy+nonceAs described in SP800-90Ar1 section 10.1.1.2:
seed_material=entropy_input|| nonce ||personalization_stringAs described in SP800-90Ar1 section 10.1.1.3:
seed_material=0x01|| V ||entropy_input||additional_inputQuoted 7 lines
And SP800-90Ar1 section 5 defining "X || Y" as "Concatenation of two strings X and Y. X and Y are either both bitstrings, or both byte strings".
According to that, we would like at least:
<384 bits Jitter RNG> || <256 bitsget_random_bytes>
and also enforcing the maximum length for the whole personalization string and the additional input.And I think here we found the misconception.
- SP800-90A section 8.7.1 clearly marks that a personalization string is optional. If it is not provided, the personalization string is treated as a zero-bit string in the formulas you mentioned above. This is also consistent with the CAVP testing of DRBGs conducted by NIST which allows testing of the DRBG without a personalization string. See [1] as an example (search for DRBG and click on it to see the tested options - there you see the testing with zero personalization string).
- SP800-90A section 9.1 specifies that the
entropy_inputis: "The maximum length of theentropy_inputis implementation dependent, but shall be less than or equal to the specified maximum length for the selected DRBG mechanism". For all DRBGs except the CTR DRBG without derivation function the maximum length is 2^35 as defined in table 2. As we do not have a CTR DRBG without derivation function, we can ignore that special case.
Quoted 4 lines
With these considerations, the current DRBG code
- does not mandate a personalization string or even create one by itself but allows the caller to specify one
OK
Quoted 6 lines
- applies an
entropy_inputlen of 512 bits during initial seeding- applies a nonce of 128 bits during initial seeding
entropy_input== <384 bitsget_random_bytes> || <256 bits Jitter RNG>
We think that using "<384 bits get_random_bytes> || " makes this DRBG non-compliant with SP800-90A rev1 because get_random_bytes doesn't use a vetted conditioning component (but ChaCha20 instead):
SP800-90Ar1, section 8.6.5 says "A DRBG mechanism requires an approved randomness source during instantiation and reseeding [...]. An approved randomness source is an entropy source that conforms to [SP 800-90B], or an RBG that conforms to [SP 800-90C] − either a DRBG or an NRBG". The FIPS 140-2 Implementation Guidance
(https://csrc.nist.gov/csrc/media/projects/cryptographic-module-validation-program/documents/fips140-2/fips1402ig.pdf),
section 7.19 says "As of November 7, 2020, all newly submitted modules requiring an entropy evaluation must demonstrate compliance to SP 800-90B". In resolution 3 it says "all processing of the raw data output from the noise sources that happens before it is ultimately output from the entropy source *shall* occur within a conditioning chain". Data from get_random_bytes may come from multiple noise sources, but they are hashed with ChaCha20.
In resolution 6 it says "a vetted conditioning component may optionally take a finite amount of supplemental data [...] in addition to the data from the primary noise source", which would be OK if get_random_bytes used a vetted algorithm, but it is not the case for now.
Quoted 2 lines
nonce = 128 bits Jitter RNG
OK
Quoted 7 lines
You asked why 384 bits from
get_random_bytes. Well, the answer is exactly to cover your initial concern also raised by James Morris: some folks may not trust the Jitter RNG. Yet we need it here as it only provides 90B compliance. But folks who dislike it can treat its data providing no entropy and assumeget_random_bytesprovides the entropy.
Agreed, this is the reason we want to keep using urandom, but not as the entropy input.
Quoted 4 lines
As both, the
get_random_bytesand Jitter RNG data is concatenated, we do not destroy entropy by this operation. This implies we cover different view points at the same time.
The entropy is not destroyed but doesn't seems compliant with the specification (and IG).
Quoted 12 lines
[1]
https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/details?validation=33056Ciao
StephanQuoted 3 lines
Thanks,
Mickaël
Am Freitag, 25. Juni 2021, 13:09:26 CEST schrieb Mickaël Salaün:
Hi Mickaël,
[...]
Quoted 20 lines
Quoted 6 lines
- applies an
entropy_inputlen of 512 bits during initial seeding- applies a nonce of 128 bits during initial seeding
entropy_input== <384 bitsget_random_bytes> || <256 bits Jitter RNG>We think that using "<384 bits
get_random_bytes> || " makes this DRBG non-compliant with SP800-90A rev1 becauseget_random_bytesdoesn't use a vetted conditioning component (but ChaCha20 instead):SP800-90Ar1, section 8.6.5 says "A DRBG mechanism requires an approved randomness source during instantiation and reseeding [...]. An approved randomness source is an entropy source that conforms to [SP 800-90B], or an RBG that conforms to [SP 800-90C] − either a DRBG or an NRBG". The FIPS 140-2 Implementation Guidance
(https://csrc.nist.gov/csrc/media/projects/cryptographic-module-validation-p
rogram/documents/fips140-2/fips1402ig.pdf), section 7.19 says "As of November 7, 2020, all newly submitted modules requiring an entropy evaluation must demonstrate compliance to SP 800-90B". In resolution 3 it
Quoted 8 lines
says "all processing of the raw data output from the noise sources that happens before it is ultimately output from the entropy source *shall* occur within a conditioning chain". Data from
get_random_bytesmay come from multiple noise sources, but they are hashed with ChaCha20. In resolution 6 it says "a vetted conditioning component may optionally take a finite amount of supplemental data [...] in addition to the data from the primary noise source", which would be OK ifget_random_bytesused a vetted algorithm, but it is not the case for now.
You cite the right references, I think the interpretation is too strict.
The specifications require that
a) The DRBG must be seeded by a 90B entropy source
b) The DRBG must be initially seeded with 256 bits of entropy plus some 128 bit nonce
We cover a) with the Jitter RNG and b) by pulling 384 bits from it.
The standard does not forbit:
c) the entropy string may contain data from another origin or it contains a larger buffer
d) the actual entropy distribution in the entropy string being not an equidistribution over the entire entropy string
Bullet d) implies that it is perfectly fine to have entropy distribution begin loopsided in the entropy string.
Bullet c) implies that other data can be provided with the entropy string.
With that, to be 90A/B compliant, you interpret that the Jitter RNG provides all entropy you need and credit the entropy from get_random_bytes with zero bits of entropy.
Note, if you look into the implementation of the DRBG seeding, the different input strings like entropy string or data without entropy like personalization string are simply concatenated and handed to the DRBG. As the Jitter RNG and get_random_bytes data is also concatenated, it follows the concepts of 90A.
If you look into the draft 90C standard, it explicitly allows concatenation of data from an entropy source that you credit with entropy and data without entropy - see the crediting of entropy of multiple entropy sources defined with "Method 1" and "Method 2" in the current 90C draft.
This ultimately allows us to have an entropy string that is concatenated from different entropy sources. If you have an entropy source that is not 90B compliant, you have to credit it with zero bits of entropy in the entropy analysis. Thus, only the entropy source(s) compliant to 90B must provide the entire entropy as mandated by 90A.
After having several discussions with the Entropy Working group sponsored by NIST that included also representatives from the NIST crypto technology group, there was no concern regarding such approach.
This approach you see in the current DRBG seeding code is now taken for different FIPS validations including FIPS validations that I work on as a FIPS tester as part of my duties working for a FIPS lab. My colleagues have reviewed the current kernel DRBG seeding strategy and approved of it for other FIPS validations.
Ciao
Stephan
Quoted 73 lines · Stephan Müller
Am Freitag, 25. Juni 2021, 13:09:26 CEST schrieb Mickaël Salaün:
Hi Mickaël,
[...]
Quoted 20 lines
Quoted 6 lines
- applies an
entropy_inputlen of 512 bits during initial seeding- applies a nonce of 128 bits during initial seeding
entropy_input== <384 bitsget_random_bytes> || <256 bits Jitter RNG>We think that using "<384 bits
get_random_bytes> || " makes this DRBG non-compliant with SP800-90A rev1 becauseget_random_bytesdoesn't use a vetted conditioning component (but ChaCha20 instead):SP800-90Ar1, section 8.6.5 says "A DRBG mechanism requires an approved randomness source during instantiation and reseeding [...]. An approved randomness source is an entropy source that conforms to [SP 800-90B], or an RBG that conforms to [SP 800-90C] − either a DRBG or an NRBG". The FIPS 140-2 Implementation Guidance
(https://csrc.nist.gov/csrc/media/projects/cryptographic-module-validation-p
rogram/documents/fips140-2/fips1402ig.pdf), section 7.19 says "As of November 7, 2020, all newly submitted modules requiring an entropy evaluation must demonstrate compliance to SP 800-90B". In resolution 3 itQuoted 8 lines
says "all processing of the raw data output from the noise sources that happens before it is ultimately output from the entropy source *shall* occur within a conditioning chain". Data from
get_random_bytesmay come from multiple noise sources, but they are hashed with ChaCha20. In resolution 6 it says "a vetted conditioning component may optionally take a finite amount of supplemental data [...] in addition to the data from the primary noise source", which would be OK ifget_random_bytesused a vetted algorithm, but it is not the case for now.You cite the right references, I think the interpretation is too strict.
The specifications require that
a) The DRBG must be seeded by a 90B entropy source
b) The DRBG must be initially seeded with 256 bits of entropy plus some 128 bit nonce
We cover a) with the Jitter RNG and b) by pulling 384 bits from it.
The standard does not forbit:
c) the entropy string may contain data from another origin or it contains a larger buffer
d) the actual entropy distribution in the entropy string being not an equidistribution over the entire entropy string
Bullet d) implies that it is perfectly fine to have entropy distribution begin loopsided in the entropy string.
Bullet c) implies that other data can be provided with the entropy string.
With that, to be 90A/B compliant, you interpret that the Jitter RNG provides all entropy you need and credit the entropy from
get_random_byteswith zero bits of entropy.Note, if you look into the implementation of the DRBG seeding, the different input strings like entropy string or data without entropy like personalization string are simply concatenated and handed to the DRBG. As the Jitter RNG and
get_random_bytesdata is also concatenated, it follows the concepts of 90A.If you look into the draft 90C standard, it explicitly allows concatenation of data from an entropy source that you credit with entropy and data without entropy - see the crediting of entropy of multiple entropy sources defined with "Method 1" and "Method 2" in the current 90C draft.
Quoted 5 lines
This ultimately allows us to have an entropy string that is concatenated from different entropy sources. If you have an entropy source that is not 90B compliant, you have to credit it with zero bits of entropy in the entropy analysis. Thus, only the entropy source(s) compliant to 90B must provide the entire entropy as mandated by 90A.
Thanks for your detailed explanation Stephan. We agree that data from get_random_bytes is not accounted as entropy, but the question is: is it still in line with the specification because it uses an algorithm not compliant to SP800-90B (i.e. ChaCha20 is not a vetted conditioning component)? Cf. IG 7.19 resolution 6 from 08/28/2020 and IG 7.20 from 05/04/2021.
Quoted 10 lines
After having several discussions with the Entropy Working group sponsored by NIST that included also representatives from the NIST crypto technology group, there was no concern regarding such approach.
This approach you see in the current DRBG seeding code is now taken for different FIPS validations including FIPS validations that I work on as a FIPS tester as part of my duties working for a FIPS lab. My colleagues have reviewed the current kernel DRBG seeding strategy and approved of it for other FIPS validations.
Good to know. We are worried that a new FIPS validation (started after November 7, 2020) could failed because of the new SP800-90B requirement. This issue was pointed out by a lab. It seems that the specification is still open to different interpretations.
Regards,
Mickaël
This one really does keep coming back like yesterday's herring, doesn't it...
Quoted 15 lines · James Morris
Quoted 3 lines · Stephan Mueller
Quoted 3 lines
These changes replace the use of the Linux RNG with the Jitter RNG, which is NIST SP800-90B compliant, to get a proper entropy input
and a
Quoted 3 lines
Quoted 1 line
nonce as defined by FIPS.
Can you please help me understand what is missing in the current code
which
Quoted 1 line
seemingly already has achieved this goal?
The advice we have is that if an attacker knows the internal state of the
CPU, then the output of the Jitter RNG can be predicted.
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.