From 4b536f423c90ba7ca41d3f95f31b17729152a403 Mon Sep 17 00:00:00 2001 From: mdw Date: Sun, 8 Oct 2000 12:02:21 +0000 Subject: [PATCH] Use @MP_EQ@ instead of @MP_CMP@. --- keyutil.c | 7 +++++-- mp-arith.c | 18 +++++++++++++++--- mp-modsqrt.c | 11 +++++++---- mp-sqrt.c | 7 +++++-- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/keyutil.c b/keyutil.c index ad438ce..174bbfe 100644 --- a/keyutil.c +++ b/keyutil.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: keyutil.c,v 1.9 2000/08/15 21:40:49 mdw Exp $ + * $Id: keyutil.c,v 1.10 2000/10/08 12:02:21 mdw Exp $ * * Simple key manager program * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: keyutil.c,v $ + * Revision 1.10 2000/10/08 12:02:21 mdw + * Use @MP_EQ@ instead of @MP_CMP@. + * * Revision 1.9 2000/08/15 21:40:49 mdw * Minor formatting change in listing attributes. * @@ -425,7 +428,7 @@ static void alg_rsa(keyopts *k) c = rsa_qpubop(&rpp, MP_NEW, m); c = rsa_qprivop(&rp, c, c, g); - if (MP_CMP(c, !=, m)) + if (!MP_EQ(c, m)) die(EXIT_FAILURE, "test encryption failed"); mp_drop(c); mp_drop(m); diff --git a/mp-arith.c b/mp-arith.c index c67fdd8..96fdeb8 100644 --- a/mp-arith.c +++ b/mp-arith.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp-arith.c,v 1.7 2000/06/22 19:02:53 mdw Exp $ + * $Id: mp-arith.c,v 1.8 2000/10/08 12:02:21 mdw Exp $ * * Basic arithmetic on multiprecision integers * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: mp-arith.c,v $ + * Revision 1.8 2000/10/08 12:02:21 mdw + * Use @MP_EQ@ instead of @MP_CMP@. + * * Revision 1.7 2000/06/22 19:02:53 mdw * New function @mp_odd@ to extract powers of two from an integer. This is * common code from the Rabin-Miller test, RSA key recovery and modular @@ -143,6 +146,15 @@ mp *mp_lsr(mp *d, mp *a, size_t n) return (d); } +/* --- @mp_eq@ --- * + * + * Arguments: @const mp *a, *b@ = two numbers + * + * Returns: Nonzero if the numbers are equal. + */ + +int mp_eq(const mp *a, const mp *b) { return (MP_EQ(a, b)); } + /* --- @mp_cmp@ --- * * * Arguments: @const mp *a, *b@ = two numbers @@ -418,7 +430,7 @@ mp *mp_odd(mp *d, mp *m, size_t *s) static int verify(const char *op, mp *expect, mp *result, mp *a, mp *b) { - if (MP_CMP(expect, !=, result)) { + if (!MP_EQ(expect, result)) { fprintf(stderr, "\n*** %s failed", op); fputs("\n*** a = ", stderr); mp_writefile(a, stderr, 10); fputs("\n*** b = ", stderr); mp_writefile(b, stderr, 10); @@ -495,7 +507,7 @@ static int todd(dstr *v) mp *t; size_t s; t = mp_odd(MP_NEW, a, &s); - if (s != rs || MP_CMP(t, !=, rt)) { + if (s != rs || !MP_EQ(t, rt)) { ok = 0; fprintf(stderr, "\n*** odd failed"); fputs("\n*** a = ", stderr); mp_writefile(a, stderr, 10); diff --git a/mp-modsqrt.c b/mp-modsqrt.c index a3a6b1f..1c66c78 100644 --- a/mp-modsqrt.c +++ b/mp-modsqrt.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp-modsqrt.c,v 1.1 2000/06/22 19:01:31 mdw Exp $ + * $Id: mp-modsqrt.c,v 1.2 2000/10/08 12:02:21 mdw Exp $ * * Compute square roots modulo a prime * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: mp-modsqrt.c,v $ + * Revision 1.2 2000/10/08 12:02:21 mdw + * Use @MP_EQ@ instead of @MP_CMP@. + * * Revision 1.1 2000/06/22 19:01:31 mdw * Compute square roots in a prime field. * @@ -132,7 +135,7 @@ mp *mp_modsqrt(mp *d, mp *a, mp *p) /* --- Fiddle at the end --- */ - if (MP_CMP(dd, ==, mone)) + if (MP_EQ(dd, mone)) r = mpmont_mul(&mm, r, r, c); c = mp_sqr(c, c); c = mpmont_reduce(&mm, c, c); @@ -167,11 +170,11 @@ static int verify(dstr *v) if (!r) ok = 0; - else if (MP_CMP(r, ==, rr)) + else if (MP_EQ(r, rr)) ok = 1; else { r = mp_sub(r, p, r); - if (MP_CMP(r, ==, rr)) + if (MP_EQ(r, rr)) ok = 1; } diff --git a/mp-sqrt.c b/mp-sqrt.c index 98741e8..6b0f602 100644 --- a/mp-sqrt.c +++ b/mp-sqrt.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: mp-sqrt.c,v 1.1 2000/06/22 19:01:44 mdw Exp $ + * $Id: mp-sqrt.c,v 1.2 2000/10/08 12:02:21 mdw Exp $ * * Compute integer square roots * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: mp-sqrt.c,v $ + * Revision 1.2 2000/10/08 12:02:21 mdw + * Use @MP_EQ@ instead of @MP_CMP@. + * * Revision 1.1 2000/06/22 19:01:44 mdw * Compute (approximations to) integer square roots. * @@ -131,7 +134,7 @@ static int verify(dstr *v) mp *q = mp_sqrt(MP_NEW, a); int ok = 1; - if (MP_CMP(q, !=, qq)) { + if (!MP_EQ(q, qq)) { ok = 0; fputs("\n*** sqrt failed", stderr); fputs("\n*** a = ", stderr); mp_writefile(a, stderr, 10); -- 2.11.0