From dfcd749bbb273c6638174cdf640216c56786a7e6 Mon Sep 17 00:00:00 2001 From: jbj Date: Fri, 23 May 2003 16:32:16 +0000 Subject: [PATCH] Spliddles. CVS patchset: 6873 CVS date: 2003/05/23 16:32:16 --- beecrypt/dsa.c | 2 ++ beecrypt/mp.c | 20 ++++++++++---------- beecrypt/mp.h | 6 +++++- beecrypt/mpnumber.c | 3 ++- beecrypt/rsakp.c | 2 +- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/beecrypt/dsa.c b/beecrypt/dsa.c index c8222d6..51a1b0c 100644 --- a/beecrypt/dsa.c +++ b/beecrypt/dsa.c @@ -150,7 +150,9 @@ int dsavrfy(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, const mpn mpsetx(qsize, qtemp+qsize, s->size, s->data); /* compute w = inv(s) mod q */ +/*@-compdef@*/ /* FIX: mpsetx annotations, qtemp[qsize] is defined */ if (mpextgcd_w(qsize, qtemp+qsize, q->modl, qtemp, qwksp)) +/*@=compdef@*/ { /* compute u1 = h(m)*w mod q */ mpbmulmod_w(q, hm->size, hm->data, qsize, qtemp, qtemp+qsize, qwksp); diff --git a/beecrypt/mp.c b/beecrypt/mp.c index 2369e63..f95339a 100644 --- a/beecrypt/mp.c +++ b/beecrypt/mp.c @@ -1199,8 +1199,8 @@ int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ndata, mpw* result, mpw if ((full && mpodd(sizep, adata)) || mpodd(sizep, bdata)) { - if (full) mpaddx(sizep, adata, size, xdata); - mpsubx(sizep, bdata, size, ndata); + if (full) (void) mpaddx(sizep, adata, size, xdata); + (void) mpsubx(sizep, bdata, size, ndata); } if (full) mpsdivtwo(sizep, adata); @@ -1212,8 +1212,8 @@ int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ndata, mpw* result, mpw if ((full && mpodd(sizep, cdata)) || mpodd(sizep, ddata)) { - if (full) mpaddx(sizep, cdata, size, xdata); - mpsubx(sizep, ddata, size, ndata); + if (full) (void) mpaddx(sizep, cdata, size, xdata); + (void) mpsubx(sizep, ddata, size, ndata); } if (full) mpsdivtwo(sizep, cdata); @@ -1221,15 +1221,15 @@ int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ndata, mpw* result, mpw } if (mpge(sizep, udata, vdata)) { - mpsub(sizep, udata, vdata); - if (full) mpsub(sizep, adata, cdata); - mpsub(sizep, bdata, ddata); + (void) mpsub(sizep, udata, vdata); + if (full) (void) mpsub(sizep, adata, cdata); + (void) mpsub(sizep, bdata, ddata); } else { - mpsub(sizep, vdata, udata); - if (full) mpsub(sizep, cdata, adata); - mpsub(sizep, ddata, bdata); + (void) mpsub(sizep, vdata, udata); + if (full) (void) mpsub(sizep, cdata, adata); + (void) mpsub(sizep, ddata, bdata); } if (mpz(sizep, udata)) { diff --git a/beecrypt/mp.h b/beecrypt/mp.h index c1c6ed5..4eb7b37 100644 --- a/beecrypt/mp.h +++ b/beecrypt/mp.h @@ -580,9 +580,11 @@ void mpdivtwo (size_t size, mpw* data) /** */ +/*@-exportlocal@*/ BEECRYPTAPI void mpsdivtwo(size_t size, mpw* data) /*@modifies data @*/; +/*@=exportlocal@*/ /** * This function performs a multi-precision multiply-setup. @@ -652,7 +654,7 @@ void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, /*@out@*/ mpw* res /** */ BEECRYPTAPI -int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, /*@out@*/ mpw* result, /*@out@*/ mpw* wksp) +int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ndata, /*@out@*/ mpw* result, /*@out@*/ mpw* wksp) /*@modifies result, wksp @*/; /** @@ -704,10 +706,12 @@ void mpfprint(/*@null@*/ FILE * f, size_t size, /*@null@*/ const mpw* data) /** */ +/*@-exportlocal@*/ BEECRYPTAPI void mpfprintln(/*@null@*/ FILE * f, size_t size, /*@null@*/ const mpw* data) /*@globals fileSystem @*/ /*@modifies *f, fileSystem @*/; +/*@=exportlocal@*/ /** */ diff --git a/beecrypt/mpnumber.c b/beecrypt/mpnumber.c index 4632470..0295e56 100644 --- a/beecrypt/mpnumber.c +++ b/beecrypt/mpnumber.c @@ -186,10 +186,11 @@ int mpninv(mpnumber* inv, const mpnumber* k, const mpnumber* mod) { int rc = 0; size_t size = mod->size; - mpw* wksp = (mpw*) malloc((7*size+6) * sizeof(mpw)); + mpw* wksp = (mpw*) malloc((7*size+6) * sizeof(*wksp)); if (wksp) { + mpnzero(inv); mpnsize(inv, size); mpsetx(size, wksp, k->size, k->data); rc = mpextgcd_w(size, wksp, mod->data, inv->data, wksp+size); diff --git a/beecrypt/rsakp.c b/beecrypt/rsakp.c index 89ac251..6da864f 100644 --- a/beecrypt/rsakp.c +++ b/beecrypt/rsakp.c @@ -118,7 +118,7 @@ int rsakpMake(rsakp* kp, randomGeneratorContext* rgc, size_t nsize) /*@-usedef@*/ /* psubone/qsubone are set */ /* compute phi = (p-1)*(q-1) */ mpmul(temp, pqsize, psubone.modl, pqsize, qsubone.modl); - mpbset(&phi, nsize, temp); + mpnset(&phi, nsize, temp); /* compute d = inv(e) mod phi */ (void) mpninv(&kp->d, &kp->e, &phi); -- 2.7.4