>
It isn't possible to do what you are wanting. RAND_METHOD replaces the RNG everywhere.
It
cannot be done on a per
thread process. Well, technically it *is* possible. However, I’m still
in doubt whether it is really necessary and should be done. The following example assumes you are compiling for
linux (or another unix-ish
os) and using pthreads: Assume that you recorded the thread id of your thread T1 (which
you obtained from pthread_create()) in the static variable ‘tid1’. Then you could take the code
from [1] and modify it as follows: ``` static int
my_rand_bytes(unsigned char *out, int count) {
int ret;
if (pthread_equal(pthread_self(), tid1) {
// ... call your special RNG here
} else {
RAND_DRBG *drbg = RAND_DRBG_get0_public();
if (drbg == NULL)
return 0;
ret = RAND_DRBG_bytes(drbg, out, count);
}
return ret; } ``` This is just a rough sketch, note that there are more RAND_METHODs
to be considered [2]. Matthias [1] https://github.com/openssl/openssl/blob/OpenSSL_1_1_1-stable/crypto/rand/drbg_lib.c#L958-L970 [2] https://github.com/openssl/openssl/blob/OpenSSL_1_1_1-stable/crypto/rand/drbg_lib.c#L1146-L1153 From: openssl-users
<openssl-users-bounces@xxxxxxxxxxx> On Behalf Of Dr Paul Dale Vishwanath, On 4/4/21 9:55 pm, Vishwanath Mahajanshetty wrote:
|
Attachment:
smime.p7s
Description: S/MIME cryptographic signature