summaryrefslogtreecommitdiffstats
path: root/src/methods
diff options
context:
space:
mode:
Diffstat (limited to 'src/methods')
-rw-r--r--src/methods/cipher_test/cipher_test.c10
-rw-r--r--src/methods/composed_gmac/composed_gmac.c32
-rw-r--r--src/methods/generic_gcm/generic_gcm.c22
-rw-r--r--src/methods/generic_gmac/generic_gmac.c18
-rw-r--r--src/methods/generic_poly1305/generic_poly1305.c10
-rw-r--r--src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c1
6 files changed, 47 insertions, 46 deletions
diff --git a/src/methods/cipher_test/cipher_test.c b/src/methods/cipher_test/cipher_test.c
index 240e15d..2516164 100644
--- a/src/methods/cipher_test/cipher_test.c
+++ b/src/methods/cipher_test/cipher_test.c
@@ -80,7 +80,7 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
fastd_method_common_init(ctx, &session->common, initiator);
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);
pr_warn(ctx, "using cipher-test method; this method must be used for testing and benchmarks only");
@@ -103,9 +103,9 @@ 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->cipher->free(session->cipher_state);
free(session);
}
}
@@ -130,7 +130,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
fastd_block128_t *inblocks = in.data;
fastd_block128_t *outblocks = out->data;
- bool ok = session->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (!ok) {
fastd_buffer_free(*out);
@@ -183,7 +183,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_block128_t *inblocks = in.data;
fastd_block128_t *outblocks = out->data;
- bool ok = session->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (!ok) {
fastd_buffer_free(*out);
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) {
diff --git a/src/methods/generic_gcm/generic_gcm.c b/src/methods/generic_gcm/generic_gcm.c
index 5aa4210..fc665dd 100644
--- a/src/methods/generic_gcm/generic_gcm.c
+++ b/src/methods/generic_gcm/generic_gcm.c
@@ -93,7 +93,7 @@ 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);
static const fastd_block128_t zeroblock = {};
fastd_block128_t H;
@@ -102,14 +102,14 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
uint8_t zeroiv[iv_length];
memset(zeroiv, 0, iv_length);
- if (!session->cipher->crypt(ctx, session->cipher_state, &H, &zeroblock, sizeof(fastd_block128_t), zeroiv)) {
- session->cipher->free(ctx, session->cipher_state);
+ if (!session->cipher->crypt(session->cipher_state, &H, &zeroblock, sizeof(fastd_block128_t), zeroiv)) {
+ session->cipher->free(session->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;
}
@@ -137,10 +137,10 @@ 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->ghash->free(ctx, session->ghash_state);
+ session->cipher->free(session->cipher_state);
+ session->ghash->free(session->ghash_state);
free(session);
}
@@ -177,7 +177,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
fastd_block128_t *outblocks = out->data;
fastd_block128_t sig;
- bool ok = session->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (ok) {
if (tail_len)
@@ -185,7 +185,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
put_size(&outblocks[n_blocks], in.len-sizeof(fastd_block128_t));
- ok = session->ghash->hash(ctx, session->ghash_state, &sig, outblocks+1, n_blocks);
+ ok = session->ghash->hash(session->ghash_state, &sig, outblocks+1, n_blocks);
}
if (!ok) {
@@ -240,7 +240,7 @@ 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->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (ok) {
if (tail_len)
@@ -248,7 +248,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) {
diff --git a/src/methods/generic_gmac/generic_gmac.c b/src/methods/generic_gmac/generic_gmac.c
index f7ea086..e9224f6 100644
--- a/src/methods/generic_gmac/generic_gmac.c
+++ b/src/methods/generic_gmac/generic_gmac.c
@@ -96,10 +96,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->ghash = fastd_mac_get(ctx, method->ghash_info);
- session->ghash_state = session->ghash->init(ctx, secret + method->cipher_info->key_length);
+ session->ghash_state = session->ghash->init(secret + method->cipher_info->key_length);
return session;
}
@@ -120,10 +120,10 @@ 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->ghash->free(ctx, session->ghash_state);
+ session->cipher->free(session->cipher_state);
+ session->ghash->free(session->ghash_state);
free(session);
}
@@ -160,7 +160,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
fastd_block128_t *outblocks = out->data;
fastd_block128_t sig;
- bool ok = session->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (ok) {
if (tail_len)
@@ -168,7 +168,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
put_size(&outblocks[n_blocks], in.len-sizeof(fastd_block128_t));
- ok = session->ghash->hash(ctx, session->ghash_state, &sig, outblocks+1, n_blocks);
+ ok = session->ghash->hash(session->ghash_state, &sig, outblocks+1, n_blocks);
}
if (!ok) {
@@ -224,7 +224,7 @@ 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->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (ok) {
if (tail_len)
@@ -232,7 +232,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) {
diff --git a/src/methods/generic_poly1305/generic_poly1305.c b/src/methods/generic_poly1305/generic_poly1305.c
index 1f40655..f547d5a 100644
--- a/src/methods/generic_poly1305/generic_poly1305.c
+++ b/src/methods/generic_poly1305/generic_poly1305.c
@@ -88,7 +88,7 @@ static fastd_method_session_state_t* method_session_init(fastd_context_t *ctx, c
fastd_method_common_init(ctx, &session->common, initiator);
session->method = method;
session->cipher = fastd_cipher_get(ctx, session->method->cipher_info);
- session->cipher_state = session->cipher->init(ctx, secret);
+ session->cipher_state = session->cipher->init(secret);
return session;
}
@@ -109,9 +109,9 @@ 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->cipher->free(session->cipher_state);
free(session);
}
}
@@ -138,7 +138,7 @@ static bool method_encrypt(fastd_context_t *ctx, fastd_peer_t *peer UNUSED, fast
fastd_block128_t *outblocks = out->data;
uint8_t tag[crypto_onetimeauth_poly1305_BYTES];
- bool ok = session->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (!ok) {
/* restore original buffer */
@@ -199,7 +199,7 @@ static bool method_decrypt(fastd_context_t *ctx, fastd_peer_t *peer, fastd_metho
fastd_block128_t *inblocks = in.data;
fastd_block128_t *outblocks = out->data;
- bool ok = session->cipher->crypt(ctx, session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
+ bool ok = session->cipher->crypt(session->cipher_state, outblocks, inblocks, n_blocks*sizeof(fastd_block128_t), nonce);
if (ok) {
if (tail_len)
diff --git a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
index 9d964a3..19a929d 100644
--- a/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
+++ b/src/methods/xsalsa20_poly1305/xsalsa20_poly1305.c
@@ -24,6 +24,7 @@
*/
+#include "../../crypto.h"
#include "../../method.h"
#include "../common.h"