diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-05 16:29:57 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-11-05 16:29:57 +0100 |
commit | cb42b5b1fa81969e6d4056e0220374e8ded09651 (patch) | |
tree | 72b85d9cc8a551149467f770ec1752f540e3d3eb /src/crypto/cipher/aes128_ctr/nacl | |
parent | 4f9b5d66bc6b198dcf6e119fa05e891fce4e355f (diff) | |
download | fastd-cb42b5b1fa81969e6d4056e0220374e8ded09651.tar fastd-cb42b5b1fa81969e6d4056e0220374e8ded09651.zip |
Generalize cipher/MAC key/IV lengths
Diffstat (limited to 'src/crypto/cipher/aes128_ctr/nacl')
-rw-r--r-- | src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c | 16 |
1 files changed, 14 insertions, 2 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 f63e46f..60c8743 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,6 +37,10 @@ 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)); @@ -49,8 +53,12 @@ static fastd_cipher_state_t* aes128_ctr_init_state(fastd_context_t *ctx, const f return state; } -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 fastd_block128_t *iv) { - crypto_stream_aes128ctr_xor_afternm(out->b, in->b, len, iv->b, state->d.data); +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.data); return true; } @@ -68,7 +76,11 @@ const fastd_cipher_t fastd_cipher_aes128_ctr_nacl = { .name = "nacl", .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, |