added missing comma in enumeration
[strongswan.git] / src / libstrongswan / crypto / diffie_hellman.h
1 /*
2 * Copyright (C) 2005-2007 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup diffie_hellman diffie_hellman
21 * @{ @ingroup crypto
22 */
23
24 #ifndef DIFFIE_HELLMAN_H_
25 #define DIFFIE_HELLMAN_H_
26
27 typedef enum diffie_hellman_group_t diffie_hellman_group_t;
28 typedef struct diffie_hellman_t diffie_hellman_t;
29
30 #include <library.h>
31
32 /**
33 * Diffie-Hellman group.
34 *
35 * The modulus (or group) to use for a Diffie-Hellman calculation.
36 * See IKEv2 RFC 3.3.2 and RFC 3526.
37 *
38 * ECP groups are defined in RFC 4753 and RFC 5114.
39 */
40 enum diffie_hellman_group_t {
41 MODP_NONE = 0,
42 MODP_768_BIT = 1,
43 MODP_1024_BIT = 2,
44 MODP_1536_BIT = 5,
45 MODP_2048_BIT = 14,
46 MODP_3072_BIT = 15,
47 MODP_4096_BIT = 16,
48 MODP_6144_BIT = 17,
49 MODP_8192_BIT = 18,
50 ECP_256_BIT = 19,
51 ECP_384_BIT = 20,
52 ECP_521_BIT = 21,
53 ECP_192_BIT = 25,
54 ECP_224_BIT = 26,
55 };
56
57 /**
58 * enum name for diffie_hellman_group_t.
59 */
60 extern enum_name_t *diffie_hellman_group_names;
61
62 /**
63 * Implementation of the Diffie-Hellman algorithm, as in RFC2631.
64 */
65 struct diffie_hellman_t {
66
67 /**
68 * Returns the shared secret of this diffie hellman exchange.
69 *
70 * Space for returned secret is allocated and must be
71 * freed by the caller.
72 *
73 * @param secret shared secret will be written into this chunk
74 * @return SUCCESS, FAILED if not both DH values are set
75 */
76 status_t (*get_shared_secret) (diffie_hellman_t *this, chunk_t *secret);
77
78 /**
79 * Sets the public value of partner.
80 *
81 * Chunk gets cloned and can be destroyed afterwards.
82 *
83 * @param value public value of partner
84 */
85 void (*set_other_public_value) (diffie_hellman_t *this, chunk_t value);
86
87 /**
88 * Gets the public value of partner.
89 *
90 * Space for returned chunk is allocated and must be freed by the caller.
91 *
92 * @param value public value of partner is stored at this location
93 * @return SUCCESS, FAILED if other public value not set
94 */
95 status_t (*get_other_public_value) (diffie_hellman_t *this, chunk_t *value);
96
97 /**
98 * Gets the own public value to transmit.
99 *
100 * Space for returned chunk is allocated and must be freed by the caller.
101 *
102 * @param value public value of caller is stored at this location
103 */
104 void (*get_my_public_value) (diffie_hellman_t *this, chunk_t *value);
105
106 /**
107 * Get the DH group used.
108 *
109 * @return DH group set in construction
110 */
111 diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
112
113 /**
114 * Destroys an diffie_hellman_t object.
115 */
116 void (*destroy) (diffie_hellman_t *this);
117 };
118
119 #endif /*DIFFIE_HELLMAN_H_ @} */