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