diff options
author | James Prestwood <prestwoj@gmail.com> | 2024-03-13 09:44:25 -0700 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2024-03-18 09:31:19 -0500 |
commit | f50fb9d1c21c6598497b7fe197f62e32a3314255 (patch) | |
tree | b8104b713909c56bb9577be203c32a51b69b1267 | |
parent | f5e27f0085f9b51015d4cd5aa0891f2cfd37e426 (diff) |
ecdh: add unlikely() check for NULL parameters
-rw-r--r-- | ell/ecdh.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -16,6 +16,7 @@ #include "ecc.h" #include "ecdh.h" #include "random.h" +#include "useful.h" /* * Some sane maximum for calculating the public key. @@ -41,6 +42,9 @@ LIB_EXPORT bool l_ecdh_generate_key_pair(const struct l_ecc_curve *curve, int iter = 0; uint64_t p2[L_ECC_MAX_DIGITS]; + if (unlikely(!curve || !out_private || !out_public)) + return false; + _ecc_calculate_p2(curve, p2); *out_public = l_ecc_point_new(curve); @@ -77,6 +81,9 @@ LIB_EXPORT bool l_ecdh_generate_shared_secret( struct l_ecc_scalar *z; struct l_ecc_point *product; + if (unlikely(!private_key || !other_public || !secret)) + return false; + z = l_ecc_scalar_new_random(curve); product = l_ecc_point_new(curve); |