- fixed bugs
This commit is contained in:
@@ -892,6 +892,7 @@ static status_t decrypt_and_verify_payloads (private_message_t *this,crypter_t *
|
||||
|
||||
if (encryption_payload->get_payload_count(encryption_payload) == 0)
|
||||
{
|
||||
this->logger->log(this->logger, CONTROL | MORE, "Encrypted payload is empty");
|
||||
iterator->remove(iterator);
|
||||
encryption_payload->destroy(encryption_payload);
|
||||
/* encrypted payload contains no other payload */
|
||||
@@ -908,10 +909,13 @@ static status_t decrypt_and_verify_payloads (private_message_t *this,crypter_t *
|
||||
* Set the next payload of proceeding payload
|
||||
* to the first payload of encrypted ones */
|
||||
last_payload->set_next_type(last_payload,current_payload_type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
this->logger->log(this->logger, CONTROL | MORE, "Encrypted payload is not empty");
|
||||
|
||||
/* encryption_payload is replaced with first encrypted payload*/
|
||||
encryption_payload->remove_first_payload(encryption_payload, ¤t_encrypted_payload);
|
||||
|
||||
|
||||
@@ -814,7 +814,7 @@ static status_t parse_payload(private_parser_t *this, payload_type_t payload_typ
|
||||
{
|
||||
pld->destroy(pld);
|
||||
return PARSE_ERROR;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AUTH_DATA:
|
||||
|
||||
@@ -388,9 +388,7 @@ static status_t decrypt(private_encryption_payload_t *this)
|
||||
/* free padding */
|
||||
this->decrypted.ptr = allocator_realloc(this->decrypted.ptr, this->decrypted.len);
|
||||
|
||||
this->parse(this);
|
||||
|
||||
return SUCCESS;
|
||||
return (this->parse(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -539,9 +537,11 @@ static status_t parse(private_encryption_payload_t *this)
|
||||
return PARSE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
status = current_payload->verify(current_payload);
|
||||
if (status != SUCCESS)
|
||||
{
|
||||
current_payload->destroy(current_payload);
|
||||
parser->destroy(parser);
|
||||
return VERIFY_ERROR;
|
||||
}
|
||||
|
||||
@@ -25,21 +25,6 @@
|
||||
#include <encoding/payloads/encodings.h>
|
||||
#include <utils/allocator.h>
|
||||
|
||||
/**
|
||||
* String mappings for id_type_t.
|
||||
*/
|
||||
mapping_t id_type_m[] = {
|
||||
{ID_IPV4_ADDR, "ID_IPV4_ADDR"},
|
||||
{ID_FQDN, "ID_FQDN"},
|
||||
{ID_RFC822_ADDR, "ID_RFC822_ADDR"},
|
||||
{ID_IPV6_ADDR, "ID_IPV6_ADDR"},
|
||||
{ID_DER_ASN1_DN, "ID_DER_ASN1_DN"},
|
||||
{ID_DER_ASN1_GN, "ID_DER_ASN1_GN"},
|
||||
{ID_KEY_ID, "ID_KEY_ID"},
|
||||
{MAPPING_END, NULL}
|
||||
};
|
||||
|
||||
|
||||
typedef struct private_id_payload_t private_id_payload_t;
|
||||
|
||||
/**
|
||||
@@ -108,11 +93,11 @@ encoding_rule_t id_payload_encodings[] = {
|
||||
/* 1 Byte ID type*/
|
||||
{ U_INT_8, offsetof(private_id_payload_t, id_type) },
|
||||
/* 3 reserved bytes */
|
||||
{ RESERVED_BYTE, 0 },
|
||||
{ RESERVED_BYTE, 0 },
|
||||
{ RESERVED_BYTE, 0 },
|
||||
{ RESERVED_BYTE, 0 },
|
||||
{ RESERVED_BYTE, 0 },
|
||||
{ RESERVED_BYTE, 0 },
|
||||
/* some id data bytes, length is defined in PAYLOAD_LENGTH */
|
||||
{ ID_DATA, offsetof(private_id_payload_t, id_data) }
|
||||
{ ID_DATA, offsetof(private_id_payload_t, id_data) }
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -260,6 +245,14 @@ static void set_initiator (private_id_payload_t *this,bool is_initiator)
|
||||
this->is_initiator = is_initiator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of id_payload_t.get_identification.
|
||||
*/
|
||||
static identification_t * get_identification (private_id_payload_t *this)
|
||||
{
|
||||
return identification_create_from_encoding(this->id_type,this->id_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of payload_t.destroy and id_payload_t.destroy.
|
||||
*/
|
||||
@@ -274,7 +267,7 @@ static void destroy(private_id_payload_t *this)
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
* Described in header.
|
||||
*/
|
||||
id_payload_t *id_payload_create(bool is_initiator)
|
||||
{
|
||||
@@ -297,6 +290,7 @@ id_payload_t *id_payload_create(bool is_initiator)
|
||||
this->public.get_data = (chunk_t (*) (id_payload_t *)) get_data;
|
||||
this->public.get_initiator = (bool (*) (id_payload_t *)) get_initiator;
|
||||
this->public.set_initiator = (void (*) (id_payload_t *,bool)) set_initiator;
|
||||
this->public.get_identification = (identification_t * (*) (id_payload_t *this)) get_identification;
|
||||
|
||||
/* private variables */
|
||||
this->critical = FALSE;
|
||||
@@ -307,3 +301,14 @@ id_payload_t *id_payload_create(bool is_initiator)
|
||||
|
||||
return (&(this->public));
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
id_payload_t *id_payload_create_from_identification(bool is_initiator,identification_t *identification)
|
||||
{
|
||||
id_payload_t *this= id_payload_create(is_initiator);
|
||||
this->set_data(this,identification->get_encoding(identification));
|
||||
this->set_id_type(this,identification->get_type(identification));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#define _ID_PAYLOAD_H_
|
||||
|
||||
#include <types.h>
|
||||
#include <utils/identification.h>
|
||||
#include <encoding/payloads/payload.h>
|
||||
|
||||
/**
|
||||
@@ -35,61 +36,6 @@
|
||||
#define ID_PAYLOAD_HEADER_LENGTH 8
|
||||
|
||||
|
||||
typedef enum id_type_t id_type_t;
|
||||
|
||||
/**
|
||||
* ID Types of a ID payload.
|
||||
*
|
||||
* @ingroup payloads
|
||||
*/
|
||||
enum id_type_t {
|
||||
/**
|
||||
* ID data is a single four (4) octet IPv4 address.
|
||||
*/
|
||||
ID_IPV4_ADDR = 1,
|
||||
|
||||
/**
|
||||
* ID data is a fully-qualified domain name string.
|
||||
* An example of a ID_FQDN is, "example.com".
|
||||
* The string MUST not contain any terminators (e.g., NULL, CR, etc.).
|
||||
*/
|
||||
ID_FQDN = 2,
|
||||
|
||||
/**
|
||||
* ID data is a fully-qualified RFC822 email address string, An example of
|
||||
* a ID_RFC822_ADDR is, "[email protected]". The string MUST
|
||||
* not contain any terminators.
|
||||
*/
|
||||
ID_RFC822_ADDR = 3,
|
||||
|
||||
/**
|
||||
* ID data is a single sixteen (16) octet IPv6 address.
|
||||
*/
|
||||
ID_IPV6_ADDR = 5,
|
||||
|
||||
/**
|
||||
* ID data is the binary DER encoding of an ASN.1 X.500 Distinguished Name
|
||||
* [X.501].
|
||||
*/
|
||||
ID_DER_ASN1_DN = 9,
|
||||
|
||||
/**
|
||||
* ID data is the binary DER encoding of an ASN.1 X.500 GeneralName
|
||||
* [X.509].
|
||||
*/
|
||||
ID_DER_ASN1_GN = 10,
|
||||
|
||||
/**
|
||||
* ID data is an opaque octet stream which may be used to pass vendor-
|
||||
* specific information necessary to do certain proprietary
|
||||
* types of identification.
|
||||
*/
|
||||
ID_KEY_ID = 11
|
||||
};
|
||||
|
||||
extern mapping_t id_type_m[];
|
||||
|
||||
|
||||
typedef struct id_payload_t id_payload_t;
|
||||
|
||||
/**
|
||||
@@ -143,6 +89,18 @@ struct id_payload_t {
|
||||
*/
|
||||
chunk_t (*get_data) (id_payload_t *this);
|
||||
|
||||
/**
|
||||
* @brief Creates an identification object of this id payload.
|
||||
*
|
||||
* Returned object has to get destroyed by the caller.
|
||||
*
|
||||
* @param this calling id_payload_t object
|
||||
* @return
|
||||
* - identification_t object
|
||||
* - NULL if ID type not supported
|
||||
*/
|
||||
identification_t *(*get_identification) (id_payload_t *this);
|
||||
|
||||
/**
|
||||
* @brief Get the type of ID payload (IDi or IDr).
|
||||
*
|
||||
@@ -186,5 +144,19 @@ struct id_payload_t {
|
||||
*/
|
||||
id_payload_t *id_payload_create(bool is_initiator);
|
||||
|
||||
/**
|
||||
* @brief Creates an id_payload_t from an existing identification_t object.
|
||||
*
|
||||
* @param is_initiator
|
||||
* - TRUE if this payload is of type IDi
|
||||
* - FALSE if this payload is of type IDr
|
||||
* @param identification identification_t object
|
||||
* @return created id_payload_t object
|
||||
*
|
||||
* @ingroup payloads
|
||||
*/
|
||||
id_payload_t *id_payload_create_from_identification(bool is_initiator,identification_t *identification);
|
||||
|
||||
|
||||
|
||||
#endif //_ID_PAYLOAD_H_
|
||||
|
||||
Reference in New Issue
Block a user