>>>>> "ambarish_mitra" == Ambarish Mitra <[EMAIL PROTECTED]> writes:
ambarish_mitra> Hi all, I am trying to generate random numbers using openssl. I
ambarish_mitra> am not using the ENGINE API, but using only the rand functions.
ambarish_mitra> Code snippet:
You correctly identify the buffer as unsigned char, but then you deal with it
as if it was a NUL terminated string.
Perhaps:
r = RAND_bytes(buf, strlen(buf));
printf("random status: %d\n",r);
printf("random number: [%s]\n",buf);
Might be:
r = RAND_bytes(buf, sizeof(buf));
printf("random status: %d\n",r);
printf("random number: ");
for (r = 0; r < sizeof(buf); r++)
{
printf("%02x" buf[r]);
};
printf("\n");
Note that strlen won't work on an undefined, unsigned char, probably giving 0,
which is the beginning of the trouble.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]