diff options
Diffstat (limited to 'Source/charon/sa')
-rw-r--r-- | Source/charon/sa/authenticator.c | 29 | ||||
-rw-r--r-- | Source/charon/sa/child_sa.c | 21 | ||||
-rw-r--r-- | Source/charon/sa/ike_sa.c | 34 | ||||
-rw-r--r-- | Source/charon/sa/ike_sa_id.c | 5 | ||||
-rw-r--r-- | Source/charon/sa/ike_sa_manager.c | 11 | ||||
-rw-r--r-- | Source/charon/sa/states/ike_auth_requested.c | 29 | ||||
-rw-r--r-- | Source/charon/sa/states/ike_sa_established.c | 7 | ||||
-rw-r--r-- | Source/charon/sa/states/ike_sa_init_requested.c | 19 | ||||
-rw-r--r-- | Source/charon/sa/states/ike_sa_init_responded.c | 33 | ||||
-rw-r--r-- | Source/charon/sa/states/initiator_init.c | 13 | ||||
-rw-r--r-- | Source/charon/sa/states/responder_init.c | 17 |
11 files changed, 107 insertions, 111 deletions
diff --git a/Source/charon/sa/authenticator.c b/Source/charon/sa/authenticator.c index 9c2a05cb3..32817b0a1 100644 --- a/Source/charon/sa/authenticator.c +++ b/Source/charon/sa/authenticator.c @@ -20,9 +20,10 @@ * for more details. */ +#include <string.h> + #include "authenticator.h" -#include <utils/allocator.h> #include <daemon.h> /** @@ -141,7 +142,7 @@ static chunk_t allocate_octets(private_authenticator_t *this, /* 4 bytes are id type and reserved fields of id payload */ octets.len = last_message.len + other_nonce.len + prf->get_block_size(prf); - octets.ptr = allocator_alloc(octets.len); + octets.ptr = malloc(octets.len); current_pos = octets.ptr; memcpy(current_pos,last_message.ptr,last_message.len); current_pos += last_message.len; @@ -175,7 +176,7 @@ static chunk_t build_preshared_secret_signature(private_authenticator_t *this, this->prf->get_bytes(this->prf, key_pad, key_buffer); this->prf->set_key(this->prf, key); this->prf->allocate_bytes(this->prf, octets, &auth_data); - allocator_free_chunk(&octets); + chunk_free(&octets); this->logger->log_chunk(this->logger,RAW | LEVEL2, "Authenticated data",auth_data); return auth_data; @@ -217,11 +218,11 @@ static status_t verify_auth_data (private_authenticator_t *this, other_id_payload, initiator, preshared_secret); - allocator_free_chunk(&preshared_secret); + chunk_free(&preshared_secret); if (auth_data.len != my_auth_data.len) { - allocator_free_chunk(&my_auth_data); + chunk_free(&my_auth_data); status = FAILED; } else if (memcmp(auth_data.ptr,my_auth_data.ptr, my_auth_data.len) == 0) @@ -237,7 +238,7 @@ static status_t verify_auth_data (private_authenticator_t *this, status = FAILED; } other_id->destroy(other_id); - allocator_free_chunk(&my_auth_data); + chunk_free(&my_auth_data); return status; } case RSA_DIGITAL_SIGNATURE: @@ -276,7 +277,7 @@ static status_t verify_auth_data (private_authenticator_t *this, public_key->destroy(public_key); other_id->destroy(other_id); - allocator_free_chunk(&octets); + chunk_free(&octets); return status; } default: @@ -322,12 +323,12 @@ static status_t compute_auth_data (private_authenticator_t *this, auth_data = this->build_preshared_secret_signature(this, last_sent_packet, other_nonce, my_id_payload, initiator, preshared_secret); - allocator_free_chunk(&preshared_secret); + chunk_free(&preshared_secret); *auth_payload = auth_payload_create(); (*auth_payload)->set_auth_method(*auth_payload, SHARED_KEY_MESSAGE_INTEGRITY_CODE); (*auth_payload)->set_data(*auth_payload, auth_data); - allocator_free_chunk(&auth_data); + chunk_free(&auth_data); return SUCCESS; } case RSA_DIGITAL_SIGNATURE: @@ -350,7 +351,7 @@ static status_t compute_auth_data (private_authenticator_t *this, octets = this->allocate_octets(this,last_sent_packet,other_nonce,my_id_payload,initiator); status = private_key->build_emsa_pkcs1_signature(private_key, HASH_SHA1, octets, &auth_data); - allocator_free_chunk(&octets); + chunk_free(&octets); if (status != SUCCESS) { private_key->destroy(private_key); @@ -362,7 +363,7 @@ static status_t compute_auth_data (private_authenticator_t *this, (*auth_payload)->set_data(*auth_payload, auth_data); private_key->destroy(private_key); - allocator_free_chunk(&auth_data); + chunk_free(&auth_data); return SUCCESS; } default: @@ -377,7 +378,7 @@ static status_t compute_auth_data (private_authenticator_t *this, */ static void destroy (private_authenticator_t *this) { - allocator_free(this); + free(this); } /* @@ -385,7 +386,7 @@ static void destroy (private_authenticator_t *this) */ authenticator_t *authenticator_create(protected_ike_sa_t *ike_sa) { - private_authenticator_t *this = allocator_alloc_thing(private_authenticator_t); + private_authenticator_t *this = malloc_thing(private_authenticator_t); /* Public functions */ this->public.destroy = (void(*)(authenticator_t*))destroy; @@ -399,7 +400,7 @@ authenticator_t *authenticator_create(protected_ike_sa_t *ike_sa) /* private data */ this->ike_sa = ike_sa; this->prf = this->ike_sa->get_prf(this->ike_sa); - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); return &(this->public); } diff --git a/Source/charon/sa/child_sa.c b/Source/charon/sa/child_sa.c index 7f19f87e6..fd82f123b 100644 --- a/Source/charon/sa/child_sa.c +++ b/Source/charon/sa/child_sa.c @@ -23,7 +23,6 @@ #include "child_sa.h" -#include <utils/allocator.h> #include <daemon.h> @@ -305,11 +304,11 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal, prf_plus /* clean up for next round */ if (enc_algo != ENCR_UNDEFINED) { - allocator_free_chunk(&enc_key); + chunk_free(&enc_key); } if (int_algo != AUTH_UNDEFINED) { - allocator_free_chunk(&int_key); + chunk_free(&int_key); } if (status != SUCCESS) @@ -396,7 +395,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list { continue; } - policy = allocator_alloc_thing(sa_policy_t); + policy = malloc_thing(sa_policy_t); policy->upper_proto = my_ts->get_protocol(my_ts); /* calculate net and ports for local side */ @@ -407,7 +406,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list from_port = (from_port != to_port) ? 0 : from_port; policy->my_net = host_create_from_chunk(family, from_addr, from_port); policy->my_net_mask = my_ts->get_netmask(my_ts); - allocator_free_chunk(&from_addr); + chunk_free(&from_addr); /* calculate net and ports for remote side */ family = other_ts->get_type(other_ts) == TS_IPV4_ADDR_RANGE ? AF_INET : AF_INET6; @@ -417,7 +416,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list from_port = (from_port != to_port) ? 0 : from_port; policy->other_net = host_create_from_chunk(family, from_addr, from_port); policy->other_net_mask = other_ts->get_netmask(other_ts); - allocator_free_chunk(&from_addr); + chunk_free(&from_addr); /* install 3 policies: out, in and forward */ status = charon->kernel_interface->add_policy(charon->kernel_interface, @@ -448,7 +447,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list { my_iter->destroy(my_iter); other_iter->destroy(other_iter); - allocator_free(policy); + free(policy); return status; } @@ -491,7 +490,7 @@ static void destroy(private_child_sa_t *this) policy->my_net->destroy(policy->my_net); policy->other_net->destroy(policy->other_net); - allocator_free(policy); + free(policy); } this->policies->destroy(this->policies); @@ -510,7 +509,7 @@ static void destroy(private_child_sa_t *this) charon->kernel_interface->del_sa(charon->kernel_interface, this->me, this->other_esp_spi, PROTO_ESP); } - allocator_free(this); + free(this); } /* @@ -519,7 +518,7 @@ static void destroy(private_child_sa_t *this) child_sa_t * child_sa_create(host_t *me, host_t* other) { static u_int32_t reqid = 0xc0000000; - private_child_sa_t *this = allocator_alloc_thing(private_child_sa_t); + private_child_sa_t *this = malloc_thing(private_child_sa_t); /* public functions */ this->public.alloc = (status_t(*)(child_sa_t*,linked_list_t*))alloc; @@ -529,7 +528,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other) this->public.destroy = (void(*)(child_sa_t*))destroy; /* private data */ - this->logger = charon->logger_manager->get_logger(charon->logger_manager, CHILD_SA); + this->logger = logger_manager->get_logger(logger_manager, CHILD_SA); this->me = me; this->other = other; this->my_ah_spi = 0; diff --git a/Source/charon/sa/ike_sa.c b/Source/charon/sa/ike_sa.c index 43de291d1..63879f1f2 100644 --- a/Source/charon/sa/ike_sa.c +++ b/Source/charon/sa/ike_sa.c @@ -19,13 +19,13 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ +#include <string.h> #include "ike_sa.h" #include <types.h> #include <daemon.h> #include <definitions.h> -#include <utils/allocator.h> #include <utils/linked_list.h> #include <utils/logger_manager.h> #include <utils/randomizer.h> @@ -526,12 +526,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d } /* concatenate nonces = nonce_i | nonce_r */ - nonces = allocator_alloc_as_chunk(nonce_i.len + nonce_r.len); + nonces = chunk_alloc(nonce_i.len + nonce_r.len); memcpy(nonces.ptr, nonce_i.ptr, nonce_i.len); memcpy(nonces.ptr + nonce_i.len, nonce_r.ptr, nonce_r.len); /* concatenate prf_seed = nonce_i | nonce_r | spi_i | spi_r */ - nonces_spis = allocator_alloc_as_chunk(nonces.len + 16); + nonces_spis = chunk_alloc(nonces.len + 16); memcpy(nonces_spis.ptr, nonces.ptr, nonces.len); spi_i = this->ike_sa_id->get_initiator_spi(this->ike_sa_id); spi_r = this->ike_sa_id->get_responder_spi(this->ike_sa_id); @@ -544,7 +544,7 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d this->prf->set_key(this->prf, nonces); this->prf->allocate_bytes(this->prf, secret, &skeyseed); this->logger->log_chunk(this->logger, PRIVATE | LEVEL1, "SKEYSEED", skeyseed); - allocator_free_chunk(&secret); + chunk_free(&secret); /* prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr ) * = SK_d | SK_ai | SK_ar | SK_ei | SK_er | SK_pi | SK_pr @@ -555,9 +555,9 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d prf_plus = prf_plus_create(this->prf, nonces_spis); /* clean up unused stuff */ - allocator_free_chunk(&nonces); - allocator_free_chunk(&nonces_spis); - allocator_free_chunk(&skeyseed); + chunk_free(&nonces); + chunk_free(&nonces_spis); + chunk_free(&skeyseed); /* @@ -572,7 +572,7 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_d secret", key); this->child_prf->set_key(this->child_prf, key); - allocator_free_chunk(&key); + chunk_free(&key); /* SK_ai/SK_ar used for integrity protection */ @@ -605,12 +605,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_ai secret", key); this->signer_initiator->set_key(this->signer_initiator, key); - allocator_free_chunk(&key); + chunk_free(&key); prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_ar secret", key); this->signer_responder->set_key(this->signer_responder, key); - allocator_free_chunk(&key); + chunk_free(&key); /* SK_ei/SK_er used for encryption */ @@ -644,12 +644,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_ei secret", key); this->crypter_initiator->set_key(this->crypter_initiator, key); - allocator_free_chunk(&key); + chunk_free(&key); prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_er secret", key); this->crypter_responder->set_key(this->crypter_responder, key); - allocator_free_chunk(&key); + chunk_free(&key); /* SK_pi/SK_pr used for authentication */ proposal->get_algorithm(proposal, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, &algo); @@ -669,12 +669,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_pi secret", key); this->prf_auth_i->set_key(this->prf_auth_i, key); - allocator_free_chunk(&key); + chunk_free(&key); prf_plus->allocate_bytes(prf_plus, key_size, &key); this->logger->log_chunk(this->logger, PRIVATE, "Sk_pr secret", key); this->prf_auth_r->set_key(this->prf_auth_r, key); - allocator_free_chunk(&key); + chunk_free(&key); /* all done, prf_plus not needed anymore */ prf_plus->destroy(prf_plus); @@ -1038,7 +1038,7 @@ static void destroy (private_ike_sa_t *this) this->randomizer->destroy(this->randomizer); this->current_state->destroy(this->current_state); - allocator_free(this); + free(this); } /* @@ -1046,7 +1046,7 @@ static void destroy (private_ike_sa_t *this) */ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id) { - private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t); + private_ike_sa_t *this = malloc_thing(private_ike_sa_t); /* Public functions */ this->protected.public.process_message = (status_t(*)(ike_sa_t*, message_t*)) process_message; @@ -1090,7 +1090,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id) this->resend_last_reply = resend_last_reply; /* initialize private fields */ - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); this->ike_sa_id = ike_sa_id->clone(ike_sa_id); this->child_sas = linked_list_create(); diff --git a/Source/charon/sa/ike_sa_id.c b/Source/charon/sa/ike_sa_id.c index b4c285fcb..bf3a05d11 100644 --- a/Source/charon/sa/ike_sa_id.c +++ b/Source/charon/sa/ike_sa_id.c @@ -23,7 +23,6 @@ #include "ike_sa_id.h" -#include <utils/allocator.h> typedef struct private_ike_sa_id_t private_ike_sa_id_t; @@ -155,7 +154,7 @@ static ike_sa_id_t* clone(private_ike_sa_id_t *this) */ static void destroy(private_ike_sa_id_t *this) { - allocator_free(this); + free(this); } /* @@ -163,7 +162,7 @@ static void destroy(private_ike_sa_id_t *this) */ ike_sa_id_t * ike_sa_id_create(u_int64_t initiator_spi, u_int64_t responder_spi, bool is_initiator_flag) { - private_ike_sa_id_t *this = allocator_alloc_thing(private_ike_sa_id_t); + private_ike_sa_id_t *this = malloc_thing(private_ike_sa_id_t); /* public functions */ this->public.set_responder_spi = (void(*)(ike_sa_id_t*,u_int64_t)) set_responder_spi; diff --git a/Source/charon/sa/ike_sa_manager.c b/Source/charon/sa/ike_sa_manager.c index 2838d2b8a..d0120fa7e 100644 --- a/Source/charon/sa/ike_sa_manager.c +++ b/Source/charon/sa/ike_sa_manager.c @@ -27,7 +27,6 @@ #include <daemon.h> #include <sa/ike_sa_id.h> -#include <utils/allocator.h> #include <utils/logger.h> #include <utils/logger_manager.h> #include <utils/linked_list.h> @@ -87,7 +86,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this) /* also destroy IKE SA */ this->ike_sa->destroy(this->ike_sa); this->ike_sa_id->destroy(this->ike_sa_id); - allocator_free(this); + free(this); return SUCCESS; } @@ -101,7 +100,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this) */ static ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id) { - ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t); + ike_sa_entry_t *this = malloc_thing(ike_sa_entry_t); /* destroy function */ this->destroy = ike_sa_entry_destroy; @@ -752,7 +751,7 @@ static void destroy(private_ike_sa_manager_t *this) this->logger->log(this->logger,CONTROL | LEVEL2,"IKE_SA's deleted"); pthread_mutex_unlock(&(this->mutex)); - allocator_free(this); + free(this); } /* @@ -760,7 +759,7 @@ static void destroy(private_ike_sa_manager_t *this) */ ike_sa_manager_t *ike_sa_manager_create() { - private_ike_sa_manager_t *this = allocator_alloc_thing(private_ike_sa_manager_t); + private_ike_sa_manager_t *this = malloc_thing(private_ike_sa_manager_t); /* assign public functions */ this->public.destroy = (void(*)(ike_sa_manager_t*))destroy; @@ -779,7 +778,7 @@ ike_sa_manager_t *ike_sa_manager_create() this->delete_entry = delete_entry; /* initialize private variables */ - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA_MANAGER); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA_MANAGER); this->ike_sa_list = linked_list_create(); diff --git a/Source/charon/sa/states/ike_auth_requested.c b/Source/charon/sa/states/ike_auth_requested.c index b037cfcd9..00c38a887 100644 --- a/Source/charon/sa/states/ike_auth_requested.c +++ b/Source/charon/sa/states/ike_auth_requested.c @@ -19,11 +19,12 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ - + +#include <string.h> + #include "ike_auth_requested.h" #include <daemon.h> -#include <utils/allocator.h> #include <encoding/payloads/ts_payload.h> #include <encoding/payloads/sa_payload.h> #include <encoding/payloads/id_payload.h> @@ -329,11 +330,11 @@ static status_t process_message(private_ike_auth_requested_t *this, message_t *i } else { - seed = allocator_alloc_as_chunk(this->sent_nonce.len + this->received_nonce.len); + seed = chunk_alloc(this->sent_nonce.len + this->received_nonce.len); memcpy(seed.ptr, this->sent_nonce.ptr, this->sent_nonce.len); memcpy(seed.ptr + this->sent_nonce.len, this->received_nonce.ptr, this->received_nonce.len); prf_plus = prf_plus_create(this->ike_sa->get_child_prf(this->ike_sa), seed); - allocator_free_chunk(&seed); + chunk_free(&seed); status = this->child_sa->update(this->child_sa, this->proposal, prf_plus); prf_plus->destroy(prf_plus); @@ -571,9 +572,9 @@ static ike_sa_state_t get_state(private_ike_auth_requested_t *this) */ static void destroy(private_ike_auth_requested_t *this) { - allocator_free_chunk(&(this->received_nonce)); - allocator_free_chunk(&(this->sent_nonce)); - allocator_free_chunk(&(this->ike_sa_init_reply_data)); + chunk_free(&(this->received_nonce)); + chunk_free(&(this->sent_nonce)); + chunk_free(&(this->ike_sa_init_reply_data)); if (this->child_sa) { this->child_sa->destroy(this->child_sa); @@ -600,16 +601,16 @@ static void destroy(private_ike_auth_requested_t *this) { this->proposal->destroy(this->proposal); } - allocator_free(this); + free(this); } /** * Implements protected_ike_sa_t.destroy_after_state_change */ static void destroy_after_state_change(private_ike_auth_requested_t *this) { - allocator_free_chunk(&(this->received_nonce)); - allocator_free_chunk(&(this->sent_nonce)); - allocator_free_chunk(&(this->ike_sa_init_reply_data)); + chunk_free(&(this->received_nonce)); + chunk_free(&(this->sent_nonce)); + chunk_free(&(this->ike_sa_init_reply_data)); if (this->my_ts) { traffic_selector_t *ts; @@ -632,7 +633,7 @@ static void destroy_after_state_change(private_ike_auth_requested_t *this) { this->proposal->destroy(this->proposal); } - allocator_free(this); + free(this); } /* @@ -640,7 +641,7 @@ static void destroy_after_state_change(private_ike_auth_requested_t *this) */ ike_auth_requested_t *ike_auth_requested_create(protected_ike_sa_t *ike_sa,chunk_t sent_nonce,chunk_t received_nonce,chunk_t ike_sa_init_reply_data, child_sa_t *child_sa) { - private_ike_auth_requested_t *this = allocator_alloc_thing(private_ike_auth_requested_t); + private_ike_auth_requested_t *this = malloc_thing(private_ike_auth_requested_t); /* interface functions */ this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message; @@ -660,7 +661,7 @@ ike_auth_requested_t *ike_auth_requested_create(protected_ike_sa_t *ike_sa,chunk this->received_nonce = received_nonce; this->sent_nonce = sent_nonce; this->ike_sa_init_reply_data = ike_sa_init_reply_data; - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); this->my_ts = NULL; this->other_ts = NULL; this->proposal = NULL; diff --git a/Source/charon/sa/states/ike_sa_established.c b/Source/charon/sa/states/ike_sa_established.c index f96734423..e91409f6a 100644 --- a/Source/charon/sa/states/ike_sa_established.c +++ b/Source/charon/sa/states/ike_sa_established.c @@ -23,7 +23,6 @@ #include "ike_sa_established.h" #include <daemon.h> -#include <utils/allocator.h> #include <encoding/payloads/delete_payload.h> @@ -214,7 +213,7 @@ static ike_sa_state_t get_state(private_ike_sa_established_t *this) */ static void destroy(private_ike_sa_established_t *this) { - allocator_free(this); + free(this); } /* @@ -222,7 +221,7 @@ static void destroy(private_ike_sa_established_t *this) */ ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa) { - private_ike_sa_established_t *this = allocator_alloc_thing(private_ike_sa_established_t); + private_ike_sa_established_t *this = malloc_thing(private_ike_sa_established_t); /* interface functions */ this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message; @@ -234,7 +233,7 @@ ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa) /* private data */ this->ike_sa = ike_sa; - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); return &(this->public); } diff --git a/Source/charon/sa/states/ike_sa_init_requested.c b/Source/charon/sa/states/ike_sa_init_requested.c index 8d3ae55ed..e3769303c 100644 --- a/Source/charon/sa/states/ike_sa_init_requested.c +++ b/Source/charon/sa/states/ike_sa_init_requested.c @@ -23,7 +23,6 @@ #include "ike_sa_init_requested.h" #include <daemon.h> -#include <utils/allocator.h> #include <encoding/payloads/sa_payload.h> #include <encoding/payloads/ke_payload.h> #include <encoding/payloads/nonce_payload.h> @@ -411,7 +410,7 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t */ status_t process_nonce_payload (private_ike_sa_init_requested_t *this, nonce_payload_t *nonce_payload) { - allocator_free(this->received_nonce.ptr); + free(this->received_nonce.ptr); this->received_nonce = nonce_payload->get_nonce(nonce_payload); return SUCCESS; } @@ -693,12 +692,12 @@ static ike_sa_state_t get_state(private_ike_sa_init_requested_t *this) static void destroy_after_state_change (private_ike_sa_init_requested_t *this) { this->diffie_hellman->destroy(this->diffie_hellman); - allocator_free_chunk(&(this->ike_sa_init_request_data)); + chunk_free(&(this->ike_sa_init_request_data)); if (this->proposal) { this->proposal->destroy(this->proposal); } - allocator_free(this); + free(this); } /** @@ -707,9 +706,9 @@ static void destroy_after_state_change (private_ike_sa_init_requested_t *this) static void destroy(private_ike_sa_init_requested_t *this) { this->diffie_hellman->destroy(this->diffie_hellman); - allocator_free(this->sent_nonce.ptr); - allocator_free(this->received_nonce.ptr); - allocator_free_chunk(&(this->ike_sa_init_request_data)); + free(this->sent_nonce.ptr); + free(this->received_nonce.ptr); + chunk_free(&(this->ike_sa_init_request_data)); if (this->child_sa) { this->child_sa->destroy(this->child_sa); @@ -718,7 +717,7 @@ static void destroy(private_ike_sa_init_requested_t *this) { this->proposal->destroy(this->proposal); } - allocator_free(this); + free(this); } /* @@ -726,7 +725,7 @@ static void destroy(private_ike_sa_init_requested_t *this) */ ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa, diffie_hellman_t *diffie_hellman, chunk_t sent_nonce,chunk_t ike_sa_init_request_data) { - private_ike_sa_init_requested_t *this = allocator_alloc_thing(private_ike_sa_init_requested_t); + private_ike_sa_init_requested_t *this = malloc_thing(private_ike_sa_init_requested_t); /* interface functions */ this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message; @@ -748,7 +747,7 @@ ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa /* private data */ this->ike_sa = ike_sa; this->received_nonce = CHUNK_INITIALIZER; - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); this->diffie_hellman = diffie_hellman; this->proposal = NULL; this->sent_nonce = sent_nonce; diff --git a/Source/charon/sa/states/ike_sa_init_responded.c b/Source/charon/sa/states/ike_sa_init_responded.c index 52548749a..54c0cc26b 100644 --- a/Source/charon/sa/states/ike_sa_init_responded.c +++ b/Source/charon/sa/states/ike_sa_init_responded.c @@ -19,11 +19,12 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ - + +#include <string.h> + #include "ike_sa_init_responded.h" #include <daemon.h> -#include <utils/allocator.h> #include <sa/authenticator.h> #include <sa/child_sa.h> #include <encoding/payloads/ts_payload.h> @@ -473,11 +474,11 @@ static status_t build_sa_payload(private_ike_sa_init_responded_t *this, sa_paylo } /* set up child sa */ - seed = allocator_alloc_as_chunk(this->received_nonce.len + this->sent_nonce.len); + seed = chunk_alloc(this->received_nonce.len + this->sent_nonce.len); memcpy(seed.ptr, this->received_nonce.ptr, this->received_nonce.len); memcpy(seed.ptr + this->received_nonce.len, this->sent_nonce.ptr, this->sent_nonce.len); prf_plus = prf_plus_create(this->ike_sa->get_child_prf(this->ike_sa), seed); - allocator_free_chunk(&seed); + chunk_free(&seed); connection = this->ike_sa->get_connection(this->ike_sa); this->child_sa = child_sa_create(connection->get_my_host(connection), @@ -607,10 +608,10 @@ static ike_sa_state_t get_state(private_ike_sa_init_responded_t *this) */ static void destroy(private_ike_sa_init_responded_t *this) { - allocator_free_chunk(&(this->received_nonce)); - allocator_free_chunk(&(this->sent_nonce)); - allocator_free_chunk(&(this->ike_sa_init_response_data)); - allocator_free_chunk(&(this->ike_sa_init_request_data)); + chunk_free(&(this->received_nonce)); + chunk_free(&(this->sent_nonce)); + chunk_free(&(this->ike_sa_init_response_data)); + chunk_free(&(this->ike_sa_init_request_data)); if (this->my_ts) { traffic_selector_t *ts; @@ -634,17 +635,17 @@ static void destroy(private_ike_sa_init_responded_t *this) this->child_sa->destroy(this->child_sa); } - allocator_free(this); + free(this); } /** * Implementation of private_ike_sa_init_responded.destroy_after_state_change. */ static void destroy_after_state_change(private_ike_sa_init_responded_t *this) { - allocator_free_chunk(&(this->received_nonce)); - allocator_free_chunk(&(this->sent_nonce)); - allocator_free_chunk(&(this->ike_sa_init_response_data)); - allocator_free_chunk(&(this->ike_sa_init_request_data)); + chunk_free(&(this->received_nonce)); + chunk_free(&(this->sent_nonce)); + chunk_free(&(this->ike_sa_init_response_data)); + chunk_free(&(this->ike_sa_init_request_data)); if (this->my_ts) { traffic_selector_t *ts; @@ -664,7 +665,7 @@ static void destroy_after_state_change(private_ike_sa_init_responded_t *this) this->other_ts->destroy(this->other_ts); } - allocator_free(this); + free(this); } /* @@ -672,7 +673,7 @@ static void destroy_after_state_change(private_ike_sa_init_responded_t *this) */ ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa, chunk_t received_nonce, chunk_t sent_nonce,chunk_t ike_sa_init_request_data, chunk_t ike_sa_init_response_data) { - private_ike_sa_init_responded_t *this = allocator_alloc_thing(private_ike_sa_init_responded_t); + private_ike_sa_init_responded_t *this = malloc_thing(private_ike_sa_init_responded_t); /* interface functions */ this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message; @@ -696,7 +697,7 @@ ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa this->my_ts = NULL; this->other_ts = NULL; this->child_sa = NULL; - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); return &(this->public); } diff --git a/Source/charon/sa/states/initiator_init.c b/Source/charon/sa/states/initiator_init.c index 85885130f..35d15235d 100644 --- a/Source/charon/sa/states/initiator_init.c +++ b/Source/charon/sa/states/initiator_init.c @@ -26,7 +26,6 @@ #include <daemon.h> #include <sa/states/state.h> #include <sa/states/ike_sa_init_requested.h> -#include <utils/allocator.h> #include <queues/jobs/retransmit_request_job.h> #include <crypto/diffie_hellman.h> #include <encoding/payloads/sa_payload.h> @@ -247,7 +246,7 @@ static void build_ke_payload(private_initiator_init_t *this, message_t *request) ke_payload->set_dh_group_number(ke_payload, dh_group); ke_payload->set_key_exchange_data(ke_payload, key_data); - allocator_free_chunk(&key_data); + chunk_free(&key_data); this->logger->log(this->logger, CONTROL|LEVEL2, "Add KE payload to message"); request->add_payload(request, (payload_t *) ke_payload); @@ -315,9 +314,9 @@ static void destroy(private_initiator_init_t *this) } if (this->sent_nonce.ptr != NULL) { - allocator_free(this->sent_nonce.ptr); + free(this->sent_nonce.ptr); } - allocator_free(this); + free(this); } /** @@ -326,7 +325,7 @@ static void destroy(private_initiator_init_t *this) static void destroy_after_state_change (private_initiator_init_t *this) { this->logger->log(this->logger, CONTROL | LEVEL3, "Going to destroy initiator_init_t state object"); - allocator_free(this); + free(this); } /* @@ -334,7 +333,7 @@ static void destroy_after_state_change (private_initiator_init_t *this) */ initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa) { - private_initiator_init_t *this = allocator_alloc_thing(private_initiator_init_t); + private_initiator_init_t *this = malloc_thing(private_initiator_init_t); /* interface functions */ this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message; @@ -353,7 +352,7 @@ initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa) /* private data */ this->ike_sa = ike_sa; - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); this->sent_nonce = CHUNK_INITIALIZER; this->diffie_hellman = NULL; diff --git a/Source/charon/sa/states/responder_init.c b/Source/charon/sa/states/responder_init.c index 32aa6db86..10acf645c 100644 --- a/Source/charon/sa/states/responder_init.c +++ b/Source/charon/sa/states/responder_init.c @@ -25,7 +25,6 @@ #include <daemon.h> #include <sa/states/state.h> #include <sa/states/ike_sa_init_responded.h> -#include <utils/allocator.h> #include <encoding/payloads/sa_payload.h> #include <encoding/payloads/ke_payload.h> #include <encoding/payloads/nonce_payload.h> @@ -413,7 +412,7 @@ static status_t build_ke_payload(private_responder_init_t *this,ke_payload_t *ke ke_payload = ke_payload_create(); ke_payload->set_key_exchange_data(ke_payload,key_data); ke_payload->set_dh_group_number(ke_payload, this->dh_group_number); - allocator_free_chunk(&key_data); + chunk_free(&key_data); this->logger->log(this->logger, CONTROL|LEVEL2, "Add KE payload to message"); response->add_payload(response,(payload_t *) ke_payload); @@ -431,7 +430,7 @@ static status_t build_nonce_payload(private_responder_init_t *this,nonce_payload status_t status; this->logger->log(this->logger, CONTROL | LEVEL2, "Process received NONCE payload"); - allocator_free(this->received_nonce.ptr); + free(this->received_nonce.ptr); this->received_nonce = CHUNK_INITIALIZER; this->logger->log(this->logger, CONTROL | LEVEL2, "Get NONCE value and store it"); @@ -498,9 +497,9 @@ static void destroy(private_responder_init_t *this) this->logger->log(this->logger, CONTROL | LEVEL1, "Going to destroy responder init state object"); this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy sent nonce"); - allocator_free_chunk(&(this->sent_nonce)); + chunk_free(&(this->sent_nonce)); this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy received nonce"); - allocator_free_chunk(&(this->received_nonce)); + chunk_free(&(this->received_nonce)); if (this->diffie_hellman != NULL) { @@ -512,7 +511,7 @@ static void destroy(private_responder_init_t *this) this->proposal->destroy(this->proposal); } this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy object"); - allocator_free(this); + free(this); } /** @@ -534,7 +533,7 @@ static void destroy_after_state_change (private_responder_init_t *this) } this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy object"); - allocator_free(this); + free(this); } /* @@ -542,7 +541,7 @@ static void destroy_after_state_change (private_responder_init_t *this) */ responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa) { - private_responder_init_t *this = allocator_alloc_thing(private_responder_init_t); + private_responder_init_t *this = malloc_thing(private_responder_init_t); /* interface functions */ this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message; @@ -558,7 +557,7 @@ responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa) /* private data */ this->ike_sa = ike_sa; - this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA); + this->logger = logger_manager->get_logger(logger_manager, IKE_SA); this->sent_nonce = CHUNK_INITIALIZER; this->received_nonce = CHUNK_INITIALIZER; this->dh_group_number = MODP_UNDEFINED; |