X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/600127f0c8669936093fc6bddda5a2dcb59cd076..097fb6f2f97575ce17738b4afb3216e9492de2b4:/dh-check.c diff --git a/dh-check.c b/dh-check.c index 8956bd1..ef07e66 100644 --- a/dh-check.c +++ b/dh-check.c @@ -1,13 +1,13 @@ /* -*-c-*- * - * $Id: dh-check.c,v 1.1 2001/02/03 16:08:24 mdw Exp $ + * $Id: dh-check.c,v 1.3 2004/04/08 01:36:15 mdw Exp $ * * Checks Diffie-Hellman group parameters * * (c) 2001 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,26 +15,18 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: dh-check.c,v $ - * Revision 1.1 2001/02/03 16:08:24 mdw - * Add consistency checking for public keys. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -66,6 +58,7 @@ int dh_checkparam(keycheck *kc, const dh_param *dp, mp **v, size_t n) mpmont mm; mp *pm1 = MP_NEW; mp *q = MP_NEW; + mp *x; mpmul mu; size_t i; @@ -96,7 +89,9 @@ int dh_checkparam(keycheck *kc, const dh_param *dp, mp **v, size_t n) goto fail; q = mp_odd(q, dp->q, &i); mpmont_create(&mm, dp->p); - q = mpmont_expr(&mm, q, dp->g, q); + x = mpmont_mul(&mm, MP_NEW, dp->g, mm.r2); + q = mpmont_expr(&mm, q, x, q); + mp_drop(x); do { if (mp_eq(q, mm.r) != !i) { if (keycheck_report(kc, KCSEV_ERR, "order of g != q")) {