If the user provides a NULL ecc private key, the kernel will
generate it and further use it for ecdh.

Signed-off-by: Tudor Ambarus <tudor.amba...@microchip.com>
---
 crypto/ecdh.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/crypto/ecdh.c b/crypto/ecdh.c
index 63ca337..f28f5b5 100644
--- a/crypto/ecdh.c
+++ b/crypto/ecdh.c
@@ -55,6 +55,10 @@ static int ecdh_set_secret(struct crypto_kpp *tfm, const 
void *buf,
        ctx->curve_id = params.curve_id;
        ctx->ndigits = ndigits;
 
+       if (!params.key || !params.key_size)
+               return ecc_gen_privkey(ctx->curve_id, ctx->ndigits,
+                                      ctx->private_key);
+
        if (ecc_is_key_valid(ctx->curve_id, ctx->ndigits,
                             (const u8 *)params.key, params.key_size) < 0)
                return -EINVAL;
-- 
2.7.4

Reply via email to