[openssl-users] conversion of RAND_bytes to rand in fips apporved way

Sudarshan Soma sudarshan12s at gmail.com
Wed Jul 25 18:12:34 UTC 2018


 Hi, we have linked FIPS compliant openssl version against our applications.

Now few applications are using libc rand function. For FIPS compliance,
applications have
to call approved SP 800-90A DRBG implementation. I was planning to replace
libc rand with RAND_bytes
for the same.

But rand() returns max value of 32767 .  Is there a recomended way to
convert RAND_bytes to libc rand()
something like this?

unsigned char buf[2];
RAND_bytes(buf,2)
int *rndp = malloc(4);
memcpy(rndp,buf,2);
return (unsigned) ((*rndp) % 32768)


Please suggest . Is there a way to give number of bits instead of bytes  to
RAND_bytes?

Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20180725/545d39a6/attachment.html>


More information about the openssl-users mailing list