Add cyclic group abstraction, with test code. Separate off exponentation
[u/mdw/catacomb] / ec-keys.h
1 /* -*-c-*-
2 *
3 * $Id: ec-keys.h,v 1.2 2004/04/01 12:50:09 mdw Exp $
4 *
5 * Elliptic curve key-fetching
6 *
7 * (c) 2004 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307, USA.
28 */
29
30 /*----- Revision history --------------------------------------------------*
31 *
32 * $Log: ec-keys.h,v $
33 * Revision 1.2 2004/04/01 12:50:09 mdw
34 * Add cyclic group abstraction, with test code. Separate off exponentation
35 * functions for better static linking. Fix a buttload of bugs on the way.
36 * Generally ensure that negative exponents do inversion correctly. Add
37 * table of standard prime-field subgroups. (Binary field subgroups are
38 * currently unimplemented but easy to add if anyone ever finds a good one.)
39 *
40 * Revision 1.1 2004/03/28 01:58:47 mdw
41 * Generate, store and retreive elliptic curve keys.
42 *
43 */
44
45 #ifndef CATACOMB_EC_KEYS_H
46 #define CATACOMB_EC_KEYS_H
47
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51
52 /*----- Header files ------------------------------------------------------*/
53
54 #ifndef CATACOMB_EC_H
55 # include "ec.h"
56 #endif
57
58 #ifndef CATACOMB_KEY_H
59 # include "key.h"
60 #endif
61
62 /*----- Key structures ----------------------------------------------------*/
63
64 typedef struct ec_param {
65 ec_info ei; /* Curve information */
66 char *cstr; /* Curve definition string */
67 } ec_param;
68
69 typedef struct ec_pub {
70 ec_info ei; /* Curve information */
71 char *cstr; /* Curve definition string */
72 ec p; /* Public point */
73 } ec_pub;
74
75 typedef struct ec_priv {
76 ec_info ei; /* Curve information */
77 char *cstr; /* Curve definition string */
78 ec p; /* Public point */
79 mp *x; /* Secret exponent */
80 } ec_priv;
81
82 extern const key_fetchdef ec_paramfetch[];
83 #define EC_PARAMFETCHSZ 3
84
85 extern const key_fetchdef ec_pubfetch[];
86 #define EC_PUBFETCHSZ 4
87
88 extern const key_fetchdef ec_privfetch[];
89 #define EC_PRIVFETCHSZ 7
90
91 /*----- Functions provided ------------------------------------------------*/
92
93 /* --- @ec_paramfree@, @ec_pubfree@, @ec_privfree@ --- *
94 *
95 * Arguments: @ec_param *ep@, @ec_pub *ep@, @ec_priv *ep@ = pointer to
96 * key block to free
97 *
98 * Returns: ---
99 *
100 * Use: Frees an elliptic curve key block
101 */
102
103 extern void ec_paramfree(ec_param */*ep*/);
104 extern void ec_pubfree(ec_pub */*ep*/);
105 extern void ec_privfree(ec_priv */*ep*/);
106
107 /*----- That's all, folks -------------------------------------------------*/
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif