summaryrefslogtreecommitdiffstats
path: root/src/methods/generic_poly1305
diff options
context:
space:
mode:
Diffstat (limited to 'src/methods/generic_poly1305')
-rw-r--r--src/methods/generic_poly1305/generic_poly1305.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c
index a8eb3d1..0e2641c 100644
--- a/src/methods/generic_poly1305/generic_poly1305.c
+++ b/src/methods/generic_poly1305/generic_poly1305.c
@@ -79,14 +79,14 @@ 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(session->method->cipher_info);
session->cipher_state = session->cipher->init(secret);
@@ -94,34 +94,34 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
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) {
- fastd_buffer_pull_head_zero(ctx, &in, KEYBYTES);
+static bool method_encrypt(fastd_peer_t *peer UNUSED, fastd_method_session_state_t *session, fastd_buffer_t *out, fastd_buffer_t in) {
+ fastd_buffer_pull_head_zero(&in, KEYBYTES);
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);
@@ -144,28 +144,28 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
crypto_onetimeauth_poly1305(tag, outblocks->b+KEYBYTES, in.len - KEYBYTES, outblocks->b);
- fastd_buffer_push_head(ctx, out, KEYBYTES);
- fastd_buffer_pull_head_from(ctx, out, tag, TAGBYTES);
+ fastd_buffer_push_head(out, KEYBYTES);
+ fastd_buffer_pull_head_from(out, tag, TAGBYTES);
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+TAGBYTES)
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)
@@ -175,11 +175,11 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_method_expand_nonce(nonce, in_nonce, sizeof(nonce));
uint8_t tag[TAGBYTES] __attribute__((aligned(8)));
- fastd_buffer_push_head_to(ctx, &in, tag, TAGBYTES);
- fastd_buffer_pull_head_zero(ctx, &in, KEYBYTES);
+ fastd_buffer_push_head_to(&in, tag, TAGBYTES);
+ fastd_buffer_pull_head_zero(&in, KEYBYTES);
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));
fastd_block128_t *inblocks = in.data;
@@ -198,20 +198,20 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_buffer_free(*out);
/* restore input buffer */
- fastd_buffer_push_head(ctx, &in, KEYBYTES);
- fastd_buffer_pull_head_from(ctx, &in, tag, TAGBYTES);
- fastd_method_put_common_header(ctx, &in, in_nonce, 0);
+ fastd_buffer_push_head(&in, KEYBYTES);
+ fastd_buffer_pull_head_from(&in, tag, TAGBYTES);
+ fastd_method_put_common_header(&in, in_nonce, 0);
return false;
}
fastd_buffer_free(in);
- fastd_buffer_push_head(ctx, out, KEYBYTES);
+ fastd_buffer_push_head(out, KEYBYTES);
- 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);
}
return true;