diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-20 01:51:12 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-20 01:51:12 +0100 |
commit | b5112ff67f3dd5bb263f5ca6283f170906acaab6 (patch) | |
tree | b1b3974a9e4ae986c516c53ae723df1c2057974d /src/crypto | |
parent | 9bb8a04e288d3df817a4328cce9e0ef8f96a0600 (diff) | |
download | fastd-b5112ff67f3dd5bb263f5ca6283f170906acaab6.tar fastd-b5112ff67f3dd5bb263f5ca6283f170906acaab6.zip |
Slightly simplify method/cipher/MAC definitions
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c | 13 | ||||
-rw-r--r-- | src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c | 13 | ||||
-rw-r--r-- | src/crypto/cipher/null/memcpy/null_memcpy.c | 14 | ||||
-rw-r--r-- | src/crypto/mac/ghash/builtin/ghash_builtin.c | 7 |
4 files changed, 7 insertions, 40 deletions
diff --git a/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c b/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c index 5cb4bc7..7c75b7d 100644 --- a/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c +++ b/src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c @@ -37,10 +37,6 @@ static fastd_cipher_context_t* aes128_ctr_initialize(fastd_context_t *ctx UNUSED return NULL; } -static size_t aes128_ctr_key_length(fastd_context_t *ctx UNUSED, const fastd_cipher_context_t *cctx UNUSED) { - return 16; -} - static fastd_cipher_state_t* aes128_ctr_init_state(fastd_context_t *ctx, const fastd_cipher_context_t *cctx UNUSED, const uint8_t *key) { fastd_block128_t k; memcpy(k.b, key, sizeof(fastd_block128_t)); @@ -55,10 +51,6 @@ static fastd_cipher_state_t* aes128_ctr_init_state(fastd_context_t *ctx, const f return state; } -static size_t aes128_ctr_iv_length(fastd_context_t *ctx UNUSED, const fastd_cipher_state_t *state UNUSED) { - return 16; -} - static bool aes128_ctr_crypt(fastd_context_t *ctx UNUSED, const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv) { crypto_stream_aes128ctr_xor_afternm(out->b, in->b, len, iv, state->d); return true; @@ -76,13 +68,12 @@ static void aes128_ctr_free(fastd_context_t *ctx UNUSED, fastd_cipher_context_t const fastd_cipher_t fastd_cipher_aes128_ctr_nacl = { .name = "nacl", + .key_length = 16, + .iv_length = 16, .initialize = aes128_ctr_initialize, - - .key_length = aes128_ctr_key_length, .init_state = aes128_ctr_init_state, - .iv_length = aes128_ctr_iv_length, .crypt = aes128_ctr_crypt, .free_state = aes128_ctr_free_state, diff --git a/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c b/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c index d874e72..d657694 100644 --- a/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c +++ b/src/crypto/cipher/blowfish_ctr/builtin/blowfish_ctr.c @@ -179,10 +179,6 @@ static fastd_cipher_context_t* blowfish_ctr_initialize(fastd_context_t *ctx UNUS return NULL; } -static size_t blowfish_ctr_key_length(fastd_context_t *ctx UNUSED, const fastd_cipher_context_t *cctx UNUSED) { - return 56; -} - static inline void bf_ntohl(uint32_t *v, size_t len) { size_t i; @@ -243,10 +239,6 @@ static fastd_cipher_state_t* blowfish_ctr_init_state(fastd_context_t *ctx UNUSED return state; } -static size_t blowfish_ctr_iv_length(fastd_context_t *ctx UNUSED, const fastd_cipher_state_t *state UNUSED) { - return 8; -} - static bool blowfish_ctr_crypt(fastd_context_t *ctx UNUSED, const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv) { register uint32_t ctr[2]; register uint32_t block[2]; @@ -283,13 +275,12 @@ static void blowfish_ctr_free(fastd_context_t *ctx UNUSED, fastd_cipher_context_ const fastd_cipher_t fastd_cipher_blowfish_ctr_builtin = { .name = "builtin", + .key_length = 56, + .iv_length = 8, .initialize = blowfish_ctr_initialize, - - .key_length = blowfish_ctr_key_length, .init_state = blowfish_ctr_init_state, - .iv_length = blowfish_ctr_iv_length, .crypt = blowfish_ctr_crypt, .free_state = blowfish_ctr_free_state, diff --git a/src/crypto/cipher/null/memcpy/null_memcpy.c b/src/crypto/cipher/null/memcpy/null_memcpy.c index e3b86ca..c260ffb 100644 --- a/src/crypto/cipher/null/memcpy/null_memcpy.c +++ b/src/crypto/cipher/null/memcpy/null_memcpy.c @@ -31,19 +31,10 @@ static fastd_cipher_context_t* null_initialize(fastd_context_t *ctx UNUSED) { return NULL; } -static size_t null_key_length(fastd_context_t *ctx UNUSED, const fastd_cipher_context_t *cctx UNUSED) { - return 0; -} - - static fastd_cipher_state_t* null_init_state(fastd_context_t *ctx UNUSED, const fastd_cipher_context_t *cctx UNUSED, const uint8_t *key UNUSED) { return NULL; } -static size_t null_iv_length(fastd_context_t *ctx UNUSED, const fastd_cipher_state_t *state UNUSED) { - return 0; -} - static bool null_memcpy(fastd_context_t *ctx UNUSED, const fastd_cipher_state_t *state UNUSED, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv UNUSED) { memcpy(out, in, len); return true; @@ -57,13 +48,12 @@ static void null_free(fastd_context_t *ctx UNUSED, fastd_cipher_context_t *cctx const fastd_cipher_t fastd_cipher_null_memcpy = { .name = "memcpy", + .key_length = 0, + .iv_length = 0, .initialize = null_initialize, - - .key_length = null_key_length, .init_state = null_init_state, - .iv_length = null_iv_length, .crypt = null_memcpy, .free_state = null_free_state, diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c index a243b2a..8793627 100644 --- a/src/crypto/mac/ghash/builtin/ghash_builtin.c +++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c @@ -65,10 +65,6 @@ static fastd_mac_context_t* ghash_initialize(fastd_context_t *ctx UNUSED) { return NULL; } -static size_t ghash_key_length(fastd_context_t *ctx UNUSED, const fastd_mac_context_t *cctx UNUSED) { - return sizeof(fastd_block128_t); -} - static fastd_mac_state_t* ghash_init_state(fastd_context_t *ctx UNUSED, const fastd_mac_context_t *mctx UNUSED, const uint8_t *key) { fastd_mac_state_t *state = malloc(sizeof(fastd_mac_state_t)); @@ -137,10 +133,9 @@ static void ghash_free(fastd_context_t *ctx UNUSED, fastd_mac_context_t *mctx UN const fastd_mac_t fastd_mac_ghash_builtin = { .name = "builtin", + .key_length = sizeof(fastd_block128_t), .initialize = ghash_initialize, - - .key_length = ghash_key_length, .init_state = ghash_init_state, .hash = ghash_hash, |