4 * @brief Interface of ike_sa_id_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 #include <encoding/message.h>
28 #include <encoding/payloads/proposal_substructure.h>
29 #include <sa/ike_sa_id.h>
30 #include <utils/logger.h>
31 #include <utils/randomizer.h>
32 #include <sa/states/state.h>
33 #include <transforms/prfs/prf.h>
34 #include <transforms/crypters/crypter.h>
35 #include <transforms/signers/signer.h>
40 * Nonce size in bytes of all sent nonces
46 typedef struct ike_sa_t ike_sa_t
;
49 * @brief Class ike_sa_t. An object of this type is managed by an
50 * ike_sa_manager_t object and represents an IKE_SA.
57 * @brief Processes a incoming IKEv2-Message of type message_t
59 * @param this ike_sa_t object object
60 * @param[in] message message_t object to process
61 * @return SUCCESSFUL if succeeded, FAILED otherwise
63 status_t (*process_message
) (ike_sa_t
*this,message_t
*message
);
66 * @brief Initiate a new connection with given configuration name.
68 * @param this calling object
69 * @param name name of the configuration
72 status_t (*initialize_connection
) (ike_sa_t
*this, char *name
);
75 * @brief Get the id of the SA.
77 * @param this ike_sa_t object object
78 * @return ike_sa's ike_sa_id_t
80 ike_sa_id_t
* (*get_id
) (ike_sa_t
*this);
83 * @brief Destroys a ike_sa_t object.
85 * @param this ike_sa_t object
87 void (*destroy
) (ike_sa_t
*this);
90 typedef struct protected_ike_sa_t protected_ike_sa_t
;
93 * @brief Protected data of an ike_sa_t object.
95 * This members should only be accessed from
96 * the varius state classes.
100 struct protected_ike_sa_t
{
103 * Public part of a ike_sa_t object
108 * Builds an empty IKEv2-Message and fills in default informations.
110 * Depending on the type of message (request or response), the message id is
111 * either message_id_out or message_id_in.
113 * Used in every state.
115 * @param this calling object
116 * @param type exchange type of new message
117 * @param request TRUE, if message has to be a request
118 * @param message new message is stored at this location
120 void (*build_message
) (protected_ike_sa_t
*this, exchange_type_t type
, bool request
, message_t
**message
);
123 * Initiate a new connection with given configuration name
125 * @param this calling object
126 * @param dh_shared_secret shared secret of diffie hellman exchange
127 * @param initiator_nonce nonce of initiator
128 * @param responder_nonce nonce of responder
130 void (*compute_secrets
) (protected_ike_sa_t
*this,chunk_t dh_shared_secret
,chunk_t initiator_nonce
, chunk_t responder_nonce
);
133 * Gets the internal stored logger_t object for given ike_sa_t object.
135 * @param this calling object
136 * @return pointer to the internal stored logger_t object
138 logger_t
*(*get_logger
) (protected_ike_sa_t
*this);
142 * Gets the internal stored host_t object for my host.
144 * @param this calling object
145 * @return pointer to the internal stored host_t object
147 host_t
*(*get_my_host
) (protected_ike_sa_t
*this);
150 * Gets the internal stored host_t object for other host.
152 * @param this calling object
153 * @return pointer to the internal stored host_t object
155 host_t
*(*get_other_host
) (protected_ike_sa_t
*this);
158 * Sets the internal stored host_t object for my host.
160 * Allready existing object gets destroyed. object gets not cloned!
162 * @param this calling object
163 * @param my_host pointer to the new host_t object
165 void (*set_my_host
) (protected_ike_sa_t
*this,host_t
* my_host
);
168 * Sets the internal stored host_t object for other host.
170 * Allready existing object gets destroyed. object gets not cloned!
172 * @param this calling object
173 * @param other_host pointer to the new host_t object
175 void (*set_other_host
) (protected_ike_sa_t
*this,host_t
*other_host
);
178 * Creates all needed transform objects for given ike_sa_t using
179 * the informations stored in a proposal_substructure_t object
181 * Allready existing objects get destroyed.
183 * @param this calling object
184 * @param proposal proposal used to get informations for transform
185 * objects (algorithms, key lengths, etc.)
187 status_t (*create_transforms_from_proposal
) (protected_ike_sa_t
*this,proposal_substructure_t
*proposal
);
190 * Sets the last requested message.
192 * Allready set last requested message gets destroyed. object gets not cloned!
194 * @param this calling object
195 * @param message pointer to the new last requested message
198 * - FAILED if message id is not next expected one
200 status_t (*set_last_requested_message
) (protected_ike_sa_t
*this,message_t
* message
);
203 * Sets the last responded message.
205 * Allready set last requested message gets destroyed. object gets not cloned!
207 * @param this calling object
208 * @param message pointer to the new last responded message
211 * - FAILED if message id is not next expected one
213 status_t (*set_last_responded_message
) (protected_ike_sa_t
*this,message_t
* message
);
216 * Gets the internal stored randomizer_t object.
218 * @param this calling object
219 * @return pointer to the internal randomizer_t object
221 randomizer_t
*(*get_randomizer
) (protected_ike_sa_t
*this);
224 * Sets the new state_t object of the IKE_SA object.
226 * The old state_t object gets not destroyed. It's the callers duty to
227 * make sure old state is destroyed (Normally the old state is the caller ).
229 * @param this calling object
230 * @param state pointer to the new state_t object
232 void (*set_new_state
) (protected_ike_sa_t
*this,state_t
*state
);
235 * Gets the internal stored initiator crypter_t object.
237 * @param this calling object
238 * @return pointer to crypter_t object
240 crypter_t
*(*get_crypter_initiator
) (protected_ike_sa_t
*this);
243 * Gets the internal stored initiator signer object.
245 * @param this calling object
246 * @return pointer to signer_t object
248 signer_t
*(*get_signer_initiator
) (protected_ike_sa_t
*this);
255 * Creates an ike_sa_t object with a specific ike_sa_id_t object
257 * @param[in] ike_sa_id ike_sa_id_t object to associate with new IKE_SA.
258 * The object is internal getting cloned
259 * and so has to be destroyed by the caller.
261 * @warning the Content of internal ike_sa_id_t object can change over time
262 * e.g. when a IKE_SA_INIT has been finished.
264 * @return created ike_sa_t object
268 ike_sa_t
* ike_sa_create(ike_sa_id_t
*ike_sa_id
);