Check rng return value when generating DH secrets and primes in gmp plugin
This commit is contained in:
committed by
Martin Willi
parent
e93bb353d5
commit
5025135f70
@@ -314,7 +314,7 @@ METHOD(public_key_t, encrypt_, bool,
|
||||
{
|
||||
chunk_t em;
|
||||
u_char *pos;
|
||||
int padding, i;
|
||||
int padding;
|
||||
rng_t *rng;
|
||||
|
||||
if (scheme != ENCRYPT_RSA_PKCS1)
|
||||
@@ -348,16 +348,12 @@ METHOD(public_key_t, encrypt_, bool,
|
||||
*pos++ = 0x02;
|
||||
|
||||
/* fill with pseudo random octets */
|
||||
rng->get_bytes(rng, padding, pos);
|
||||
|
||||
/* replace zero-valued random octets */
|
||||
for (i = 0; i < padding; i++)
|
||||
if (!rng_get_bytes_not_zero(rng, padding, pos, TRUE))
|
||||
{
|
||||
while (*pos == 0)
|
||||
{
|
||||
rng->get_bytes(rng, 1, pos);
|
||||
}
|
||||
pos++;
|
||||
DBG1(DBG_LIB, "failed to allocate padding");
|
||||
chunk_clear(&em);
|
||||
rng->destroy(rng);
|
||||
return FALSE;
|
||||
}
|
||||
rng->destroy(rng);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user