*/
static payload_type_t get_next_type(private_ke_payload_t *this)
{
- return (this->next_payload);
+ return this->next_payload;
}
/**
static void compute_length(private_ke_payload_t *this)
{
size_t length = KE_PAYLOAD_HEADER_LENGTH;
+
if (this->key_exchange_data.ptr != NULL)
{
length += this->key_exchange_data.len;
*/
static size_t get_length(private_ke_payload_t *this)
{
- compute_length(this);
return this->payload_length;
}
*/
static chunk_t get_key_exchange_data(private_ke_payload_t *this)
{
- return (this->key_exchange_data);
-}
-
-/**
- * Implementation of ke_payload_t.set_key_exchange_data.
- */
-static void set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchange_data)
-{
- /* destroy existing data first */
- if (this->key_exchange_data.ptr != NULL)
- {
- /* free existing value */
- free(this->key_exchange_data.ptr);
- this->key_exchange_data.ptr = NULL;
- this->key_exchange_data.len = 0;
-
- }
-
- this->key_exchange_data = chunk_clone(key_exchange_data);
- compute_length(this);
+ return this->key_exchange_data;
}
/**
/* public functions */
this->public.get_key_exchange_data = (chunk_t (*) (ke_payload_t *)) get_key_exchange_data;
- this->public.set_key_exchange_data = (void (*) (ke_payload_t *,chunk_t)) set_key_exchange_data;
this->public.get_dh_group_number = (diffie_hellman_group_t (*) (ke_payload_t *)) get_dh_group_number;
this->public.set_dh_group_number =(void (*) (ke_payload_t *,diffie_hellman_group_t)) set_dh_group_number;
this->public.destroy = (void (*) (ke_payload_t *)) destroy;
*/
chunk_t (*get_key_exchange_data) (ke_payload_t *this);
- /**
- * Sets the key exchange data of this KE payload.
- *
- * Value is getting copied.
- *
- * @param key_exchange_data chunk_t pointing to the value to set
- */
- void (*set_key_exchange_data) (ke_payload_t *this, chunk_t key_exchange_data);
-
/**
* Gets the Diffie-Hellman Group Number of this KE payload.
*
/* Length of the whole nonce payload*/
{ PAYLOAD_LENGTH, offsetof(private_nonce_payload_t, payload_length) },
/* some nonce bytes, lenth is defined in PAYLOAD_LENGTH */
- { NONCE_DATA, offsetof(private_nonce_payload_t, nonce) }
+ { NONCE_DATA, offsetof(private_nonce_payload_t, nonce) },
};
/* 1 2 3
*/
static status_t verify(private_nonce_payload_t *this)
{
- if ((this->nonce.len < 16) || ((this->nonce.len > 256)))
+ if (this->nonce.len < 16 || this->nonce.len > 256)
{
- /* nonce length is wrong */
return FAILED;
}
-
return SUCCESS;
}
*/
static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
{
- this->nonce.ptr = clalloc(nonce.ptr, nonce.len);
- this->nonce.len = nonce.len;
+ this->nonce = chunk_clone(nonce);
this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
return SUCCESS;
}
*/
static chunk_t get_nonce(private_nonce_payload_t *this)
{
- chunk_t nonce;
- nonce.ptr = clalloc(this->nonce.ptr,this->nonce.len);
- nonce.len = this->nonce.len;
- return nonce;
+ return chunk_clone(this->nonce);
}
/**
*/
static payload_type_t get_next_type(private_nonce_payload_t *this)
{
- return (this->next_payload);
+ return this->next_payload;
}
/**
this->next_payload = type;
}
-/**
- * recompute the length of the payload.
- */
-static void compute_length(private_nonce_payload_t *this)
-{
- this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + this->nonce.len;
-}
-
/**
* Implementation of payload_t.get_length.
*/
static size_t get_length(private_nonce_payload_t *this)
{
- compute_length(this);
return this->payload_length;
}
{
free(this->nonce.ptr);
}
-
free(this);
}
*/
static size_t get_length(private_notify_payload_t *this)
{
- compute_length(this);
return this->payload_length;
}
METHOD(payload_t, get_length, size_t,
private_proposal_substructure_t *this)
{
- compute_length(this);
return this->proposal_length;
}
add_transform_substructure(clone, current);
}
enumerator->destroy(enumerator);
+ compute_length(clone);
return &clone->public;
}
.destroy = _destroy,
},
.next_payload = NO_PAYLOAD,
+ .proposal_length = PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH,
.transforms = linked_list_create(),
);
}
this->proposal_number = proposal->get_number(proposal);
this->protocol_id = proposal->get_protocol(proposal);
+ compute_length(this);
return &this->public;
}
METHOD(payload_t, get_length, size_t,
private_sa_payload_t *this)
{
- compute_length(this);
return this->payload_length;
}
*/
static size_t get_length(private_transform_substructure_t *this)
{
- compute_length(this);
return this->transform_length;
}
*/
static size_t get_length(private_ts_payload_t *this)
{
- compute_length(this);
return this->payload_length;
}
{
this->traffic_selectors->insert_last(this->traffic_selectors,traffic_selector);
this->number_of_traffic_selectors = this->traffic_selectors->get_count(this->traffic_selectors);
+ compute_length(this);
}
/**