From c3dc864eaa5cebae57be1b0e9339f2e7ebdbfe15 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Tue, 6 Dec 2005 13:44:22 +0000 Subject: - code cleanup of encoding package --- Source/charon/encoding/payloads/nonce_payload.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'Source/charon/encoding/payloads/nonce_payload.c') diff --git a/Source/charon/encoding/payloads/nonce_payload.c b/Source/charon/encoding/payloads/nonce_payload.c index 5070e1987..63f1adddd 100644 --- a/Source/charon/encoding/payloads/nonce_payload.c +++ b/Source/charon/encoding/payloads/nonce_payload.c @@ -130,24 +130,21 @@ static status_t verify(private_nonce_payload_t *this) */ static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce) { - if (nonce.len >= 16 && nonce.len <= 256) - { - - this->nonce.ptr = allocator_clone_bytes(nonce.ptr, nonce.len); - this->nonce.len = nonce.len; - this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len; - return SUCCESS; - } - return INVALID_ARG; + this->nonce.ptr = allocator_clone_bytes(nonce.ptr, nonce.len); + this->nonce.len = nonce.len; + this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len; + return SUCCESS; } /** * Implementation of nonce_payload_t.get_nonce. */ -static void get_nonce(private_nonce_payload_t *this, chunk_t *nonce) +static chunk_t get_nonce(private_nonce_payload_t *this) { - nonce->ptr = allocator_clone_bytes(this->nonce.ptr,this->nonce.len); - nonce->len = this->nonce.len; + chunk_t nonce; + nonce.ptr = allocator_clone_bytes(this->nonce.ptr,this->nonce.len); + nonce.len = this->nonce.len; + return nonce; } /** @@ -231,8 +228,8 @@ nonce_payload_t *nonce_payload_create() /* public functions */ this->public.destroy = (void (*) (nonce_payload_t *)) destroy; - this->public.set_nonce = (status_t (*) (nonce_payload_t *,chunk_t)) set_nonce; - this->public.get_nonce = (void (*) (nonce_payload_t *,chunk_t*)) get_nonce; + this->public.set_nonce = (void (*) (nonce_payload_t *,chunk_t)) set_nonce; + this->public.get_nonce = (chunk_t (*) (nonce_payload_t *)) get_nonce; /* private functions */ this->compute_length = compute_length; -- cgit v1.2.3