Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to seed PRNG for usage with BN_rand*?

Tags:

c

openssl

I would like to use:

BN_rand_range(...);

and due to the OpenSSL documentation:

The PRNG must be seeded prior to calling BN_rand() or BN_rand_range().

But there is no link or method name hint provided how I could do that. What is the correct way to seed the PRNG with OpenSSL?

like image 700
miho Avatar asked Dec 31 '25 05:12

miho


1 Answers

What is the correct way to seed the PRNG with OpenSSL?

Internally, OpenSSL of auto-seeds itself with RAND_poll (with some hand waiving). There's a few reasons why you might want to avoid the behavior and explicitly seed the generator yourself.

There's a more complete writeup on the OpenSSL wiki at Random Numbers.

like image 162
jww Avatar answered Jan 03 '26 10:01

jww