2005-11-08 13:33:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* @file ike_sa.h
|
2005-11-10 09:35:28 +00:00
|
|
|
|
*
|
2005-12-07 09:03:34 +00:00
|
|
|
|
* @brief Interface of ike_sa_t.
|
2005-11-10 09:35:28 +00:00
|
|
|
|
*
|
2005-11-08 13:33:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
2006-06-22 06:36:28 +00:00
|
|
|
|
* Copyright (C) 2006 Tobias Brunner, Daniel Roethlisberger
|
2006-07-07 08:49:06 +00:00
|
|
|
|
* Copyright (C) 2005-2006 Martin Willi
|
|
|
|
|
* Copyright (C) 2005 Jan Hutter
|
2005-11-08 13:33:28 +00:00
|
|
|
|
* Hochschule fuer Technik Rapperswil
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
|
* for more details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef IKE_SA_H_
|
|
|
|
|
#define IKE_SA_H_
|
|
|
|
|
|
2005-11-23 09:24:35 +00:00
|
|
|
|
#include <types.h>
|
2005-11-23 09:57:18 +00:00
|
|
|
|
#include <encoding/message.h>
|
2005-11-28 15:20:51 +00:00
|
|
|
|
#include <encoding/payloads/proposal_substructure.h>
|
2005-11-23 10:11:50 +00:00
|
|
|
|
#include <sa/ike_sa_id.h>
|
2006-02-16 09:55:07 +00:00
|
|
|
|
#include <sa/child_sa.h>
|
2006-03-07 09:42:15 +00:00
|
|
|
|
#include <config/configuration.h>
|
2005-11-23 09:24:35 +00:00
|
|
|
|
#include <utils/logger.h>
|
|
|
|
|
#include <utils/randomizer.h>
|
2006-04-05 12:10:50 +00:00
|
|
|
|
#include <crypto/prfs/prf.h>
|
|
|
|
|
#include <crypto/crypters/crypter.h>
|
|
|
|
|
#include <crypto/signers/signer.h>
|
2006-04-25 10:06:30 +00:00
|
|
|
|
#include <config/connections/connection.h>
|
|
|
|
|
#include <config/policies/policy.h>
|
2006-07-07 07:04:07 +00:00
|
|
|
|
#include <config/proposal.h>
|
2006-04-26 12:28:02 +00:00
|
|
|
|
#include <utils/logger.h>
|
2005-11-21 16:41:24 +00:00
|
|
|
|
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
|
|
|
|
typedef enum ike_sa_state_t ike_sa_state_t;
|
|
|
|
|
|
2005-11-21 16:41:24 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief State of an IKE_SA.
|
2006-07-12 14:08:52 +00:00
|
|
|
|
*
|
|
|
|
|
* An IKE_SA passes various states in its lifetime. A newly created
|
|
|
|
|
* SA is in the state CREATED.
|
|
|
|
|
* @verbatim
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD> SA_CREATED <EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
on initiate()---> <EFBFBD> <----- on IKE_SA_INIT received
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD> SA_CONNECTING <EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
<EFBFBD> <----- on IKE_AUTH successfully completed
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD> SA_ESTABLISHED <EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
on delete()---> <EFBFBD> <----- on IKE_SA delete request received
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD> SA_DELETING <EFBFBD>
|
|
|
|
|
+----------------+
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
<EFBFBD> <----- after delete() acknowledged
|
|
|
|
|
<EFBFBD>
|
|
|
|
|
\<EFBFBD>/
|
|
|
|
|
X
|
|
|
|
|
/ \
|
|
|
|
|
@endverbatim
|
|
|
|
|
*
|
2005-11-29 08:08:03 +00:00
|
|
|
|
* @ingroup sa
|
2005-11-21 16:41:24 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
enum ike_sa_state_t {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IKE_SA just got created, but is not initiating nor responding yet.
|
|
|
|
|
*/
|
2006-07-13 08:26:54 +00:00
|
|
|
|
IKE_CREATED,
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IKE_SA gets initiated actively or passively
|
|
|
|
|
*/
|
2006-07-13 08:26:54 +00:00
|
|
|
|
IKE_CONNECTING,
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IKE_SA is fully established
|
|
|
|
|
*/
|
2006-07-13 08:26:54 +00:00
|
|
|
|
IKE_ESTABLISHED,
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* IKE_SA is in progress of deletion
|
|
|
|
|
*/
|
2006-07-13 08:26:54 +00:00
|
|
|
|
IKE_DELETING,
|
2006-07-05 10:53:20 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* String mappings for ike_sa_state_t.
|
|
|
|
|
*/
|
|
|
|
|
extern mapping_t ike_sa_state_m[];
|
2005-11-08 13:33:28 +00:00
|
|
|
|
|
2005-12-07 09:03:34 +00:00
|
|
|
|
|
2005-11-24 11:30:19 +00:00
|
|
|
|
typedef struct ike_sa_t ike_sa_t;
|
|
|
|
|
|
2005-11-08 13:33:28 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Class ike_sa_t representing an IKE_SA.
|
|
|
|
|
*
|
|
|
|
|
* An IKE_SA contains crypto information related to a connection
|
|
|
|
|
* with a peer. It contains multiple IPsec CHILD_SA, for which
|
|
|
|
|
* it is responsible. All traffic is handled by an IKE_SA, using
|
|
|
|
|
* transactions.
|
|
|
|
|
*
|
2005-12-07 07:27:28 +00:00
|
|
|
|
* @b Constructors:
|
|
|
|
|
* - ike_sa_create()
|
2005-11-29 08:08:03 +00:00
|
|
|
|
*
|
|
|
|
|
* @ingroup sa
|
2005-11-08 13:33:28 +00:00
|
|
|
|
*/
|
2005-11-24 11:30:19 +00:00
|
|
|
|
struct ike_sa_t {
|
2005-11-08 13:33:28 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Get the id of the SA.
|
|
|
|
|
*
|
|
|
|
|
* Returned ike_sa_id_t object is not getting cloned!
|
2005-11-10 09:35:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return ike_sa's ike_sa_id_t
|
2005-11-08 13:33:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
ike_sa_id_t* (*get_id) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the state of the IKE_SA.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return state of the IKE_SA
|
|
|
|
|
*/
|
|
|
|
|
ike_sa_state_t (*get_state) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the state of the IKE_SA.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param state state to set for the IKE_SA
|
|
|
|
|
*/
|
|
|
|
|
void (*set_state) (ike_sa_t *this, ike_sa_state_t ike_sa);
|
2006-07-20 10:09:32 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the name of the connection this IKE_SA uses.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return name
|
|
|
|
|
*/
|
|
|
|
|
char* (*get_name) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the name of the connection this IKE_SA uses.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param name name, gets cloned
|
|
|
|
|
*/
|
|
|
|
|
void (*set_name) (ike_sa_t *this, char* name);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the own host address.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return host address
|
|
|
|
|
*/
|
|
|
|
|
host_t* (*get_my_host) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the other peers host address.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return host address
|
|
|
|
|
*/
|
|
|
|
|
host_t* (*get_other_host) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the own identification.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return identification
|
|
|
|
|
*/
|
|
|
|
|
identification_t* (*get_my_id) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the own identification.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param me identification
|
|
|
|
|
*/
|
|
|
|
|
void (*set_my_id) (ike_sa_t *this, identification_t *me);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the other peers identification.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return identification
|
|
|
|
|
*/
|
|
|
|
|
identification_t* (*get_other_id) (ike_sa_t *this);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Set the other peers identification.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param other identification
|
|
|
|
|
*/
|
|
|
|
|
void (*set_other_id) (ike_sa_t *this, identification_t *other);
|
2005-11-08 13:33:28 +00:00
|
|
|
|
|
2005-11-22 15:40:11 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Initiate a new connection.
|
|
|
|
|
*
|
2006-07-20 10:09:32 +00:00
|
|
|
|
* The policy/connection is owned by the IKE_SA after the call, so
|
2006-03-16 15:25:06 +00:00
|
|
|
|
* do not modify or destroy it.
|
2005-11-22 15:40:11 +00:00
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
2006-03-16 15:25:06 +00:00
|
|
|
|
* @param connection connection to initiate
|
2006-07-20 10:09:32 +00:00
|
|
|
|
* @param policy policy to set up
|
|
|
|
|
* @return
|
|
|
|
|
* - SUCCESS if initialization started
|
|
|
|
|
* - DESTROY_ME if initialization failed and IKE_SA MUST be deleted
|
|
|
|
|
*/
|
|
|
|
|
status_t (*initiate) (ike_sa_t *this, connection_t *connection, policy_t *policy);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Route a policy in the kernel.
|
|
|
|
|
*
|
|
|
|
|
* Installs the policies in the kernel. If traffic matches,
|
|
|
|
|
* the kernel requests connection setup from the IKE_SA via acquire().
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
2006-07-21 13:31:53 +00:00
|
|
|
|
* @param connection connection definition used for routing
|
2006-07-20 10:09:32 +00:00
|
|
|
|
* @param policy policy to route
|
|
|
|
|
* @return
|
2006-07-21 13:31:53 +00:00
|
|
|
|
* - SUCCESS if routed successfully
|
|
|
|
|
* - FAILED if routing failed
|
2006-07-20 10:09:32 +00:00
|
|
|
|
*/
|
2006-07-21 13:31:53 +00:00
|
|
|
|
status_t (*route) (ike_sa_t *this, connection_t *connection, policy_t *policy);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Unroute a policy in the kernel previously routed.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param policy policy to route
|
|
|
|
|
* @return
|
|
|
|
|
* - SUCCESS if route removed
|
|
|
|
|
* - DESTROY_ME if last route was removed from
|
|
|
|
|
* an IKE_SA which was not established
|
|
|
|
|
*/
|
|
|
|
|
status_t (*unroute) (ike_sa_t *this, policy_t *policy);
|
2006-07-20 10:09:32 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Acquire connection setup for a policy.
|
|
|
|
|
*
|
|
|
|
|
* If an installed policy raises an acquire, the kernel calls
|
|
|
|
|
* this function to establsh the CHILD_SA (and maybe the IKE_SA).
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param reqid reqid of the CHILD_SA the policy belongs to.
|
2005-12-07 07:27:28 +00:00
|
|
|
|
* @return
|
|
|
|
|
* - SUCCESS if initialization started
|
2006-05-23 08:01:49 +00:00
|
|
|
|
* - DESTROY_ME if initialization failed and IKE_SA MUST be deleted
|
2005-11-22 15:40:11 +00:00
|
|
|
|
*/
|
2006-07-20 10:09:32 +00:00
|
|
|
|
status_t (*acquire) (ike_sa_t *this, u_int32_t reqid);
|
2005-12-02 13:20:20 +00:00
|
|
|
|
|
2006-06-22 06:36:28 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Initiates the deletion of an IKE_SA.
|
|
|
|
|
*
|
|
|
|
|
* Sends a delete message to the remote peer and waits for
|
|
|
|
|
* its response. If the response comes in, or a timeout occurs,
|
|
|
|
|
* the IKE SA gets deleted.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* - SUCCESS if deletion is initialized
|
|
|
|
|
* - INVALID_STATE, if the IKE_SA is not in
|
|
|
|
|
* an established state and can not be
|
|
|
|
|
* delete (but destroyed).
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
status_t (*delete) (ike_sa_t *this);
|
|
|
|
|
|
2005-12-02 13:20:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief Retransmits a request.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param message_id ID of the request to retransmit
|
|
|
|
|
* @return
|
|
|
|
|
* - SUCCESS
|
|
|
|
|
* - NOT_FOUND if request doesn't have to be retransmited
|
|
|
|
|
*/
|
|
|
|
|
status_t (*retransmit_request) (ike_sa_t *this, u_int32_t message_id);
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
2006-04-25 10:06:30 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Processes a incoming IKEv2-Message.
|
2006-04-25 10:06:30 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* Message processing may fail. If a critical failure occurs,
|
|
|
|
|
* process_message() return DESTROY_ME. Then the caller must
|
|
|
|
|
* destroy the IKE_SA immediatly, as it is unusable.
|
2006-04-27 07:24:04 +00:00
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param[in] message message to process
|
|
|
|
|
* @return
|
|
|
|
|
* - SUCCESS
|
|
|
|
|
* - FAILED
|
|
|
|
|
* - DESTROY_ME if this IKE_SA MUST be deleted
|
2006-04-27 07:24:04 +00:00
|
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
|
status_t (*process_message) (ike_sa_t *this, message_t *message);
|
2005-12-06 12:27:09 +00:00
|
|
|
|
|
2006-07-13 08:26:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief Get the next message ID for a request.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return the next message id
|
|
|
|
|
*/
|
|
|
|
|
u_int32_t (*get_next_message_id) (ike_sa_t *this);
|
|
|
|
|
|
2006-06-22 06:36:28 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Check if NAT traversal is enabled for this IKE_SA.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @return TRUE if NAT traversal enabled
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
bool (*is_natt_enabled) (ike_sa_t *this);
|
2006-06-22 06:36:28 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Enable NAT detection for this IKE_SA.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* If a Network address translation is detected with
|
|
|
|
|
* NAT_DETECTION notifys, a SA must switch to ports
|
|
|
|
|
* 4500. To enable this behavior, call enable_natt().
|
|
|
|
|
* It is relevant which peer is NATted, this is specified
|
|
|
|
|
* with the "local" parameter. Call it twice when both
|
|
|
|
|
* are NATted.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param local TRUE, if we are NATted, FALSE if other
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
void (*enable_natt) (ike_sa_t *this, bool local);
|
2006-06-22 06:36:28 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Sends a DPD request to the peer.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* To check if a peer is still alive, periodic
|
|
|
|
|
* empty INFORMATIONAL messages are sent if no
|
|
|
|
|
* other traffic was received.
|
|
|
|
|
*
|
2006-06-23 14:02:30 +00:00
|
|
|
|
* @param this calling object
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @return
|
|
|
|
|
* - SUCCESS
|
|
|
|
|
* - DESTROY_ME, if peer did not respond
|
2006-06-23 14:02:30 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
status_t (*send_dpd) (ike_sa_t *this);
|
|
|
|
|
|
2006-06-23 14:02:30 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Sends a keep alive packet.
|
2006-06-23 14:02:30 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* To refresh NAT tables in a NAT router
|
|
|
|
|
* between the peers, periodic empty
|
|
|
|
|
* UDP packets are sent if no other traffic
|
|
|
|
|
* was sent.
|
2005-12-06 12:27:09 +00:00
|
|
|
|
*
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param this calling object
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
void (*send_keepalive) (ike_sa_t *this);
|
2006-06-22 06:36:28 +00:00
|
|
|
|
|
2006-04-26 12:28:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief Log the status of a the ike sa to a logger.
|
|
|
|
|
*
|
|
|
|
|
* The status of the IKE SA and all child SAs is logged.
|
|
|
|
|
* Supplying NULL as logger uses the internal child_sa logger
|
2006-04-27 07:24:04 +00:00
|
|
|
|
* to do the logging. The log is only done if the supplied
|
|
|
|
|
* connection name is NULL or matches the connections name.
|
2006-04-26 12:28:02 +00:00
|
|
|
|
*
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param logger logger to use for logging
|
|
|
|
|
* @param name name of the connection
|
2006-04-26 12:28:02 +00:00
|
|
|
|
*/
|
2006-04-27 07:24:04 +00:00
|
|
|
|
void (*log_status) (ike_sa_t *this, logger_t *logger, char *name);
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
2005-11-22 15:40:11 +00:00
|
|
|
|
/**
|
2006-02-14 14:52:00 +00:00
|
|
|
|
* @brief Derive all keys and create the transforms for IKE communication.
|
2005-11-25 13:42:02 +00:00
|
|
|
|
*
|
2006-02-14 14:52:00 +00:00
|
|
|
|
* Keys are derived using the diffie hellman secret, nonces and internal
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* stored SPIs.
|
2006-05-19 06:46:22 +00:00
|
|
|
|
* Already existing objects get destroyed.
|
2005-11-25 13:42:02 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param proposal proposal which contains algorithms to use
|
|
|
|
|
* @param dh diffie hellman object with shared secret
|
|
|
|
|
* @param nonce_i initiators nonce
|
|
|
|
|
* @param nonce_r responders nonce
|
|
|
|
|
* @param initiator role of this IKE SA (TRUE = originial initiator)
|
|
|
|
|
*/
|
|
|
|
|
status_t (*build_transforms) (ike_sa_t *this, proposal_t* proposal,
|
|
|
|
|
diffie_hellman_t *dh,
|
|
|
|
|
chunk_t nonce_i, chunk_t nonce_r,
|
|
|
|
|
bool initiator);
|
2005-12-02 19:26:01 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-02-14 14:52:00 +00:00
|
|
|
|
* @brief Get the multi purpose prf.
|
2005-12-02 19:26:01 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return pointer to prf_t object
|
2005-12-02 19:26:01 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
prf_t *(*get_prf) (ike_sa_t *this);
|
2005-12-02 19:26:01 +00:00
|
|
|
|
|
2006-02-09 16:25:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief Get the prf-object, which is used to derive keys for child SAs.
|
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return pointer to prf_t object
|
2006-02-09 16:25:02 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
prf_t *(*get_child_prf) (ike_sa_t *this);
|
2006-02-09 16:25:02 +00:00
|
|
|
|
|
2006-02-14 14:52:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief Get the prf used for authentication of initiator.
|
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return pointer to prf_t object
|
2006-02-14 14:52:00 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
prf_t *(*get_prf_auth_i) (ike_sa_t *this);
|
2006-02-14 14:52:00 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Get the prf used for authentication of responder.
|
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @return pointer to prf_t object
|
2006-06-09 15:12:43 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
prf_t *(*get_prf_auth_r) (ike_sa_t *this);
|
2006-06-09 15:12:43 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @brief Associates a child SA to this IKE SA
|
2006-06-09 15:12:43 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param child_sa child_sa to add
|
2006-06-09 15:12:43 +00:00
|
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
|
void (*add_child_sa) (ike_sa_t *this, child_sa_t *child_sa);
|
|
|
|
|
|
2006-07-21 13:31:53 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief Check if an IKE_SA has one or more CHILD_SAs with a given reqid.
|
|
|
|
|
*
|
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param reqid reqid of the CHILD
|
|
|
|
|
* @return TRUE if it has such a CHILD, FALSE if not
|
|
|
|
|
*/
|
|
|
|
|
bool (*has_child_sa) (ike_sa_t *this, u_int32_t reqid);
|
|
|
|
|
|
2006-07-03 06:27:45 +00:00
|
|
|
|
/**
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @brief Get a CHILD_SA identified by protocol and SPI.
|
2005-12-02 11:38:56 +00:00
|
|
|
|
*
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param this calling object
|
|
|
|
|
* @param protocol protocol of the SA
|
|
|
|
|
* @param spi SPI of the CHILD_SA
|
|
|
|
|
* @param inbound TRUE if SPI is inbound, FALSE if outbound
|
|
|
|
|
* @return child_sa, or NULL if none found
|
2006-07-05 10:53:20 +00:00
|
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
|
child_sa_t* (*get_child_sa) (ike_sa_t *this, protocol_id_t protocol,
|
|
|
|
|
u_int32_t spi, bool inbound);
|
2006-06-22 06:36:28 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Rekey the CHILD SA with the specified reqid.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* Looks for a CHILD SA owned by this IKE_SA, and start the rekeing.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param protocol protocol of the SA
|
|
|
|
|
* @param spi inbound SPI of the CHILD_SA
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @return
|
|
|
|
|
* - NOT_FOUND, if IKE_SA has no such CHILD_SA
|
|
|
|
|
* - SUCCESS, if rekeying initiated
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
|
status_t (*rekey_child_sa) (ike_sa_t *this, protocol_id_t protocol, u_int32_t spi);
|
|
|
|
|
|
2006-06-22 06:36:28 +00:00
|
|
|
|
/**
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @brief Close the CHILD SA with the specified protocol/SPI.
|
|
|
|
|
*
|
|
|
|
|
* Looks for a CHILD SA owned by this IKE_SA, deletes it and
|
|
|
|
|
* notify's the remote peer about the delete. The associated
|
|
|
|
|
* states and policies in the kernel get deleted, if they exist.
|
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param protocol protocol of the SA
|
|
|
|
|
* @param spi inbound SPI of the CHILD_SA
|
|
|
|
|
* @return
|
|
|
|
|
* - NOT_FOUND, if IKE_SA has no such CHILD_SA
|
|
|
|
|
* - SUCCESS, if delete message sent
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
|
status_t (*delete_child_sa) (ike_sa_t *this, protocol_id_t protocol, u_int32_t spi);
|
|
|
|
|
|
2006-06-22 06:36:28 +00:00
|
|
|
|
/**
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @brief Destroy a CHILD SA with the specified protocol/SPI.
|
|
|
|
|
*
|
|
|
|
|
* Looks for a CHILD SA owned by this IKE_SA and destroys it.
|
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param protocol protocol of the SA
|
|
|
|
|
* @param spi inbound SPI of the CHILD_SA
|
|
|
|
|
* @return
|
|
|
|
|
* - NOT_FOUND, if IKE_SA has no such CHILD_SA
|
|
|
|
|
* - SUCCESS
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-07 07:04:07 +00:00
|
|
|
|
status_t (*destroy_child_sa) (ike_sa_t *this, protocol_id_t protocol, u_int32_t spi);
|
2006-07-05 10:53:20 +00:00
|
|
|
|
|
2006-06-22 06:36:28 +00:00
|
|
|
|
/**
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @brief Destroys a ike_sa_t object.
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* @param this calling object
|
2006-06-22 06:36:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
void (*destroy) (ike_sa_t *this);
|
2005-11-21 16:41:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-11-08 13:33:28 +00:00
|
|
|
|
/**
|
2005-12-07 09:03:34 +00:00
|
|
|
|
* @brief Creates an ike_sa_t object with a specific ID.
|
2005-11-10 09:35:28 +00:00
|
|
|
|
*
|
2006-07-05 10:53:20 +00:00
|
|
|
|
* The ID gets cloned internally.
|
|
|
|
|
*
|
2006-07-07 07:04:07 +00:00
|
|
|
|
* @param ike_sa_id ike_sa_id_t object to associate with new IKE_SA
|
|
|
|
|
* @return ike_sa_t object
|
2005-11-29 08:08:03 +00:00
|
|
|
|
*
|
|
|
|
|
* @ingroup sa
|
2005-11-08 13:33:28 +00:00
|
|
|
|
*/
|
2006-07-05 10:53:20 +00:00
|
|
|
|
ike_sa_t *ike_sa_create(ike_sa_id_t *ike_sa_id);
|
2005-11-08 13:33:28 +00:00
|
|
|
|
|
2006-07-07 07:04:07 +00:00
|
|
|
|
#endif /* IKE_SA_H_ */
|