ref: 69fab298beee33e4a6f91d9e1811dfa1898aa743
parent: 62a8bf184668a071f5113f73d0d4082d8d0ee556
author: aiju <aiju@phicode.de>
date: Sat Sep 13 15:46:41 EDT 2014
libsec: ecgen() and ecdsasign() fix
--- a/sys/src/libsec/port/ecc.c
+++ b/sys/src/libsec/port/ecc.c
@@ -397,10 +397,10 @@
p = mallocz(sizeof(*p), 1);
if(p == nil)
return nil;
+ p->x = mpnew(0);
+ p->y = mpnew(0);
+ p->d = mpnew(0);
}
- p->x = mpnew(0);
- p->y = mpnew(0);
- p->d = mpnew(0);
for(;;){
mprand(mpsignif(dom->n), genrandom, p->d);
if(mpcmp(p->d, mpzero) > 0 && mpcmp(p->d, dom->n) < 0)
@@ -418,6 +418,7 @@
tmp.x = mpnew(0);
tmp.y = mpnew(0);
+ tmp.d = mpnew(0);
E = betomp(dig, len, nil);
t = mpnew(0);
if(mpsignif(dom->n) < 8*len)
@@ -439,6 +440,7 @@
mpfree(E);
mpfree(tmp.x);
mpfree(tmp.y);
+ mpfree(tmp.d);
}
int