Blame SOURCES/libgcrypt-1.8.3-fips-enttest.patch
|
|
66e42d |
diff -up libgcrypt-1.8.3/random/random-drbg.c.fips-enttest libgcrypt-1.8.3/random/random-drbg.c
|
|
|
66e42d |
--- libgcrypt-1.8.3/random/random-drbg.c.fips-enttest 2017-11-23 19:16:58.000000000 +0100
|
|
|
66e42d |
+++ libgcrypt-1.8.3/random/random-drbg.c 2019-06-03 13:19:44.035516400 +0200
|
|
|
66e42d |
@@ -610,6 +610,8 @@ drbg_get_entropy (drbg_state_t drbg, uns
|
|
|
66e42d |
size_t len)
|
|
|
66e42d |
{
|
|
|
66e42d |
int rc = 0;
|
|
|
66e42d |
+ static unsigned char oldhash[64] = { 0 };
|
|
|
66e42d |
+ unsigned char newhash[64];
|
|
|
66e42d |
|
|
|
66e42d |
/* Perform testing as defined in 11.3.2 */
|
|
|
66e42d |
if (drbg->test_data && drbg->test_data->fail_seed_source)
|
|
|
66e42d |
@@ -634,6 +636,17 @@ drbg_get_entropy (drbg_state_t drbg, uns
|
|
|
66e42d |
#else
|
|
|
66e42d |
rc = -1;
|
|
|
66e42d |
#endif
|
|
|
66e42d |
+
|
|
|
66e42d |
+ /* to avoid storing the actual entropy obtained for indefinite
|
|
|
66e42d |
+ time, we just store the SHA-512 hash of the entropy gathered
|
|
|
66e42d |
+ */
|
|
|
66e42d |
+ _gcry_md_hash_buffer (GCRY_MD_SHA512, newhash, buffer, len);
|
|
|
66e42d |
+
|
|
|
66e42d |
+ if (memcmp (newhash, oldhash, sizeof (oldhash)) == 0)
|
|
|
66e42d |
+ return -1; /* continous entropy test failed */
|
|
|
66e42d |
+
|
|
|
66e42d |
+ memcpy (oldhash, newhash, sizeof (oldhash));
|
|
|
66e42d |
+
|
|
|
66e42d |
return rc;
|
|
|
66e42d |
}
|
|
|
66e42d |
|