From: Pauli Date: Mon, 23 Sep 2024 04:18:22 +0000 (+1000) Subject: fips: fix locking issues X-Git-Tag: openssl-3.5.0-alpha1~1024 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=348c928d66e099f9814e7a63e4618e3aecf7286c;p=thirdparty%2Fopenssl.git fips: fix locking issues Reviewed-by: Tomas Mraz Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/25498) --- diff --git a/providers/implementations/rands/fips_crng_test.c b/providers/implementations/rands/fips_crng_test.c index 057ae6e35e2..209a1adb278 100644 --- a/providers/implementations/rands/fips_crng_test.c +++ b/providers/implementations/rands/fips_crng_test.c @@ -302,24 +302,18 @@ static size_t crng_test_get_seed(void *vcrngt, unsigned char **pout, } /* Grab seed from our parent */ - if (!crng_test_lock(crngt)) + if (!lock_parent(crngt)) return 0; - if (!lock_parent(crngt)) { - crng_test_unlock(crngt); - return 0; - } + n = crngt->parent_get_seed(crngt->parent, pout, entropy, min_len, max_len, prediction_resistance, adin, adin_len); - unlock_parent(crngt); - if (n > 0) - r = crng_test(crngt, *pout, n); - crng_test_unlock(crngt); - if (n > 0 && r > 0) - return n; - if (crngt->parent_clear_seed != NULL) + if (n > 0 && crng_test(crngt, *pout, n) > 0) + r = n; + else if (crngt->parent_clear_seed != NULL) crngt->parent_clear_seed(crngt->parent, *pout, n); - return 0; + unlock_parent(crngt); + return r; } static void crng_test_clear_seed(void *vcrngt,