1 /* $OpenBSD: dh.h,v 1.3 2010/06/23 11:26:13 reyk Exp $ */ 2 /* $vantronix: dh.h,v 1.8 2010/06/02 12:22:58 reyk Exp $ */ 3 4 /* 5 * Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #ifndef _DH_H_ 21 #define _DH_H_ 22 23 enum group_type { 24 GROUP_MODP = 0, 25 GROUP_EC2N = 1, 26 GROUP_ECP = 2 27 }; 28 29 struct group_id { 30 enum group_type type; 31 u_int id; 32 int bits; 33 char *prime; 34 char *generator; 35 int nid; 36 }; 37 38 struct group { 39 int id; 40 struct group_id *spec; 41 42 void *dh; 43 void *ec; 44 45 int (*init)(struct group *); 46 int (*getlen)(struct group *); 47 int (*exchange)(struct group *, u_int8_t *); 48 int (*shared)(struct group *, u_int8_t *, u_int8_t *); 49 }; 50 51 #define DH_MAXSZ 1024 /* 8192 bits */ 52 53 void group_init(void); 54 void group_free(struct group *); 55 struct group *group_get(u_int32_t); 56 57 int dh_getlen(struct group *); 58 int dh_create_exchange(struct group *, u_int8_t *); 59 int dh_create_shared(struct group *, u_int8_t *, u_int8_t *); 60 61 #endif /* _DH_H_ */ 62