From the OpenSSL manual:
"Byte sequences generated by RAND_pseudo_bytes() will be unique
if they are of sufficient length, but are not necessarily unpredictable."
So, replace these call with RAND_bytes() to get cryptographically strong
key material.
Signed-off-by: Steffan Karger <steffan@karger.me>
/* Copy random data to the buffer */
- RAND_pseudo_bytes((unsigned char *)c->outkey, len);
+ RAND_bytes((unsigned char *)c->outkey, len);
/* The message we send must be smaller than the modulus of the RSA key.
By definition, for a key of k bits, the following formula holds:
/* Copy random data to the buffer */
- RAND_pseudo_bytes((unsigned char *)c->hischallenge, len);
+ RAND_bytes((unsigned char *)c->hischallenge, len);
/* Convert to hex */
to->inkey = xrealloc(to->inkey, to->inkeylength);
// Create a new key
- RAND_pseudo_bytes((unsigned char *)to->inkey, to->inkeylength);
+ RAND_bytes((unsigned char *)to->inkey, to->inkeylength);
if(to->incipher)
EVP_DecryptInit_ex(&to->inctx, to->incipher, NULL, (unsigned char *)to->inkey, (unsigned char *)to->inkey + to->incipher->key_len);