shithub: drawterm-fdroid

Download patch

ref: fbff9598dc0291fde22776360dc8df2383ddda80
parent: e33e667369270ef94daaacd5461e28ee4b57d34d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 30 10:14:21 EDT 2016

libsec: add secp384r1 curve parameters for tls

--- a/include/libsec.h
+++ b/include/libsec.h
@@ -529,6 +529,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/libsec/Makefile
+++ b/libsec/Makefile
@@ -60,6 +60,7 @@
 	salsa.$O\
 	secp256k1.$O\
 	secp256r1.$O\
+	secp384r1.$O\
 	sha1.$O\
 	sha1pickle.$O\
 	sha2_128.$O\
--- /dev/null
+++ b/libsec/secp384r1.c
@@ -1,0 +1,12 @@
+#include "os.h"
+#include <mp.h>
+void secp384r1(mpint *p, mpint *a, mpint *b, mpint *x, mpint *y, mpint *n, mpint *h){
+	strtomp("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF", nil, 16, p);
+	uitomp(3UL, a);
+	mpsub(p, a, a);
+	strtomp("B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF", nil, 16, b);
+	strtomp("AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7", nil, 16, x);
+	strtomp("3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F", nil, 16, y);
+	strtomp("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973", nil, 16, n);
+	mpassign(mpone, h);
+	}
--- a/libsec/tlshand.c
+++ b/libsec/tlshand.c
@@ -350,6 +350,7 @@
 
 static Namedcurve namedcurves[] = {
 	0x0017, secp256r1,
+	0x0018, secp384r1,
 };
 
 static uchar pointformats[] = {
--- a/libsec/x509.c
+++ b/libsec/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,
 };