working version with crypto
[anytun.git] / keyexchange / isakmpd-20041012 / math_group.h
blobd5a19bcc76d5ff0253b11cf19c3c569f8647d7e3
1 /* $OpenBSD: math_group.h,v 1.10 2004/04/15 18:39:26 deraadt Exp $ */
2 /* $EOM: math_group.h,v 1.7 1999/04/17 23:20:40 niklas Exp $ */
4 /*
5 * Copyright (c) 1998 Niels Provos. All rights reserved.
6 * Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * This code was written under funding by Ericsson Radio Systems.
33 #ifndef _MATH_GROUP_H_
34 #define _MATH_GROUP_H_
36 enum groups {
37 MODP, /* F_p, Z modulo a prime */
38 EC2N, /* Elliptic Curve over the Field GF(2**N) */
39 ECP, /* Elliptic Curve over the Field Z_p */
40 NOTYET /* Not yet assigned */
44 * The group on which diffie hellmann calculations are done.
47 struct group {
48 enum groups type;
49 int id; /* Group ID */
50 int bits; /* Number of key bits provided by this group */
51 void *group;
52 void *a, *b, *c, *d;
53 void *gen; /* Group Generator */
54 int (*getlen) (struct group *);
55 void (*getraw) (struct group *, void *, u_int8_t *);
56 int (*setraw) (struct group *, void *, u_int8_t *, int);
57 int (*setrandom) (struct group *, void *);
58 int (*operation) (struct group *, void *, void *, void *);
61 /* Description of an Elliptic Group over GF(2**n) for Boot-Strapping */
63 struct ec2n_dscr {
64 int id;
65 int bits; /* Key Bits provided by this group */
66 char *polynomial; /* Irreduceable polynomial */
67 char *gen_x; /* X - Coord. of Generator */
68 char *a, *b; /* Curve Parameters */
71 /* Description of F_p for Boot-Strapping */
73 struct modp_dscr {
74 int id;
75 int bits; /* Key Bits provided by this group */
76 char *prime; /* Prime */
77 char *gen; /* Generator */
80 /* Prototypes */
82 void group_init(void);
83 void group_free(struct group *);
84 struct group *group_get(u_int32_t);
86 void ec2n_free(struct group *);
87 struct group *ec2n_clone(struct group *, struct group *);
88 void ec2n_init(struct group *);
90 void modp_free(struct group *);
91 struct group *modp_clone(struct group *, struct group *);
92 void modp_init(struct group *);
94 #endif /* _MATH_GROUP_H_ */