Migrated ke_payload to INIT/METHOD macros
[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 key exchange data of this KE payload.
51 *
52 * @return chunk_t pointing to internal data
53 */
54 chunk_t (*get_key_exchange_data) (ke_payload_t *this);
55
56 /**
57 * Gets the Diffie-Hellman Group Number of this KE payload.
58 *
59 * @return DH Group Number of this payload
60 */
61 diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
62
63 /**
64 * Destroys an ke_payload_t object.
65 */
66 void (*destroy) (ke_payload_t *this);
67 };
68
69 /**
70 * Creates an empty ke_payload_t object
71 *
72 * @return ke_payload_t object
73 */
74 ke_payload_t *ke_payload_create(void);
75
76 /**
77 * Creates a ke_payload_t from a diffie_hellman_t
78 *
79 * @param diffie_hellman diffie hellman object containing group and key
80 * @return ke_payload_t object
81 */
82 ke_payload_t *ke_payload_create_from_diffie_hellman(
83 diffie_hellman_t *diffie_hellman);
84
85 #endif /** KE_PAYLOAD_H_ @}*/