]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
fips-jitter: set provider into error state upon CRNG permanent failures
authorDimitri John Ledkov <dimitri.ledkov@surgut.co.uk>
Fri, 15 Nov 2024 05:32:33 +0000 (05:32 +0000)
committerTomas Mraz <tomas@openssl.org>
Mon, 25 Nov 2024 14:20:55 +0000 (15:20 +0100)
With fips-jitter build time option, jitter can be inside FIPS
boundary.

Calls to jent_read_entropy() can return permanent failures for
Repetitive Count Test (RTC), Adaptive Proportion Test (APT), LAG
prediction test.

Ensure the module enters error state upon permanent jitter failures.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25957)

providers/implementations/rands/seed_src_jitter.c

index af8d5c4852de8474c0f176b863b9b9170ac8bbc9..1a1919d8230087b78f1489e7b263e938b357feb3 100644 (file)
 #include <openssl/err.h>
 #include <openssl/randerr.h>
 #include <openssl/proverr.h>
+#include <openssl/self_test.h>
 #include "prov/implementations.h"
 #include "prov/provider_ctx.h"
+#include "prov/providercommon.h"
 #include "crypto/rand.h"
 #include "crypto/rand_pool.h"
 
@@ -98,10 +100,12 @@ static size_t get_jitter_random_value(PROV_JITTER *s,
 
         /*
          * Permanent Failure
-         * https://github.com/smuellerDD/jitterentropy-library/issues/118
+         * https://github.com/smuellerDD/jitterentropy-library/blob/master/doc/jitterentropy.3#L234
          */
-        if (result < -5)
+        if (result < -5) {
+            ossl_set_error_state(OSSL_SELF_TEST_TYPE_CRNG);
             break;
+        }
 
         /* Success */
         if (result >= 0 && (size_t)result == len)