From 7adeb6e88196a594ec3d36ffc1c658340ffcd7bc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 20 Apr 2014 05:29:11 +0200 Subject: Make ctx global --- src/methods/cipher_test/cipher_test.c | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/methods/cipher_test') diff --git a/src/methods/cipher_test/cipher_test.c b/src/methods/cipher_test/cipher_test.c index 0cec4b0..52bca0f 100644 --- a/src/methods/cipher_test/cipher_test.c +++ b/src/methods/cipher_test/cipher_test.c @@ -70,49 +70,49 @@ static void method_destroy(fastd_method_t *method) { free(method); } -static size_t method_key_length(fastd_context_t *ctx UNUSED, const fastd_method_t *method) { +static size_t method_key_length(const fastd_method_t *method) { return method->cipher_info->key_length; } -static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, const fastd_method_t *method, const uint8_t *secret, bool initiator) { +static fastd_method_session_state_t* method_session_init(const fastd_method_t *method, const uint8_t *secret, bool initiator) { fastd_method_session_state_t *session = malloc(sizeof(fastd_method_session_state_t)); - fastd_method_common_init(ctx, &session->common, initiator); + fastd_method_common_init(&session->common, initiator); session->method = method; session->cipher = fastd_cipher_get(method->cipher_info); session->cipher_state = session->cipher->init(secret); - pr_warn(ctx, "using cipher-test method; this method must be used for testing and benchmarks only"); + pr_warn("using cipher-test method; this method must be used for testing and benchmarks only"); return session; } -static bool method_session_is_valid(fastd_context_t *ctx, fastd_method_session_state_t *session) { - return (session && fastd_method_session_common_is_valid(ctx, &session->common)); +static bool method_session_is_valid(fastd_method_session_state_t *session) { + return (session && fastd_method_session_common_is_valid(&session->common)); } -static bool method_session_is_initiator(fastd_context_t *ctx UNUSED, fastd_method_session_state_t *session) { +static bool method_session_is_initiator(fastd_method_session_state_t *session) { return fastd_method_session_common_is_initiator(&session->common); } -static bool method_session_want_refresh(fastd_context_t *ctx, fastd_method_session_state_t *session) { - return fastd_method_session_common_want_refresh(ctx, &session->common); +static bool method_session_want_refresh(fastd_method_session_state_t *session) { + return fastd_method_session_common_want_refresh(&session->common); } -static void method_session_superseded(fastd_context_t *ctx, fastd_method_session_state_t *session) { - fastd_method_session_common_superseded(ctx, &session->common); +static void method_session_superseded(fastd_method_session_state_t *session) { + fastd_method_session_common_superseded(&session->common); } -static void method_session_free(fastd_context_t *ctx UNUSED, fastd_method_session_state_t *session) { +static void method_session_free(fastd_method_session_state_t *session) { if (session) { session->cipher->free(session->cipher_state); free(session); } } -static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in) { +static bool method_encrypt(fastd_peer_t *peer UNUSED, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in) { size_t tail_len = alignto(in.len, sizeof(fastd_block128_t))-in.len; - *out = fastd_buffer_alloc(ctx, in.len, alignto(COMMON_HEADBYTES, 16), sizeof(fastd_block128_t)+tail_len); + *out = fastd_buffer_alloc(in.len, alignto(COMMON_HEADBYTES, 16), sizeof(fastd_block128_t)+tail_len); if (tail_len) memset(in.data+in.len, 0, tail_len); @@ -134,23 +134,23 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast fastd_buffer_free(in); - fastd_method_put_common_header(ctx, out, session->common.send_nonce, 0); + fastd_method_put_common_header(out, session->common.send_nonce, 0); fastd_method_increment_nonce(&session->common); return true; } -static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in) { +static bool method_decrypt(fastd_peer_t *peer, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in) { if (in.len < COMMON_HEADBYTES) return false; - if (!method_session_is_valid(ctx, session)) + if (!method_session_is_valid(session)) return false; uint8_t in_nonce[COMMON_NONCEBYTES]; uint8_t flags; int64_t age; - if (!fastd_method_handle_common_header(ctx, &session->common, &in, in_nonce, &flags, &age)) + if (!fastd_method_handle_common_header(&session->common, &in, in_nonce, &flags, &age)) return false; if (flags) @@ -160,7 +160,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho fastd_method_expand_nonce(nonce, in_nonce, sizeof(nonce)); size_t tail_len = alignto(in.len, sizeof(fastd_block128_t))-in.len; - *out = fastd_buffer_alloc(ctx, in.len, 0, tail_len); + *out = fastd_buffer_alloc(in.len, 0, tail_len); int n_blocks = block_count(in.len, sizeof(fastd_block128_t)); @@ -174,9 +174,9 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho return false; } - if (!fastd_method_reorder_check(ctx, peer, &session->common, in_nonce, age)) { + if (!fastd_method_reorder_check(peer, &session->common, in_nonce, age)) { fastd_buffer_free(*out); - *out = fastd_buffer_alloc(ctx, 0, 0, 0); + *out = fastd_buffer_alloc(0, 0, 0); } fastd_buffer_free(in); -- cgit v1.2.3