Fix a deadlock while attempting to get the Primary EVP_RAND_CTX
When only the FIPS provider was loaded we could get a deadlock when
calling RAND_get0_primary() due to attempting to obtain a recursive
lock.
We reduce the scope of the locks that we hold to avoid this.
Fixes #27391
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27408)
(cherry picked from commit
01ea08049815325bf7719499f58c3799aa3fb555)