dfc6308b48e0ec58e377e07cdef3b0c94d3fc769
[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 <collections/linked_list.h>
31 #include <crypto/diffie_hellman.h>
32
33 /**
34 * Class representing an IKEv1 or IKEv2 key exchange payload.
35 */
36 struct ke_payload_t {
37
38 /**
39 * The payload_t interface.
40 */
41 payload_t payload_interface;
42
43 /**
44 * Returns the key exchange data of this KE payload.
45 *
46 * @return chunk_t pointing to internal data
47 */
48 chunk_t (*get_key_exchange_data) (ke_payload_t *this);
49
50 /**
51 * Gets the Diffie-Hellman Group Number of this KE payload (IKEv2 only).
52 *
53 * @return DH Group Number of this payload
54 */
55 diffie_hellman_group_t (*get_dh_group_number) (ke_payload_t *this);
56
57 /**
58 * Destroys a ke_payload_t object.
59 */
60 void (*destroy) (ke_payload_t *this);
61 };
62
63 /**
64 * Creates an empty ke_payload_t object.
65 *
66 * @param type PLV2_KEY_EXCHANGE or PLV1_KEY_EXCHANGE
67 * @return ke_payload_t object
68 */
69 ke_payload_t *ke_payload_create(payload_type_t type);
70
71 /**
72 * Creates a ke_payload_t from a diffie_hellman_t.
73 *
74 * @param type PLV2_KEY_EXCHANGE or PLV1_KEY_EXCHANGE
75 * @param dh diffie hellman object containing group and key
76 * @return ke_payload_t object
77 */
78 ke_payload_t *ke_payload_create_from_diffie_hellman(payload_type_t type,
79 diffie_hellman_t *dh);
80
81 #endif /** KE_PAYLOAD_H_ @}*/