From: Meng Yu <yumeng18@huawei.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <linux-crypto@vger.kernel.org>, <xuzaibo@huawei.com>,
<wangzhou1@hisilicon.com>, <yumeng18@huawei.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH v7 5/7] crypto: add curve 25519 and expose them
Date: Fri, 22 Jan 2021 15:09:53 +0800 [thread overview]
Message-ID: <1611299395-675-6-git-send-email-yumeng18@huawei.com> (raw)
In-Reply-To: <1611299395-675-1-git-send-email-yumeng18@huawei.com>
1. Add curve 25519 parameters;
2. Add curve25519 function 'ecc_get_curve25519_param',
to 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 | 7 +++++++
crypto/ecc_curve_defs.h | 17 +++++++++++++++++
include/crypto/ecc_curve.h | 7 +++++++
3 files changed, 31 insertions(+)
diff --git a/crypto/ecc.c b/crypto/ecc.c
index cfa1dc3..025b5e6e 100644
--- a/crypto/ecc.c
+++ b/crypto/ecc.c
@@ -53,6 +53,13 @@ const struct ecc_curve *ecc_get_curve_by_id(unsigned int curve_id)
}
EXPORT_SYMBOL(ecc_get_curve_by_id);
+/* Returns curv25519 curve param */
+const struct ecc_curve *ecc_get_curve25519(void)
+{
+ return &ecc_25519;
+}
+EXPORT_SYMBOL(ecc_get_curve25519);
+
static inline const struct ecc_curve *ecc_get_curve(unsigned int curve_id)
{
switch (curve_id) {
diff --git a/crypto/ecc_curve_defs.h b/crypto/ecc_curve_defs.h
index b81e580..91b3d4b 100644
--- a/crypto/ecc_curve_defs.h
+++ b/crypto/ecc_curve_defs.h
@@ -160,4 +160,21 @@ static const struct ecc_curve ecc_curve_list[] = {
}
};
+/* 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 a3adf1e..2d22647 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_by_id(unsigned int curve_id);
+/**
+ * ecc_get_curve25519() - get curve25519 curve;
+ *
+ * Returns curve25519
+ */
+const struct ecc_curve *ecc_get_curve25519(void);
+
#endif
\ No newline at end of file
--
2.8.1
next prev parent reply other threads:[~2021-01-22 7:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-22 7:09 [PATCH v7 0/7] add ECDH and CURVE25519 algorithms support for Kunpeng 930 Meng Yu
2021-01-22 7:09 ` [PATCH v7 1/7] crypto: hisilicon/hpre - add version adapt to new algorithms Meng Yu
2021-01-22 7:09 ` [PATCH v7 2/7] crypto: hisilicon/hpre - add some updates to adapt to Kunpeng 930 Meng Yu
2021-01-22 7:09 ` [PATCH v7 3/7] crypto: hisilicon/hpre - add algorithm type Meng Yu
2021-01-22 7:09 ` [PATCH v7 4/7] crypto: add ecc curve and expose them Meng Yu
2021-01-28 5:03 ` Herbert Xu
2021-01-28 10:30 ` Ard Biesheuvel
2021-01-28 10:39 ` Herbert Xu
2021-02-01 17:09 ` Daniele Alessandrelli
2021-02-02 5:13 ` Herbert Xu
2021-02-02 9:27 ` Alessandrelli, Daniele
2021-02-02 9:42 ` Herbert Xu
2021-02-02 12:35 ` Alessandrelli, Daniele
2021-02-04 5:31 ` Herbert Xu
2021-01-29 2:49 ` Stefan Berger
2021-01-29 3:00 ` Herbert Xu
2021-02-08 6:35 ` Vitaly Chikunov
2021-02-08 6:47 ` Ard Biesheuvel
2021-02-08 21:27 ` Vitaly Chikunov
2021-02-01 3:45 ` yumeng
2021-02-03 18:03 ` Saulo Alessandre
2021-02-04 5:41 ` Herbert Xu
2021-01-22 7:09 ` Meng Yu [this message]
2021-01-22 7:09 ` [PATCH v7 6/7] crypto: hisilicon/hpre - add 'ECDH' algorithm Meng Yu
2021-01-22 7:09 ` [PATCH v7 7/7] 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=1611299395-675-6-git-send-email-yumeng18@huawei.com \
--to=yumeng18@huawei.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®