linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@microchip.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <linux-crypto@vger.kernel.org>, <smueller@chronox.de>,
	<marcel@holtmann.org>, <Nicolas.Ferre@microchip.com>,
	Tudor Ambarus <tudor.ambarus@microchip.com>
Subject: [RFC PATCH v2 2/4] crypto: ecdh - allow user to provide NULL privkey
Date: Wed, 17 May 2017 18:26:51 +0300	[thread overview]
Message-ID: <1495034813-27143-3-git-send-email-tudor.ambarus@microchip.com> (raw)
In-Reply-To: <1495034813-27143-1-git-send-email-tudor.ambarus@microchip.com>

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.ambarus@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

  parent reply	other threads:[~2017-05-17 15:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-17 15:26 [RFC PATCH v2 0/4] crypto: (ec)dh - add privkey generation support Tudor Ambarus
2017-05-17 15:26 ` [RFC PATCH v2 1/4] crypto: ecc " Tudor Ambarus
2017-05-28 18:44   ` Stephan Müller
2017-05-29  9:08     ` Tudor Ambarus
2017-05-29  9:23       ` Stephan Müller
2017-05-29  9:47         ` Tudor Ambarus
2017-05-29  9:56           ` Stephan Müller
2017-05-29 13:27             ` Tudor Ambarus
2017-05-17 15:26 ` Tudor Ambarus [this message]
2017-05-17 15:26 ` [RFC PATCH v2 3/4] crypto: dh - allow user to provide NULL privkey Tudor Ambarus
2017-05-28 18:50   ` Stephan Müller
2017-05-17 15:26 ` [RFC PATCH v2 4/4] crypto: testmgr - add genkey kpp test Tudor Ambarus
2017-05-26 13:44   ` Tudor Ambarus
2017-05-28 18:57   ` Stephan Müller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495034813-27143-3-git-send-email-tudor.ambarus@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=Nicolas.Ferre@microchip.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=smueller@chronox.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).