@@ -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);