diff mbox series

[v9,6/9] crypto: Add NIST P384 curve parameters

Message ID 20210225160802.2478700-7-stefanb@linux.vnet.ibm.com
State New
Headers show
Series Add support for x509 certs with NIST P384/256/192 keys | expand

Commit Message

Stefan Berger Feb. 25, 2021, 4:07 p.m. UTC
From: Saulo Alessandre <saulo.alessandre@tse.jus.br>

* crypto/ecc_curve_defs.h
  - add nist_p384 params

* include/crypto/ecdh.h
  - add ECC_CURVE_NIST_P384

Signed-off-by: Saulo Alessandre <saulo.alessandre@tse.jus.br>
Tested-by: Stefan Berger <stefanb@linux.ibm.com>
---
 crypto/ecc_curve_defs.h | 32 ++++++++++++++++++++++++++++++++
 include/crypto/ecdh.h   |  1 +
 2 files changed, 33 insertions(+)

Comments

Herbert Xu March 4, 2021, 5:28 a.m. UTC | #1
On Thu, Feb 25, 2021 at 11:07:59AM -0500, Stefan Berger wrote:
> From: Saulo Alessandre <saulo.alessandre@tse.jus.br>

> 

> * crypto/ecc_curve_defs.h

>   - add nist_p384 params

> 

> * include/crypto/ecdh.h

>   - add ECC_CURVE_NIST_P384

> 

> Signed-off-by: Saulo Alessandre <saulo.alessandre@tse.jus.br>

> Tested-by: Stefan Berger <stefanb@linux.ibm.com>

> ---

>  crypto/ecc_curve_defs.h | 32 ++++++++++++++++++++++++++++++++

>  include/crypto/ecdh.h   |  1 +

>  2 files changed, 33 insertions(+)


Can you reorder the patches so that the crypto patches come first
and then I can apply them?

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Stefan Berger March 4, 2021, 1:59 p.m. UTC | #2
On 3/4/21 12:28 AM, Herbert Xu wrote:
> On Thu, Feb 25, 2021 at 11:07:59AM -0500, Stefan Berger wrote:
>> From: Saulo Alessandre <saulo.alessandre@tse.jus.br>
>>
>> * crypto/ecc_curve_defs.h
>>    - add nist_p384 params
>>
>> * include/crypto/ecdh.h
>>    - add ECC_CURVE_NIST_P384
>>
>> Signed-off-by: Saulo Alessandre <saulo.alessandre@tse.jus.br>
>> Tested-by: Stefan Berger <stefanb@linux.ibm.com>
>> ---
>>   crypto/ecc_curve_defs.h | 32 ++++++++++++++++++++++++++++++++
>>   include/crypto/ecdh.h   |  1 +
>>   2 files changed, 33 insertions(+)
> Can you reorder the patches so that the crypto patches come first
> and then I can apply them?

Yes, sounds good.

Are you going to take the other patches as well, except for maybe 9/9, 
which depends on Nayan's patch series. Mimi suggested to me to ask you 
whether you could create a topic branch where we can apply other patches 
to, such as Nayna's?

The NIST P384 patch temporarily introduces this warning, which goes away 
when the immediately following patch (current 7/9) is applied. Is this 
an issue or should I squash Saulo's patches or put the top hunk from 7/9 
into 6/9?


In file included from crypto/ecc.c:38:
crypto/ecc_curve_defs.h:76:25: warning: ?nist_p384? defined but not used 
[-Wunused-variable]
    76 | static struct ecc_curve nist_p384 = {
       |                         ^~~~~~~~~

    Stefan


>
> Thanks,
Herbert Xu March 4, 2021, 10:31 p.m. UTC | #3
On Thu, Mar 04, 2021 at 08:59:36AM -0500, Stefan Berger wrote:
>
> Are you going to take the other patches as well, except for maybe 9/9, which
> depends on Nayan's patch series. Mimi suggested to me to ask you whether you
> could create a topic branch where we can apply other patches to, such as
> Nayna's?

Yes I can do a topic branch.  Please let me know which patches
I should take when you resubmit.

Thanks,
diff mbox series

Patch

diff --git a/crypto/ecc_curve_defs.h b/crypto/ecc_curve_defs.h
index 69be6c7d228f..b327732f6ef5 100644
--- a/crypto/ecc_curve_defs.h
+++ b/crypto/ecc_curve_defs.h
@@ -54,4 +54,36 @@  static struct ecc_curve nist_p256 = {
 	.b = nist_p256_b
 };
 
+/* NIST P-384 */
+static u64 nist_p384_g_x[] = { 0x3A545E3872760AB7ull, 0x5502F25DBF55296Cull,
+				0x59F741E082542A38ull, 0x6E1D3B628BA79B98ull,
+				0x8Eb1C71EF320AD74ull, 0xAA87CA22BE8B0537ull };
+static u64 nist_p384_g_y[] = { 0x7A431D7C90EA0E5Full, 0x0A60B1CE1D7E819Dull,
+				0xE9DA3113B5F0B8C0ull, 0xF8F41DBD289A147Cull,
+				0x5D9E98BF9292DC29ull, 0x3617DE4A96262C6Full };
+static u64 nist_p384_p[] = { 0x00000000FFFFFFFFull, 0xFFFFFFFF00000000ull,
+				0xFFFFFFFFFFFFFFFEull, 0xFFFFFFFFFFFFFFFFull,
+				0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFFFFFFFFFFull };
+static u64 nist_p384_n[] = { 0xECEC196ACCC52973ull, 0x581A0DB248B0A77Aull,
+				0xC7634D81F4372DDFull, 0xFFFFFFFFFFFFFFFFull,
+				0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFFFFFFFFFFull };
+static u64 nist_p384_a[] = { 0x00000000FFFFFFFCull, 0xFFFFFFFF00000000ull,
+				0xFFFFFFFFFFFFFFFEull, 0xFFFFFFFFFFFFFFFFull,
+				0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFFFFFFFFFFull };
+static u64 nist_p384_b[] = { 0x2a85c8edd3ec2aefull, 0xc656398d8a2ed19dull,
+				0x0314088f5013875aull, 0x181d9c6efe814112ull,
+				0x988e056be3f82d19ull, 0xb3312fa7e23ee7e4ull };
+static struct ecc_curve nist_p384 = {
+	.name = "nist_384",
+	.g = {
+		.x = nist_p384_g_x,
+		.y = nist_p384_g_y,
+		.ndigits = 6,
+	},
+	.p = nist_p384_p,
+	.n = nist_p384_n,
+	.a = nist_p384_a,
+	.b = nist_p384_b
+};
+
 #endif
diff --git a/include/crypto/ecdh.h b/include/crypto/ecdh.h
index a5b805b5526d..e4ba1de961e4 100644
--- a/include/crypto/ecdh.h
+++ b/include/crypto/ecdh.h
@@ -25,6 +25,7 @@ 
 /* Curves IDs */
 #define ECC_CURVE_NIST_P192	0x0001
 #define ECC_CURVE_NIST_P256	0x0002
+#define ECC_CURVE_NIST_P384	0x0003
 
 /**
  * struct ecdh - define an ECDH private key