Optimise locking in rsa_get_blinding()
authorMatt Caswell <matt@openssl.org>
Fri, 12 May 2023 16:06:10 +0000 (17:06 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 30 May 2023 16:39:29 +0000 (17:39 +0100)
commitf53479f98a2f2a6149192c5e3ef4ddf0926dceba
tree916981427a525f8809f1a70077c4f389165c7519
parent6d15357aeb893c6e8b4c7a8188c18f4db54c0612
Optimise locking in rsa_get_blinding()

We optimise locking in rsa_get_blinding() so that we normally take a
read lock, and only fallback to a write lock if we need to. This will
be very slightly slower in the case of single use RSA objects, but should
be significantly better when an RSA object is reused in a multi-threaded
environment. It's probably worth the trade off.

Partially fixes #20286

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20953)
crypto/rsa/rsa_ossl.c