3 * $Id: keycheck.h,v 1.1 2001/02/03 16:08:24 mdw Exp $
5 * Framework for checking consistency of 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: keycheck.h,v $
33 * Revision 1.1 2001/02/03 16:08:24 mdw
34 * Add consistency checking for public keys.
38 #ifndef CATACOMB_KEYCHECK_H
39 #define CATACOMB_KEYCHECK_H
45 /*----- Header files ------------------------------------------------------*/
51 /*----- Data structures ---------------------------------------------------*/
55 KCSEV_INFO
= KCSEV_ALL
,
61 typedef struct keycheck
{
62 unsigned sev
[KCSEV_MAX
];
63 int (*func
)(unsigned /*sev*/, const char */
*msg*/
, void */
*p*/
);
67 typedef struct keycheck_reportctx
{
72 /*----- Generic functions -------------------------------------------------*/
74 /* --- @keycheck_report@ --- *
76 * Arguments: @keycheck *kc@ = keycheck state
77 * @unsigned sev@ = severity of this report
78 * @const char *msg@ = message to send along
79 * @...@ = things to fill the message in with
81 * Returns: Zero to continue, or nonzero to stop and give up.
83 * Use: Reports a message to the user function.
86 extern int keycheck_report(keycheck */
*kc*/
, unsigned /*sev*/,
87 const char */
*msg*/
, ...);
89 /* --- @keycheck_init@ --- *
91 * Arguments: @keycheck *kc@ = pointer to block to initialize
92 * @int (*func)(unsigned sev, const char *msg, void *p)@ =
93 * handler function for problems
94 * @void *p@ = pointer to give to handler
98 * Use: Initializes a key checking context.
101 extern void keycheck_init(keycheck */
*kc*/
,
102 int (*/
*func*/
)(unsigned /*sev*/,
107 /* --- @keycheck_allclear@ --- *
109 * Arguments: @keycheck *kc@ = pointer to keycheck context
110 * @unsigned sev@ = minimum severity to care about
112 * Returns: Nonzero if no problems of @sev@ or above were noticed.
115 extern int keycheck_allclear(keycheck */
*kc*/
, unsigned /*sev*/);
117 /*----- A standard report function ----------------------------------------*/
119 /* --- @keycheck_stdreport@ --- *
121 * Arguments: @unsigned sev@ = problem severity
122 * @const char *msg@ = message to report
123 * @void *p@ = pointer to a @keycheck_reportctx@ structure
127 * Use: Reports a message to stderr.
130 extern int keycheck_stdreport(unsigned /*sev*/,
131 const char */
*msg*/
, void */
*p*/
);
133 /*----- Special support functions for large integers ----------------------*/
135 /* --- @keycheck_prime@ --- *
137 * Arguments: @keycheck *kc@ = keycheck state
138 * @unsigned sev@ = severity if not prime
139 * @mp *m@ = a number to check for primality
140 * @const char *name@ = name of this number
142 * Returns: Zero if OK, or return status from function.
144 * Use: Checks that a number is prime.
147 extern int keycheck_prime(keycheck */
*kc*/
, unsigned /*sev*/,
148 mp */
*m*/
, const char */
*name*/
);
150 /*----- That's all, folks -------------------------------------------------*/