/* -*-c-*-
*
- * $Id: dsa-verify.c,v 1.4 2000/06/17 10:53:35 mdw Exp $
+ * $Id: dsa-verify.c,v 1.5 2000/10/08 12:13:17 mdw Exp $
*
* DSA signature verification
*
/*----- Revision history --------------------------------------------------*
*
* $Log: dsa-verify.c,v $
+ * Revision 1.5 2000/10/08 12:13:17 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.4 2000/06/17 10:53:35 mdw
* Typesetting fixes.
*
f[1].base = y;
w = mpmont_mexp(&pm, MP_NEW, f, 2);
mp_div(0, &w, w, dp->q);
- ok = MP_CMP(w, ==, r);
+ ok = MP_EQ(w, r);
/* --- Tidy up --- */
/* -*-c-*-
*
- * $Id: mpcrt.c,v 1.2 1999/12/10 23:22:32 mdw Exp $
+ * $Id: mpcrt.c,v 1.3 2000/10/08 12:11:22 mdw Exp $
*
* Chinese Remainder Theorem computations (Gauss's algorithm)
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpcrt.c,v $
+ * Revision 1.3 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.2 1999/12/10 23:22:32 mdw
* Interface changes for suggested destinations. Use Barrett reduction.
*
mpcrt_create(&c, m, n, 0);
b = mpcrt_solve(&c, MP_NEW, r);
- if (MP_CMP(a, !=, b)) {
+ if (!MP_EQ(a, b)) {
fputs("\n*** failed\n", stderr);
fputs("n = ", stderr);
mp_writefile(c.mb.m, stderr, 10);
/* -*-c-*-
*
- * $Id: mpint.c,v 1.2 1999/12/10 23:22:53 mdw Exp $
+ * $Id: mpint.c,v 1.3 2000/10/08 12:11:22 mdw Exp $
*
* Conversion between MPs and standard C integers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpint.c,v $
+ * Revision 1.3 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.2 1999/12/10 23:22:53 mdw
* Support for uint32.
*
mp *d = mp_fromuint(MP_NEW, i);
int ok = 1;
- if (MP_CMP(d, !=, m)) {
+ if (!MP_EQ(d, m)) {
fputs("\n*** fromint failed.\n", stderr);
fprintf(stderr, "i = %lu", i);
fputs("\nexpect = ", stderr); mp_writefile(m, stderr, 10);
mp *d = mp_fromint(MP_NEW, i);
int ok = 1;
- if (MP_CMP(d, !=, m)) {
+ if (!MP_EQ(d, m)) {
fputs("\n*** fromint failed.\n", stderr);
fprintf(stderr, "i = %li", i);
fputs("\nexpect = ", stderr); mp_writefile(m, stderr, 10);
/* -*-c-*-
*
- * $Id: mpmont-mexp.c,v 1.4 2000/06/17 11:45:09 mdw Exp $
+ * $Id: mpmont-mexp.c,v 1.5 2000/10/08 12:11:22 mdw Exp $
*
* Multiple simultaneous exponentiations
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpmont-mexp.c,v $
+ * Revision 1.5 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.4 2000/06/17 11:45:09 mdw
* Major memory management overhaul. Added arena support. Use the secure
* arena for secret integers. Replace and improve the MP management macros
rr = *(mp **)v[j].buf;
mpmont_create(&mm, m);
r = mpmont_mexp(&mm, MP_NEW, f, n);
- if (MP_CMP(r, !=, rr)) {
+ if (!MP_EQ(r, rr)) {
fputs("\n*** mexp failed\n", stderr);
fputs("m = ", stderr); mp_writefile(m, stderr, 10);
for (i = 0; i < n; i++) {
/* -*-c-*-
*
- * $Id: mpmul.c,v 1.2 2000/07/09 21:31:10 mdw Exp $
+ * $Id: mpmul.c,v 1.3 2000/10/08 12:11:22 mdw Exp $
*
* Multiply many small numbers together
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpmul.c,v $
+ * Revision 1.3 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.2 2000/07/09 21:31:10 mdw
* Fix bug, and add a test rig.
*
mp *fx = *(mp **)v[1].buf;
mp *y = mp_factorial(x);
int ok = 1;
- if (MP_CMP(fx, !=, y)) {
+ if (!MP_EQ(fx, y)) {
fprintf(stderr, "factorial failed\n");
MP_FPRINTF(stderr, (stderr, "%lu! = ", x), fx);
MP_EPRINT("result", y);
/* -*-c-*-
*
- * $Id: pgen.c,v 1.5 2000/06/17 11:52:36 mdw Exp $
+ * $Id: pgen.c,v 1.6 2000/10/08 12:11:22 mdw Exp $
*
* Prime generation glue
*
/*----- Revision history --------------------------------------------------*
*
* $Log: pgen.c,v $
+ * Revision 1.6 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.5 2000/06/17 11:52:36 mdw
* Signal a pgen abort if the jump and base share a common factor.
*
pf.step = 2;
p = pgen("p", MP_NEW, m, pgen_evspin, 0, 0, pgen_filter, &pf,
rabin_iters(mp_bits(m)), pgen_test, &r);
- if (!p || MP_CMP(p, !=, q)) {
+ if (!p || !MP_EQ(p, q)) {
fputs("\n*** pgen failed", stderr);
fputs("\nm = ", stderr); mp_writefile(m, stderr, 10);
fputs("\np = ", stderr); mp_writefile(p, stderr, 10);
/* -*-c-*-
*
- * $Id: prim.c,v 1.2 2000/07/29 09:57:42 mdw Exp $
+ * $Id: prim.c,v 1.3 2000/10/08 12:11:22 mdw Exp $
*
* Finding primitive elements
*
/*----- Revision history --------------------------------------------------*
*
* $Log: prim.c,v $
+ * Revision 1.3 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.2 2000/07/29 09:57:42 mdw
* Improve primitive-element testing a lot. Now much more sensible and
* orthogonal: you can find a generator for any given subgroup order by
x = mp_copy(ev->m);
else {
x = mpmont_exp(&c->mm, MP_NEW, ev->m, c->exp);
- if (MP_CMP(x, ==, MP_ONE))
+ if (MP_EQ(x, MP_ONE))
goto done;
}
if (c->n == 0)
mp *y = MP_NEW;
while (n) {
y = mpmont_exp(&c->mm, y, x, *f);
- if (MP_CMP(y, ==, MP_ONE)) {
+ if (MP_EQ(y, MP_ONE)) {
mp_drop(y);
goto done;
}
/* -*-c-*-
*
- * $Id: rabin.c,v 1.4 2000/06/22 19:03:02 mdw Exp $
+ * $Id: rabin.c,v 1.5 2000/10/08 12:11:22 mdw Exp $
*
* Miller-Rabin primality test
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rabin.c,v $
+ * Revision 1.5 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.4 2000/06/22 19:03:02 mdw
* Use the new @mp_odd@ function.
*
*/
y = mpmont_expr(&r->mm, MP_NEW, g, r->r);
- if (MP_CMP(y, ==, r->mm.r) || MP_CMP(y, ==, r->m1)) {
+ if (MP_EQ(y, r->mm.r) || MP_EQ(y, r->m1)) {
rc = PGEN_PASS;
goto done;
}
dd = mp_sqr(spare, y);
dd = mpmont_reduce(&r->mm, dd, dd);
spare = y; y = dd;
- if (MP_CMP(y, ==, r->mm.r))
+ if (MP_EQ(y, r->mm.r))
break;
- if (MP_CMP(y, ==, r->m1)) {
+ if (MP_EQ(y, r->m1)) {
rc = PGEN_PASS;
break;
}
/* -*-c-*-
*
- * $Id: rho.c,v 1.1 2000/07/09 21:32:30 mdw Exp $
+ * $Id: rho.c,v 1.2 2000/10/08 12:11:22 mdw Exp $
*
* Pollard's rho algorithm for discrete logs
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rho.c,v $
+ * Revision 1.2 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.1 2000/07/09 21:32:30 mdw
* Pollard's rho algorithm for computing discrete logs.
*
bb = mp_sub(bb, bb, b);
g = MP_NEW;
mp_gcd(&g, &bb, 0, bb, cc->n);
- if (MP_CMP(g, !=, MP_ONE)) {
+ if (!MP_EQ(g, MP_ONE)) {
mp_drop(aa);
aa = 0;
} else {
static int prime_eq(void *x, void *y)
{
- return (MP_CMP(*(mp **)x, ==, *(mp **)y));
+ return (MP_EQ(*(mp **)x, *(mp **)y));
}
static int prime_split(void *x)
y = mpmont_exp(&mm, MP_NEW, dp.g, x);
mpmont_destroy(&mm);
l = rho_prime(dp.g, y, dp.q, dp.p);
- if (MP_CMP(x, ==, l)) {
+ if (MP_EQ(x, l)) {
fputs(". ok\n", stdout);
ok = 1;
} else {
/* -*-c-*-
*
- * $Id: rsa-gen.c,v 1.3 2000/07/01 11:22:22 mdw Exp $
+ * $Id: rsa-gen.c,v 1.4 2000/10/08 12:11:22 mdw Exp $
*
* RSA parameter generation
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rsa-gen.c,v $
+ * Revision 1.4 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.3 2000/07/01 11:22:22 mdw
* Remove bad type name `rsa_param'.
*
*/
mp_gcd(&g.g, 0, &rp->d, phi, rp->e);
- if (MP_CMP(g.g, !=, MP_ONE) && MP_LEN(rp->d) * 4 > MP_LEN(rp->n) * 3)
+ if (!MP_EQ(g.g, MP_ONE) && MP_LEN(rp->d) * 4 > MP_LEN(rp->n) * 3)
goto fail_e;
/* --- Work out exponent residues --- */
/* -*-c-*-
*
- * $Id: rsa-priv.c,v 1.1 2000/07/01 11:23:20 mdw Exp $
+ * $Id: rsa-priv.c,v 1.2 2000/10/08 12:11:22 mdw Exp $
*
* RSA private-key operations
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rsa-priv.c,v $
+ * Revision 1.2 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.1 2000/07/01 11:23:20 mdw
* Renamed from `rsa-decrypt', since the name was no longer appropriate.
* Add functions for doing padded RSA decryption and signing.
do {
k = mprand_range(k, rp->n, rd->r, 0);
mp_gcd(&g, 0, &ki, rp->n, k);
- } while (MP_CMP(g, !=, MP_ONE));
+ } while (!MP_EQ(g, MP_ONE));
k = mpmont_expr(&rd->nm, k, k, rp->e);
c = mpmont_mul(&rd->nm, c, c, k);
mp_drop(k);
/* --- Sort out some space --- */
dstr_ensure(d, n);
- p = d->buf + d->len;
+ p = (octet *)d->buf + d->len;
p[0] = 0;
/* --- Do the packing --- */
/* -*-c-*-
*
- * $Id: rsa-recover.c,v 1.4 2000/07/01 11:22:22 mdw Exp $
+ * $Id: rsa-recover.c,v 1.5 2000/10/08 12:11:22 mdw Exp $
*
* Recover RSA parameters
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rsa-recover.c,v $
+ * Revision 1.5 2000/10/08 12:11:22 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.4 2000/07/01 11:22:22 mdw
* Remove bad type name `rsa_param'.
*
mp_div(&rp->q, &r, rp->n, rp->p);
else
mp_div(&rp->p, &r, rp->n, rp->q);
- if (MP_CMP(r, !=, MP_ZERO)) {
+ if (!MP_EQ(r, MP_ZERO)) {
mp_drop(r);
return (-1);
}
aw = primetab[i++];
z = mpmont_expr(&mm, z, &a, t);
- if (MP_CMP(z, ==, mm.r) || MP_CMP(z, ==, m1))
+ if (MP_EQ(z, mm.r) || MP_EQ(z, m1))
continue;
/* --- Now square until something interesting happens --- *
for (;;) {
mp *zz = mp_sqr(MP_NEW, z);
zz = mpmont_reduce(&mm, zz, zz);
- if (MP_CMP(zz, ==, mm.r)) {
+ if (MP_EQ(zz, mm.r)) {
mp_drop(zz);
goto done;
- } else if (MP_CMP(zz, ==, m1)) {
+ } else if (MP_EQ(zz, m1)) {
mp_drop(zz);
goto again;
}
}
mp_drop(phi);
- if (MP_CMP(g, !=, MP_ONE)) {
+ if (!MP_EQ(g, MP_ONE)) {
mp_drop(g);
return (-1);
}
/* -*-c-*-
*
- * $Id: share.c,v 1.3 2000/06/24 18:29:05 mdw Exp $
+ * $Id: share.c,v 1.4 2000/10/08 12:16:17 mdw Exp $
*
* Shamir's secret sharing
*
/*----- Revision history --------------------------------------------------*
*
* $Log: share.c,v $
+ * Revision 1.4 2000/10/08 12:16:17 mdw
+ * Use @MP_EQ@ instead of @MP_CMP@.
+ *
* Revision 1.3 2000/06/24 18:29:05 mdw
* Interface change: allow shares to be extracted from a context on demand,
* rather than building them all up-front.
ss = share_combine(&s);
share_destroy(&s);
- if (MP_CMP(sec, !=, ss)) {
+ if (!MP_EQ(sec, ss)) {
ok = 0;
fprintf(stderr, "\nbad recombination of shares\n");
};