summaryrefslogtreecommitdiffstats
path: root/src/crypto/mac
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-29 23:18:21 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-30 00:42:35 +0100
commit1111dc8e5e9e78254c1a7a891d961713e1be9db0 (patch)
tree3490dad7d1c43d32a9c5d362d6f03bb17cb5408a /src/crypto/mac
parenta09d04a02231964fa5a8f0113e9909cfb140fe4e (diff)
downloadfastd-1111dc8e5e9e78254c1a7a891d961713e1be9db0.tar
fastd-1111dc8e5e9e78254c1a7a891d961713e1be9db0.zip
Remove cipher and MAC contexts
Not a single implementation was using them...
Diffstat (limited to 'src/crypto/mac')
-rw-r--r--src/crypto/mac/ghash/builtin/ghash_builtin.c17
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c15
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h2
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c2
-rw-r--r--src/crypto/mac/macs.c.in23
5 files changed, 8 insertions, 51 deletions
diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c
index 511e844..341408f 100644
--- a/src/crypto/mac/ghash/builtin/ghash_builtin.c
+++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c
@@ -61,11 +61,7 @@ static inline void mulH_a(fastd_block128_t *x, const fastd_mac_state_t *cstate)
}
-static fastd_mac_context_t* ghash_initialize(fastd_context_t *ctx UNUSED) {
- return NULL;
-}
-
-static fastd_mac_state_t* ghash_init_state(fastd_context_t *ctx UNUSED, const fastd_mac_context_t *mctx UNUSED, const uint8_t *key) {
+static fastd_mac_state_t* ghash_init(fastd_context_t *ctx UNUSED, const uint8_t *key) {
fastd_mac_state_t *state = malloc(sizeof(fastd_mac_state_t));
fastd_block128_t Hbase[4];
@@ -121,24 +117,17 @@ static bool ghash_hash(fastd_context_t *ctx UNUSED, const fastd_mac_state_t *sta
return true;
}
-static void ghash_free_state(fastd_context_t *ctx UNUSED, fastd_mac_state_t *state) {
+static void ghash_free(fastd_context_t *ctx UNUSED, fastd_mac_state_t *state) {
if (state) {
secure_memzero(state, sizeof(*state));
free(state);
}
}
-static void ghash_free(fastd_context_t *ctx UNUSED, fastd_mac_context_t *mctx UNUSED) {
-}
-
const fastd_mac_t fastd_mac_ghash_builtin = {
.available = fastd_true,
- .initialize = ghash_initialize,
- .init_state = ghash_init_state,
-
+ .init = ghash_init,
.hash = ghash_hash,
-
- .free_state = ghash_free_state,
.free = ghash_free,
};
diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c
index 11073a5..8f1edb0 100644
--- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c
+++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c
@@ -34,28 +34,17 @@ static bool ghash_available(void) {
return ((fastd_cpuid()&REQ) == REQ);
}
-static fastd_mac_context_t* ghash_initialize(fastd_context_t *ctx UNUSED) {
- return NULL;
-}
-
-static void ghash_free_state(fastd_context_t *ctx UNUSED, fastd_mac_state_t *state) {
+static void ghash_free(fastd_context_t *ctx UNUSED, fastd_mac_state_t *state) {
if (state) {
secure_memzero(state, sizeof(*state));
free(state);
}
}
-static void ghash_free(fastd_context_t *ctx UNUSED, fastd_mac_context_t *mctx UNUSED) {
-}
-
const fastd_mac_t fastd_mac_ghash_pclmulqdq = {
.available = ghash_available,
- .initialize = ghash_initialize,
- .init_state = fastd_ghash_pclmulqdq_init_state,
-
+ .init = fastd_ghash_pclmulqdq_init,
.hash = fastd_ghash_pclmulqdq_hash,
-
- .free_state = ghash_free_state,
.free = ghash_free,
};
diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h
index c2645f8..ccb1ecf 100644
--- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h
+++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h
@@ -32,5 +32,5 @@ struct fastd_mac_state {
};
-fastd_mac_state_t* fastd_ghash_pclmulqdq_init_state(fastd_context_t *ctx, const fastd_mac_context_t *mctx, const uint8_t *key);
+fastd_mac_state_t* fastd_ghash_pclmulqdq_init(fastd_context_t *ctx, const uint8_t *key);
bool fastd_ghash_pclmulqdq_hash(fastd_context_t *ctx, const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t n_blocks);
diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
index 375cf91..134d4ed 100644
--- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
+++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
@@ -58,7 +58,7 @@ static inline __m128i byteswap(__m128i v) {
}
-fastd_mac_state_t* fastd_ghash_pclmulqdq_init_state(fastd_context_t *ctx UNUSED, const fastd_mac_context_t *mctx UNUSED, const uint8_t *key) {
+fastd_mac_state_t* fastd_ghash_pclmulqdq_init(fastd_context_t *ctx UNUSED, const uint8_t *key) {
fastd_mac_state_t *state = malloc(sizeof(fastd_mac_state_t));
vecblock_t h;
diff --git a/src/crypto/mac/macs.c.in b/src/crypto/mac/macs.c.in
index 3587322..c70473b 100644
--- a/src/crypto/mac/macs.c.in
+++ b/src/crypto/mac/macs.c.in
@@ -89,24 +89,6 @@ bool fastd_mac_config(const fastd_mac_t **mac_conf, const char *name, const char
return false;
}
-void fastd_mac_init(fastd_context_t *ctx) {
- ctx->mac_contexts = calloc(array_size(macs), sizeof(fastd_mac_context_t*));
-
- size_t i;
- for (i = 0; i < array_size(macs); i++) {
- if (ctx->conf->macs[i])
- ctx->mac_contexts[i] = ctx->conf->macs[i]->initialize(ctx);
- }
-}
-
-void fastd_mac_free(fastd_context_t *ctx) {
- size_t i;
- for (i = 0; i < array_size(macs); i++)
- ctx->conf->macs[i]->free(ctx, ctx->mac_contexts[i]);
-
- free(ctx->mac_contexts);
-}
-
const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) {
size_t i, j;
for (i = 0; i < array_size(macs); i++) {
@@ -124,16 +106,13 @@ const fastd_mac_info_t* fastd_mac_info_get_by_name(const char *name) {
return NULL;
}
-const fastd_mac_t* fastd_mac_get_by_name(fastd_context_t *ctx, const char *name, const fastd_mac_info_t **info, const fastd_mac_context_t **cctx) {
+const fastd_mac_t* fastd_mac_get_by_name(fastd_context_t *ctx, const char *name, const fastd_mac_info_t **info) {
size_t i;
for (i = 0; i < array_size(macs); i++) {
if (!strcmp(macs[i].name, name)) {
if (info)
*info = macs[i].info;
- if (cctx)
- *cctx = ctx->mac_contexts[i];
-
return ctx->conf->macs[i];
}
}