All of lore.kernel.org
 help / color / mirror / Atom feed
From: Meng Yu <yumeng18@huawei.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
	<marcel@holtmann.org>, <johan.hedberg@gmail.com>,
	<luiz.dentz@gmail.com>, <tudor.ambarus@microchip.com>
Cc: <linux-crypto@vger.kernel.org>, <xuzaibo@huawei.com>,
	<wangzhou1@hisilicon.com>, <yumeng18@huawei.com>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH v8 8/9] crypto: add curve25519 params and expose them
Date: Mon, 8 Feb 2021 17:38:56 +0800	[thread overview]
Message-ID: <1612777137-51067-9-git-send-email-yumeng18@huawei.com> (raw)
In-Reply-To: <1612777137-51067-1-git-send-email-yumeng18@huawei.com>

1. Add curve 25519 parameters;
2. Add curve25519 function 'ecc_get_curve25519_param', to make
   its parameters be exposed to everyone in kernel tree.

Signed-off-by: Meng Yu <yumeng18@huawei.com>
Reviewed-by: Zaibo Xu <xuzaibo@huawei.com>
---
 crypto/ecc.c               |  6 ++++++
 crypto/ecc_curve_defs.h    | 18 ++++++++++++++++++
 include/crypto/ecc_curve.h |  7 +++++++
 3 files changed, 31 insertions(+)

diff --git a/crypto/ecc.c b/crypto/ecc.c
index a631d3e..d8dbe7a 100644
--- a/crypto/ecc.c
+++ b/crypto/ecc.c
@@ -43,6 +43,12 @@ typedef struct {
 	u64 m_high;
 } uint128_t;
 
+/* Returns curv25519 curve param */
+const struct ecc_curve *ecc_get_curve25519(void)
+{
+	return &ecc_25519;
+}
+EXPORT_SYMBOL(ecc_get_curve25519);
 
 const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
 {
diff --git a/crypto/ecc_curve_defs.h b/crypto/ecc_curve_defs.h
index bcd7b58..f37eced 100644
--- a/crypto/ecc_curve_defs.h
+++ b/crypto/ecc_curve_defs.h
@@ -160,4 +160,22 @@ static struct ecc_curve nist_p521 = {
 	.b = nist_p521_b
 };
 
+/* curve25519 */
+static u64 curve25519_g_x[] = { 0x0000000000000009, 0x0000000000000000,
+				0x0000000000000000, 0x0000000000000000 };
+static u64 curve25519_p[] = { 0xffffffffffffffed, 0xffffffffffffffff,
+				0xffffffffffffffff, 0x7fffffffffffffff };
+static u64 curve25519_a[] = { 0x000000000001DB41, 0x0000000000000000,
+				0x0000000000000000, 0x0000000000000000 };
+static const struct ecc_curve ecc_25519 = {
+	.name = "curve25519",
+	.g = {
+		.x = curve25519_g_x,
+		.ndigits = 4,
+	},
+	.p = curve25519_p,
+	.a = curve25519_a,
+};
+
+
 #endif
diff --git a/include/crypto/ecc_curve.h b/include/crypto/ecc_curve.h
index 19a35da..7096478 100644
--- a/include/crypto/ecc_curve.h
+++ b/include/crypto/ecc_curve.h
@@ -50,4 +50,11 @@ struct ecc_curve {
  */
 const struct ecc_curve *ecc_get_curve(unsigned int curve_id);
 
+/**
+ * ecc_get_curve25519() - get curve25519 curve;
+ *
+ * Returns curve25519
+ */
+const struct ecc_curve *ecc_get_curve25519(void);
+
 #endif
-- 
2.8.1


  parent reply	other threads:[~2021-02-08  9:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08  9:38 [PATCH v8 0/9] add ECDH and CURVE25519 algorithms support for Kunpeng 930 Meng Yu
2021-02-08  9:38 ` [PATCH v8 1/9] crypto: hisilicon/hpre - add version adapt to new algorithms Meng Yu
2021-02-08  9:38 ` [PATCH v8 2/9] crypto: hisilicon/hpre - add algorithm type Meng Yu
2021-02-08  9:38 ` [PATCH v8 3/9] crypto: atmel-ecc - move curve_id of ECDH from the key to algorithm name Meng Yu
2021-02-10  4:56   ` Herbert Xu
2021-02-18  2:14     ` yumeng
2021-02-08  9:38 ` [PATCH v8 4/9] net/bluetooth: modify ECDH name in 'crypto_alloc_kpp' Meng Yu
2021-02-08  9:38 ` [PATCH v8 5/9] crypto: move curve_id of ECDH to algorithm name Meng Yu
2021-02-09  3:48   ` kernel test robot
2021-02-09  3:48     ` kernel test robot
2021-02-09  5:33   ` kernel test robot
2021-02-09  5:33     ` kernel test robot
2021-02-08  9:38 ` [PATCH v8 6/9] crypto: add new ecc curve and expose them Meng Yu
2021-02-08  9:38 ` [PATCH v8 7/9] crypto: hisilicon/hpre - add 'ECDH' algorithm Meng Yu
2021-02-10  4:57   ` Herbert Xu
2021-02-18  2:24     ` yumeng
2021-02-18 20:01       ` Herbert Xu
2021-02-19  1:25         ` yumeng
2021-02-19  4:01           ` Herbert Xu
2021-02-08  9:38 ` Meng Yu [this message]
2021-02-08  9:38 ` [PATCH v8 9/9] crypto: hisilicon/hpre - add 'CURVE25519' algorithm Meng Yu

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=1612777137-51067-9-git-send-email-yumeng18@huawei.com \
    --to=yumeng18@huawei.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=tudor.ambarus@microchip.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=xuzaibo@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.