I am working on a project and I'm noticing a peculiar behavior that I was hoping someone could tell me if it is correct or not.
I have a program that is trying to generate some random numbers using BN_rand(). Snippet of code follows:
BIGNUM *test = NULL;
unsigned char buffer[2048];
int fd = open("/dev/urandom", O_RDWR);
read(fd, buffer, 2048);
close(fd);
test = BN_new();
if (RAND_status() != 1)
goto error3;
RAND_seed(buffer, 2048);
if (!BN_rand(test,2048,0,1))
goto error3;
do_bn_print_name(stdout, "test", test);
Every time I run this program though, it gives me the same random number. I was expecting the number to be changing after every run. Am I doing this right or is this expected behavior?
Thanks for any assistance!
rc = RAND_load_file("/dev/urandom", 32); if(rc != 32) { /* RAND_load_file failed */ }
– MCCCS Jul 26 '18 at 17:04