Thank You Paul and Matthias for your help.
The reason I am trying to have separate RAND_METHOD for two threads is, the first thread which runs DNS bind code registers for RAND_METHOD through dnssec module in it. It registers via either ENGINE_set_default_RAND() or RAND_set_rand_method() based on OPENSSL_NO_ENGINE is defined or not. But problem is, under some circumstances the random number generator enters into blocking mode and starts to wait for some events on some FDs and it blocks in select() system call. dst__entropy_getdata() from bind code is doing this. I am not sure under what cases it enters into blocking mode.
So If I use this RND_METHOD in second thread (basically this thread does different task of handling DoT, Dns Over TLS, connections, which is not related to first thread wrt SSL functionalities), then while creating SSL_CTX this thread gets stuck in select() system call randomly (happens very rarely as decided by dst__entropy_getdata()); this can happen at any time of SSL connection lifetime whenever it wants to get random data.
I agree with you that we should have done this as separate process instead of new thread; but I am trying figure out if I can somehow avoid this situation.
As you mentioned, I tried to look into implementation of RAND_bytes() and drbg_bytes().
When SSL_CTX_new() calls RAND_bytes(), it calls RAND_get_rand_method() which returns RAND_METHOD set by bind thread. So if I avoid configuring RAND_METHOD in bind thread, then RAND_get_rand_method() will return rand_meth which is OpenSSL default RAND_METHOD; but if I do this change bind thread will move away from its RAND_METHOD functions and start using OpenSSL default functions which may change its behaviour.
So I am still confused how can I do bind thread to use its own RAND_METHOD and DoT thread to use default OpenSSL RAND_METHOD. It would be really helpful if you can explain this with little more details (are there any APIs I can call from one thread to use its specific RAND_METHOD but other threads continue to use OpenSSL default RAND_METHOD?).
Send openssl-users mailing list submissions to
I would be **very** concerned about bypassing a blocking RAND. It is almost certainly blocking because it does not have enough randomness to satisfy your request. By skipping this, you are likely getting poor quality random values and this can effectively negate any security you are gaining from the encryption.
Good random numbers are fundamental to modern cryptography. Without them, there is no security. I cannot stress this enough. Do not try to second guess or bypass the RNG.
On 3/4/21 6:41 pm, Vishwanath Mahajanshetty wrote:
|Free forum by Nabble||Edit this page|