ref: c9d55cadb36a6667d61d0001b0f7619c74431d4a
parent: d5992857bbb2947b46ddf7d451a40dcd3e31e0e4
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 29 22:15:40 EDT 2016
libsec: add secp384r1 curve parameters for tls
--- a/sys/include/libsec.h
+++ b/sys/include/libsec.h
@@ -535,6 +535,7 @@
/* curves */
void secp256r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
void secp256k1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
+void secp384r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h);
DigestState* ripemd160(uchar *, ulong, uchar *, DigestState *);
--- a/sys/src/libsec/port/mkfile
+++ b/sys/src/libsec/port/mkfile
@@ -33,9 +33,10 @@
ccpoly.c\
tsmemcmp.c\
secp256r1.c\
+ secp384r1.c\
secp256k1.c\
-CLEANFILES=secp256r1.c secp256k1.c jacobian.c
+CLEANFILES=secp256r1.c secp384r1.c secp256k1.c jacobian.c
ALLOFILES=${CFILES:%.c=%.$O}
--- /dev/null
+++ b/sys/src/libsec/port/secp384r1.mp
@@ -1,0 +1,10 @@
+# E: y² = x³ + ax + b
+secp384r1(p,a,b,x,y,n,h) {
+ p = 2^384 - 2^128 - 2^96 + 2^32 - 1;
+ a = p - 3;
+ b = 0xB3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF;
+ x = 0xAA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7;
+ y = 0x3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F;
+ n = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973;
+ h = 1;
+}
--- a/sys/src/libsec/port/tlshand.c
+++ b/sys/src/libsec/port/tlshand.c
@@ -350,6 +350,7 @@
static Namedcurve namedcurves[] = {
0x0017, secp256r1,
+ 0x0018, secp384r1,
};
static uchar pointformats[] = {
--- a/sys/src/libsec/port/x509.c
+++ b/sys/src/libsec/port/x509.c
@@ -1696,13 +1696,16 @@
};
static Ints15 oid_secp256r1 = {7, 1, 2, 840, 10045, 3, 1, 7};
+static Ints15 oid_secp384r1 = {5, 1, 3, 132, 0, 34};
static Ints *namedcurves_oid_tab[] = {
(Ints*)&oid_secp256r1,
+ (Ints*)&oid_secp384r1,
nil,
};
static void (*namedcurves[])(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h) = {
secp256r1,
+ secp384r1,
nil,
};