updated integrity algorithm identifiers
[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
17 /**
18 * @defgroup diffie_hellman diffie_hellman
19 * @{ @ingroup crypto
20 */
21
22 #ifndef DIFFIE_HELLMAN_H_
23 #define DIFFIE_HELLMAN_H_
24
25 typedef enum diffie_hellman_group_t diffie_hellman_group_t;
26 typedef struct diffie_hellman_t diffie_hellman_t;
27
28 #include <library.h>
29
30 /**
31 * Diffie-Hellman group.
32 *
33 * The modulus (or group) to use for a Diffie-Hellman calculation.
34 * See IKEv2 RFC 3.3.2 and RFC 3526.
35 *
36 * ECP groups are defined in RFC 4753 and RFC 5114.
37 */
38 enum diffie_hellman_group_t {
39 MODP_NONE = 0,
40 MODP_768_BIT = 1,
41 MODP_1024_BIT = 2,
42 MODP_1536_BIT = 5,
43 MODP_2048_BIT = 14,
44 MODP_3072_BIT = 15,
45 MODP_4096_BIT = 16,
46 MODP_6144_BIT = 17,
47 MODP_8192_BIT = 18,
48 ECP_256_BIT = 19,
49 ECP_384_BIT = 20,
50 ECP_521_BIT = 21,
51 ECP_192_BIT = 25,
52 ECP_224_BIT = 26,
53 /** insecure NULL diffie hellman group for testing, in PRIVATE USE */
54 MODP_NULL = 1024,
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 own public value to transmit.
89 *
90 * Space for returned chunk is allocated and must be freed by the caller.
91 *
92 * @param value public value of caller is stored at this location
93 */
94 void (*get_my_public_value) (diffie_hellman_t *this, chunk_t *value);
95
96 /**
97 * Get the DH group used.
98 *
99 * @return DH group set in construction
100 */
101 diffie_hellman_group_t (*get_dh_group) (diffie_hellman_t *this);
102
103 /**
104 * Destroys an diffie_hellman_t object.
105 */
106 void (*destroy) (diffie_hellman_t *this);
107 };
108
109 #endif /** DIFFIE_HELLMAN_H_ @}*/