diff options
author | Kai Engert <kaie@kuix.de> | 2016-02-18 21:53:57 +0100 |
---|---|---|
committer | Kai Engert <kaie@kuix.de> | 2016-02-18 21:53:57 +0100 |
commit | 5bc722815ef219d3be2287bc1b125efbf3e386c3 (patch) | |
tree | 771653d9881014458d7d08149e98b03e075cd0e4 /lib/freebl/dh.c | |
parent | fd980e9d3e6faa5ab7c11744a3ae6e4544d4ce6f (diff) | |
download | nss-hg-5bc722815ef219d3be2287bc1b125efbf3e386c3.tar.gz |
Bug 1181814, Backout 43e2d2e1cb74
Diffstat (limited to 'lib/freebl/dh.c')
-rw-r--r-- | lib/freebl/dh.c | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/lib/freebl/dh.c b/lib/freebl/dh.c index 86ae90e68..66c110134 100644 --- a/lib/freebl/dh.c +++ b/lib/freebl/dh.c @@ -173,8 +173,8 @@ DH_NewKey(DHParams *params, DHPrivateKey **privKey) /* Generate private key xa */ SECITEM_AllocItem(arena, &key->privateValue, dh_GetSecretKeyLen(params->prime.len)); - CHECK_SEC_OK(RNG_GenerateGlobalRandomBytes(key->privateValue.data, - key->privateValue.len)); + RNG_GenerateGlobalRandomBytes(key->privateValue.data, + key->privateValue.len); SECITEM_TO_MPINT( key->privateValue, &xa ); /* xa < p */ CHECK_MPI_OK( mp_mod(&xa, &p, &xa) ); @@ -191,10 +191,8 @@ cleanup: MP_TO_SEC_ERROR(err); rv = SECFailure; } - if (rv) { - *privKey = NULL; + if (rv) PORT_FreeArena(arena, PR_TRUE); - } return rv; } @@ -274,10 +272,6 @@ DH_Derive(SECItem *publicValue, /* allocate a buffer which can hold the entire derived secret. */ secret = PORT_Alloc(len); - if (secret == NULL) { - err = MP_MEM; - goto cleanup; - } /* grab the derived secret */ err = mp_to_unsigned_octets(&ZZ, secret, len); if (err >= 0) err = MP_OKAY; @@ -291,10 +285,7 @@ DH_Derive(SECItem *publicValue, nb = outBytes; else nb = len; - if (SECITEM_AllocItem(NULL, derivedSecret, nb) == NULL) { - err = MP_MEM; - goto cleanup; - } + SECITEM_AllocItem(NULL, derivedSecret, nb); if (len < nb) { unsigned int offset = nb - len; memset(derivedSecret->data, 0, offset); @@ -369,19 +360,11 @@ KEA_Derive(SECItem *prime, /* allocate a buffer for the full derived secret */ len = mp_unsigned_octet_size(&w); secret = PORT_Alloc(len); - if (secret == NULL) { - err = MP_MEM; - goto cleanup; - } /* grab the secret */ err = mp_to_unsigned_octets(&w, secret, len); if (err > 0) err = MP_OKAY; /* allocate output buffer */ - if (SECITEM_AllocItem(NULL, derivedSecret, KEA_DERIVED_SECRET_LEN) - == NULL) { - err = MP_MEM; - goto cleanup; - } + SECITEM_AllocItem(NULL, derivedSecret, KEA_DERIVED_SECRET_LEN); memset(derivedSecret->data, 0, derivedSecret->len); /* copy in the 128 lsb of the secret */ if (len >= KEA_DERIVED_SECRET_LEN) { @@ -404,8 +387,6 @@ cleanup: PORT_ZFree(secret, len); if (err) { MP_TO_SEC_ERROR(err); - if (derivedSecret->data) - PORT_ZFree(derivedSecret->data, derivedSecret->len); return SECFailure; } return SECSuccess; |