Thread (5 messages) 5 messages, 1 author, 2017-05-17

[RFC PATCH 2/4] crypto: ecdh - allow user to provide NULL privkey

flat view
STALE3441d SUPERSEDED

From: Tudor Ambarus <hidden>
Date: 2017-05-17 10:39:03
Subsystem: crypto api, the rest · Maintainers: Herbert Xu, "David S. Miller", Linus Torvalds

Revision rfc of 2 in this series.

Revisions (2)
  1. rfc current
  2. v2 [diff vs current]
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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help