summaryrefslogtreecommitdiffstats
path: root/src/methods/composed_gmac/composed_gmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/methods/composed_gmac/composed_gmac.c')
-rw-r--r--src/methods/composed_gmac/composed_gmac.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/methods/composed_gmac/composed_gmac.c b/src/methods/composed_gmac/composed_gmac.c
index fafc77b..87ce2e3 100644
--- a/src/methods/composed_gmac/composed_gmac.c
+++ b/src/methods/composed_gmac/composed_gmac.c
@@ -116,10 +116,10 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
session->method = method;
session->cipher = fastd_cipher_get(ctx, method->cipher_info);
- session->cipher_state = session->cipher->init(ctx, secret);
+ session->cipher_state = session->cipher->init(secret);
session->gmac_cipher = fastd_cipher_get(ctx, method->gmac_cipher_info);
- session->gmac_cipher_state = session->gmac_cipher->init(ctx, secret + method->cipher_info->key_length);
+ session->gmac_cipher_state = session->gmac_cipher->init(secret + method->cipher_info->key_length);
fastd_block128_t H;
@@ -127,16 +127,16 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
uint8_t zeroiv[gmac_iv_length];
memset(zeroiv, 0, gmac_iv_length);
- if (!session->gmac_cipher->crypt(ctx, session->gmac_cipher_state, &H, &ZERO_BLOCK, sizeof(fastd_block128_t), zeroiv)) {
- session->cipher->free(ctx, session->cipher_state);
- session->gmac_cipher->free(ctx, session->gmac_cipher_state);
+ if (!session->gmac_cipher->crypt(session->gmac_cipher_state, &H, &ZERO_BLOCK, sizeof(fastd_block128_t), zeroiv)) {
+ session->cipher->free(session->cipher_state);
+ session->gmac_cipher->free(session->gmac_cipher_state);
free(session);
return NULL;
}
session->ghash = fastd_mac_get(ctx, method->ghash_info);
- session->ghash_state = session->ghash->init(ctx, H.b);
+ session->ghash_state = session->ghash->init(H.b);
return session;
}
@@ -157,11 +157,11 @@ static void method_session_superseded(fastd_context_t *ctx, fastd_method_session
fastd_method_session_common_superseded(ctx, &session->common);
}
-static void method_session_free(fastd_context_t *ctx, fastd_method_session_state_t *session) {
+static void method_session_free(fastd_context_t *ctx UNUSED, fastd_method_session_state_t *session) {
if (session) {
- session->cipher->free(ctx, session->cipher_state);
- session->gmac_cipher->free(ctx, session->gmac_cipher_state);
- session->ghash->free(ctx, session->ghash_state);
+ session->cipher->free(session->cipher_state);
+ session->gmac_cipher->free(session->gmac_cipher_state);
+ session->ghash->free(session->ghash_state);
free(session);
}
@@ -195,7 +195,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
memcpy(gmac_nonce, session->common.send_nonce, COMMON_NONCEBYTES);
gmac_nonce[gmac_iv_length-1] = 1;
- bool ok = session->gmac_cipher->crypt(ctx, session->gmac_cipher_state, outblocks, &ZERO_BLOCK, sizeof(fastd_block128_t), gmac_nonce);
+ bool ok = session->gmac_cipher->crypt(session->gmac_cipher_state, outblocks, &ZERO_BLOCK, sizeof(fastd_block128_t), gmac_nonce);
if (ok) {
size_t iv_length = session->method->cipher_info->iv_length;
@@ -206,7 +206,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
nonce[iv_length-1] = 1;
}
- ok = session->cipher->crypt(ctx, session->cipher_state, outblocks+1, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ ok = session->cipher->crypt(session->cipher_state, outblocks+1, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
}
if (ok) {
@@ -215,7 +215,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
put_size(&outblocks[n_blocks+1], in.len);
- ok = session->ghash->hash(ctx, session->ghash_state, &sig, outblocks+1, n_blocks+1);
+ ok = session->ghash->hash(session->ghash_state, &sig, outblocks+1, n_blocks+1);
}
if (!ok) {
@@ -278,10 +278,10 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_block128_t *outblocks = out->data;
fastd_block128_t sig;
- bool ok = session->gmac_cipher->crypt(ctx, session->gmac_cipher_state, outblocks, inblocks, sizeof(fastd_block128_t), gmac_nonce);
+ bool ok = session->gmac_cipher->crypt(session->gmac_cipher_state, outblocks, inblocks, sizeof(fastd_block128_t), gmac_nonce);
if (ok)
- ok = session->cipher->crypt(ctx, session->cipher_state, outblocks+1, inblocks+1, (n_blocks-1)*sizeof(fastd_block128_t), nonce);
+ ok = session->cipher->crypt(session->cipher_state, outblocks+1, inblocks+1, (n_blocks-1)*sizeof(fastd_block128_t), nonce);
if (ok) {
if (tail_len)
@@ -289,7 +289,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
put_size(&inblocks[n_blocks], in.len-sizeof(fastd_block128_t));
- ok = session->ghash->hash(ctx, session->ghash_state, &sig, inblocks+1, n_blocks);
+ ok = session->ghash->hash(session->ghash_state, &sig, inblocks+1, n_blocks);
}
if (!ok || memcmp(&sig, &outblocks[0], sizeof(fastd_block128_t)) != 0) {