shithub: drawterm

Download patch

ref: 368599deabba0aa9d18b05ffc0b6a87d1fc7d22a
parent: 4eeb8bcb3cbcd28752a8c0621bc5e0d6c2db5bb4
author: glenda <[email protected]>
date: Sat Jun 19 11:07:14 EDT 2021

libsec: add curve25519 and adjust ECpriv point access

--- a/libsec/Makefile
+++ b/libsec/Makefile
@@ -7,6 +7,7 @@
 	poly1305.$O chacha.$O chachablock.$O ccpoly.$O\
 	des.$O des3CBC.$O desmodes.$O\
 	ecc.$O jacobian.$O secp256k1.$O secp256r1.$O secp384r1.$O\
+	curve25519.$O curve25519_dh.$O\
 	genrandom.$O fastrand.$O nfastrand.$O prng.$O\
 	hmac.$O hkdf.$O pbkdf2.$O\
 	rsaalloc.$O rsadecrypt.$O rsaencrypt.$O\
--- a/libsec/tlshand.c
+++ b/libsec/tlshand.c
@@ -990,8 +990,8 @@
 			return nil;
 
 		memset(Q, 0, sizeof(*Q));
-		Q->x = mpnew(0);
-		Q->y = mpnew(0);
+		Q->a.x = mpnew(0);
+		Q->a.y = mpnew(0);
 		Q->d = mpnew(0);
 
 		memset(&K, 0, sizeof(K));
@@ -1004,7 +1004,7 @@
 		n = (mpsignif(dom->p)+7)/8;
 		setMasterSecret(sec, mptobytes(K.x, n));
 		Yc = newbytes(1 + 2*n);
-		Yc->len = ecencodepub(dom, Q, Yc->data, Yc->len);
+		Yc->len = ecencodepub(dom, &Q->a, Yc->data, Yc->len);
 
 		mpfree(K.x);
 		mpfree(K.y);
@@ -2084,8 +2084,8 @@
 
 	dh_finish(&c->sec->dh, nil);
 
-	mpfree(c->sec->ec.Q.x);
-	mpfree(c->sec->ec.Q.y);
+	mpfree(c->sec->ec.Q.a.x);
+	mpfree(c->sec->ec.Q.a.y);
 	mpfree(c->sec->ec.Q.d);
 	ecdomfree(&c->sec->ec.dom);
 
@@ -2559,8 +2559,8 @@
 	}else{
 		ecdominit(dom, sec->nc->init);
 		memset(Q, 0, sizeof(*Q));
-		Q->x = mpnew(0);
-		Q->y = mpnew(0);
+		Q->a.x = mpnew(0);
+		Q->a.y = mpnew(0);
 		Q->d = mpnew(0);
 		ecgen(dom, Q);
 		n = 1 + 2*((mpsignif(dom->p)+7)/8);
@@ -2567,7 +2567,7 @@
 		par = newbytes(1+2+1+n);
 		par->data[0] = 3;
 		put16(par->data+1, sec->nc->tlsid);
-		n = ecencodepub(dom, Q, par->data+4, par->len-4);
+		n = ecencodepub(dom, &Q->a, par->data+4, par->len-4);
 		par->data[3] = n;
 		par->len = 1+2+1+n;
 	}