aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2016-10-14 15:24:04 +0200
committerTobias Brunner <tobias@strongswan.org>2016-10-14 15:24:04 +0200
commitd3beae1311e72bfe8880313c23c4c7ecad170518 (patch)
tree62454c785489dd9ab2609945cbf1089c1a8d0525 /src/libstrongswan
parentb9c4b15a532a1d0212fb0348a26f673760b92873 (diff)
downloadstrongswan-d3beae1311e72bfe8880313c23c4c7ecad170518.tar.bz2
strongswan-d3beae1311e72bfe8880313c23c4c7ecad170518.tar.xz
newhope: Properly release allocated arrays if RNG can't be created
Diffstat (limited to 'src/libstrongswan')
-rw-r--r--src/libstrongswan/plugins/newhope/newhope_ke.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstrongswan/plugins/newhope/newhope_ke.c b/src/libstrongswan/plugins/newhope/newhope_ke.c
index d4ce8c6d7..28956d5fb 100644
--- a/src/libstrongswan/plugins/newhope/newhope_ke.c
+++ b/src/libstrongswan/plugins/newhope/newhope_ke.c
@@ -197,7 +197,7 @@ static uint32_t* multiply_add_poly(private_newhope_ke_t *this,
fft->transform(fft, this->s, this->s, FALSE);
fft->transform(fft, e, e, FALSE);
fft->destroy(fft);
-
+
b = (uint32_t*)malloc(this->params->n * sizeof(uint32_t));
/* compute b = a * s + e in the frequency domain */
@@ -301,7 +301,7 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
/* allocate space for public output value */
*value = chunk_alloc(poly_len + seed_len);
a_seed = chunk_create(value->ptr + poly_len, seed_len);
-
+
/* create polynomial a from 256 bit random seed */
rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
if (!rng)
@@ -314,20 +314,20 @@ METHOD(diffie_hellman_t, get_my_public_value, bool,
DBG1(DBG_LIB, "could not generate seed for polynomial a");
goto end;
}
-
+
a = derive_a_poly(this, a_seed);
if (a == NULL)
{
goto end;
}
-
+
/* generate random seed for the derivation of noise polynomials */
if (!rng->get_bytes(rng, seed_len, noise_seed.ptr))
{
DBG1(DBG_LIB, "could not generate seed for noise polynomials");
goto end;
}
-
+
/* create noise polynomial generator */
noise = newhope_noise_create(noise_seed);
if (!noise)
@@ -458,13 +458,13 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
{
DBG3(DBG_LIB, "%4d %5u %5u", i, a[i], b[i]);
}
-
+
/* generate random seed for the derivation of noise polynomials */
rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
if (!rng)
{
DBG1(DBG_LIB, "could not instatiate random source");
- return FALSE;
+ goto end;
}
if (!rng->get_bytes(rng, seed_len, noise_seed.ptr))
{
@@ -492,7 +492,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
{
goto end;
}
-
+
/* create noise polynomial e'' from seed with nonce = 0x02 */
e2 = noise->get_binomial_words(noise, 0x02, n, q);
if (e2 == NULL)