- Code documented

This commit is contained in:
Jan Hutter
2005-12-04 15:07:38 +00:00
parent 0743de26be
commit 813ed1cd03
2 changed files with 38 additions and 18 deletions
+33 -13
View File
@@ -33,7 +33,7 @@
/** /**
* Length of key pad in bytes. * Length of key pad in bytes.
*/ */
#define IKE_V2_KEY_PAD_LEN 17 #define IKE_V2_KEY_PAD_LEN strlen(IKE_V2_KEY_PAD)
typedef struct private_authenticator_t private_authenticator_t; typedef struct private_authenticator_t private_authenticator_t;
@@ -43,17 +43,17 @@ typedef struct private_authenticator_t private_authenticator_t;
struct private_authenticator_t { struct private_authenticator_t {
/** /**
* Public interface. * Public authenticator_t interface.
*/ */
authenticator_t public; authenticator_t public;
/** /**
* Assigned IKE_SA. Needed to get prf function. * Assigned IKE_SA. Needed to get objects of type prf_t, sa_config_t and logger_t.
*/ */
protected_ike_sa_t *ike_sa; protected_ike_sa_t *ike_sa;
/** /**
* PRF function. Taken from the IKE_SA. * PRF taken from the IKE_SA.
*/ */
prf_t *prf; prf_t *prf;
@@ -65,15 +65,38 @@ struct private_authenticator_t {
logger_t *logger; logger_t *logger;
/** /**
* TODO * Creates the octets which are signed (RSA) or MACed (shared secret) as described in section
* 2.15 of draft.
*
* @param this calling object
* @param last_message the last message to include in created octets
* (either binary form of IKE_SA_INIT request or IKE_SA_INIT response)
* @param other_nonce Nonce data received from other peer
* @param my_id id_payload_t object representing an ID payload
* @param initiator Type of peer. TRUE, if it is original initiator, FALSE otherwise
* @return octets as described in section 2.15. Memory gets allocated and has to get
* destroyed by caller.
*/ */
chunk_t (*allocate_octets) (private_authenticator_t *this,chunk_t last_message, chunk_t other_nonce,id_payload_t *my_id, bool initiator); chunk_t (*allocate_octets) (private_authenticator_t *this,chunk_t last_message, chunk_t other_nonce,id_payload_t *my_id, bool initiator);
/**
* Creates the AUTH data using auth method SHARED_KEY_MESSAGE_INTEGRITY_CODE.
*
* @param this calling object
* @param last_message the last message
* (either binary form of IKE_SA_INIT request or IKE_SA_INIT response)
* @param nonce Nonce data to include in auth data compution
* @param id_payload id_payload_t object representing an ID payload
* @param initiator Type of peer. TRUE, if it is original initiator, FALSE otherwise
* @param shared_secret shared secret as chunk_t. If shared secret is a string, the NULL termination is not included.
* @return AUTH data as dscribed in section 2.15 for AUTH method SHARED_KEY_MESSAGE_INTEGRITY_CODE.
* Memory gets allocated and has to get destroyed by caller.
*/
chunk_t (*allocate_auth_data_with_preshared_secret) (private_authenticator_t *this,chunk_t last_message, chunk_t nonce,id_payload_t *id_payload, bool initiator,chunk_t preshared_secret); chunk_t (*allocate_auth_data_with_preshared_secret) (private_authenticator_t *this,chunk_t last_message, chunk_t nonce,id_payload_t *id_payload, bool initiator,chunk_t preshared_secret);
}; };
/** /**
* Implementation of authenticator_t.private_authenticator_t. * Implementation of private_authenticator_t.allocate_octets.
*/ */
static chunk_t allocate_octets(private_authenticator_t *this,chunk_t last_message, chunk_t other_nonce,id_payload_t *my_id, bool initiator) static chunk_t allocate_octets(private_authenticator_t *this,chunk_t last_message, chunk_t other_nonce,id_payload_t *my_id, bool initiator)
{ {
@@ -84,8 +107,8 @@ static chunk_t allocate_octets(private_authenticator_t *this,chunk_t last_messag
chunk_t octets; chunk_t octets;
id_with_header[0] = my_id->get_id_type(my_id); id_with_header[0] = my_id->get_id_type(my_id);
/* TODO /* TODO:
* Reserved bytes are not in any case zero * Reserved bytes are not in any case zero.
*/ */
id_with_header[1] = 0x00; id_with_header[1] = 0x00;
id_with_header[2] = 0x00; id_with_header[2] = 0x00;
@@ -116,7 +139,7 @@ static chunk_t allocate_octets(private_authenticator_t *this,chunk_t last_messag
} }
/** /**
* Implementation of authenticator_t.allocate_auth_data_with_preshared_secret. * Implementation of private_authenticator_t.allocate_auth_data_with_preshared_secret.
*/ */
static chunk_t allocate_auth_data_with_preshared_secret (private_authenticator_t *this,chunk_t last_message, chunk_t nonce,id_payload_t *id_payload, bool initiator,chunk_t preshared_secret) static chunk_t allocate_auth_data_with_preshared_secret (private_authenticator_t *this,chunk_t last_message, chunk_t nonce,id_payload_t *id_payload, bool initiator,chunk_t preshared_secret)
{ {
@@ -142,9 +165,8 @@ static chunk_t allocate_auth_data_with_preshared_secret (private_authenticator_t
} }
/** /**
* Implementation of authenticator_t.private_authenticator_t. * Implementation of authenticator_t.verify_auth_data.
*/ */
static status_t verify_auth_data (private_authenticator_t *this,auth_payload_t *auth_payload, chunk_t last_received_packet,chunk_t my_nonce,id_payload_t *other_id_payload,bool initiator,bool *verified) static status_t verify_auth_data (private_authenticator_t *this,auth_payload_t *auth_payload, chunk_t last_received_packet,chunk_t my_nonce,id_payload_t *other_id_payload,bool initiator,bool *verified)
{ {
switch(auth_payload->get_auth_method(auth_payload)) switch(auth_payload->get_auth_method(auth_payload))
@@ -228,7 +250,6 @@ static status_t compute_auth_data (private_authenticator_t *this,auth_payload_t
{ {
sa_config_t *sa_config = this->ike_sa->get_sa_config(this->ike_sa); sa_config_t *sa_config = this->ike_sa->get_sa_config(this->ike_sa);
switch(sa_config->get_auth_method(sa_config)) switch(sa_config->get_auth_method(sa_config))
{ {
case SHARED_KEY_MESSAGE_INTEGRITY_CODE: case SHARED_KEY_MESSAGE_INTEGRITY_CODE:
@@ -237,7 +258,6 @@ static status_t compute_auth_data (private_authenticator_t *this,auth_payload_t
chunk_t preshared_secret; chunk_t preshared_secret;
status_t status; status_t status;
status = charon->configuration_manager->get_shared_secret(charon->configuration_manager,my_id,&preshared_secret); status = charon->configuration_manager->get_shared_secret(charon->configuration_manager,my_id,&preshared_secret);
my_id->destroy(my_id); my_id->destroy(my_id);
+4 -4
View File
@@ -20,11 +20,9 @@
* for more details. * for more details.
*/ */
#ifndef _AUTHENTICATOR_H_ #ifndef _AUTHENTICATOR_H_
#define _AUTHENTICATOR_H_ #define _AUTHENTICATOR_H_
#include <types.h> #include <types.h>
#include <encoding/payloads/auth_payload.h> #include <encoding/payloads/auth_payload.h>
#include <encoding/payloads/id_payload.h> #include <encoding/payloads/id_payload.h>
@@ -34,7 +32,6 @@
typedef struct authenticator_t authenticator_t; typedef struct authenticator_t authenticator_t;
/** /**
* @brief Class authenticator_t. Used to authenticate a peer. * @brief Class authenticator_t. Used to authenticate a peer.
* *
@@ -43,7 +40,8 @@ typedef struct authenticator_t authenticator_t;
* - RSA_DIGITAL_SIGNATURE * - RSA_DIGITAL_SIGNATURE
* *
* This class retrieves needed data for specific AUTH methods (RSA keys, shared secrets, etc.) * This class retrieves needed data for specific AUTH methods (RSA keys, shared secrets, etc.)
* over an internal stored protected_ike_sa_t object or directly from the configuration_manager_t. * over an internal stored protected_ike_sa_t object or directly from the configuration_manager_t over
* the daemon_t object charon.
* *
* @ingroup sa * @ingroup sa
*/ */
@@ -127,6 +125,8 @@ struct authenticator_t {
* This preconditions are not given in IKE_SA states INITIATOR_INIT or RESPONDER_INIT! * This preconditions are not given in IKE_SA states INITIATOR_INIT or RESPONDER_INIT!
* *
* @param ike_sa object of type protected_ike_sa_t * @param ike_sa object of type protected_ike_sa_t
*
* @ingroup sa
*/ */
authenticator_t *authenticator_create(protected_ike_sa_t *ike_sa); authenticator_t *authenticator_create(protected_ike_sa_t *ike_sa);