Hi
all,
I am
trying to generate random numbers using openssl. I am not using the ENGINE API,
but using only the rand functions.
Code
snippet:
int main(int argc, char
*argv[])
{
RAND_METHOD *rmeth;
int r;
unsigned char buf[16];
{
RAND_METHOD *rmeth;
int r;
unsigned char buf[16];
rmeth =
RAND_SSLeay();
if (rmeth ==
NULL)
exit(2);
exit(2);
r = RAND_bytes(buf,
strlen(buf));
printf("random status:
%d\n",r);
printf("random number: [%s]\n",buf);
printf("random number: [%s]\n",buf);
RAND_cleanup();
return 0;
}
return 0;
}
From
the documentation of RAND_bytes, I see that it fills up the buf and returns 1 on
success. In this code, this returns 1, but still the buffer comes
empty.
random status: 1
random number: []
random number: []
Has
anyone faced this issue before? Where am I going wrong? Any help
appreciated.