3 * $Id: dsa-check.c,v 1.1 2001/02/03 16:08:24 mdw Exp $
5 * Consistency checking for DSA keys
7 * (c) 2001 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 /*----- Revision history --------------------------------------------------*
32 * $Log: dsa-check.c,v $
33 * Revision 1.1 2001/02/03 16:08:24 mdw
34 * Add consistency checking for public keys.
38 /*----- Header files ------------------------------------------------------*/
48 /*----- Main code ---------------------------------------------------------*/
50 /* --- @dsa_checkparam@ --- *
52 * Arguments: @keycheck *kc@ = keycheck state
53 * @const dsa_param *dp@ = pointer to the parameter set
54 * @const dsa_seed *ds@ = pointer to seed information
56 * Returns: Zero if all OK, or return status from function.
58 * Use: Checks a set of DSA parameters for consistency and security.
61 int dsa_checkparam(keycheck
*kc
, const dsa_param
*dp
, const dsa_seed
*ds
)
64 grand
*r
= dsarand_create(ds
->p
, ds
->sz
);
65 mp
*p
= MP_NEW
, *q
= MP_NEW
;
70 r
->ops
->misc(r
, DSARAND_PASSES
, 2);
71 q
= mprand(q
, mp_bits(dp
->q
), r
, 1);
72 if (!mp_eq(q
, dp
->q
) &&
73 keycheck_report(kc
, KCSEV_ERR
, "q doesn't match seed provided"))
77 r
->ops
->misc(r
, DSARAND_PASSES
, 1);
78 for (i
= 0; i
<= ds
->count
; i
++)
79 p
= mprand(p
, n
, r
, 0);
84 if (!mp_eq(p
, dp
->p
) &&
85 keycheck_report(kc
, KCSEV_ERR
, "p doesn't match seed provided"))
94 return (dh_checkparam(kc
, dp
, 0, 0));
97 /*----- That's all, folks -------------------------------------------------*/