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