Moving charon to libcharon.
[strongswan.git] / src / libcharon / encoding / payloads / ke_payload.h
1 /*
2 * Copyright (C) 2005-2006 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 ke_payload ke_payload
19 * @{ @ingroup payloads
20 */
21
22 #ifndef KE_PAYLOAD_H_
23 #define KE_PAYLOAD_H_
24
25 typedef struct ke_payload_t ke_payload_t;
26
27 #include <library.h>
28 #include <encoding/payloads/payload.h>
29 #include <encoding/payloads/transform_substructure.h>
30 #include <utils/linked_list.h>
31 #include <crypto/diffie_hellman.h>
32
33 /**
34 * KE payload length in bytes without any key exchange data.
35 */
36 #define KE_PAYLOAD_HEADER_LENGTH 8
37
38 /**
39 * Class representing an IKEv2-KE Payload.
40 *
41 * The KE Payload format is described in RFC section 3.4.
42 */
43 struct ke_payload_t {
44 /**
45 * The payload_t interface.
46 */
47 payload_t payload_interface;
48
49 /**
50 * Returns the currently set key exchange data of this KE payload.
51 *
52 * @warning Returned data are not copied.
53 *
54 * @return chunk_t pointing to the value
55 */
56 chunk_t (*get_key_exchange_data) (ke_payload_t *this);
57
58 /**
59 * Sets the key exchange data of this KE payload.
60 *
61 * Value is getting copied.
62 *
63 * @param key_exchange_data chunk_t pointing to the value to set
64 */
65 void (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
66
67 /**
68 * Gets the Diffie-Hellman Group Number of this KE payload.
69 *
70 * @return DH Group Number of this payload
71 */
72 diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
73
74 /**
75 * Sets the Diffie-Hellman Group Number of this KE payload.
76 *
77 * @param dh_group_number DH Group to set
78 */
79 void (*set_dh_group_number) (ke_payload_t *this,
80 diffie_hellman_group_t dh_group_number);
81
82 /**
83 * Destroys an ke_payload_t object.
84 */
85 void (*destroy) (ke_payload_t *this);
86 };
87
88 /**
89 * Creates an empty ke_payload_t object
90 *
91 * @return ke_payload_t object
92 */
93 ke_payload_t *ke_payload_create(void);
94
95 /**
96 * Creates a ke_payload_t from a diffie_hellman_t
97 *
98 * @param diffie_hellman diffie hellman object containing group and key
99 * @return ke_payload_t object
100 */
101 ke_payload_t *ke_payload_create_from_diffie_hellman(
102 diffie_hellman_t *diffie_hellman);
103
104 #endif /** KE_PAYLOAD_H_ @}*/