diff options
Diffstat (limited to 'src/crypto/cipher/aes128_ctr')
-rw-r--r-- | src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c | 12 | ||||
-rw-r--r-- | src/crypto/cipher/aes128_ctr/openssl/aes128_ctr_openssl.c | 7 |
2 files changed, 10 insertions, 9 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 f4756a3..ca32e72 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 @@ -25,6 +25,7 @@ #include "../../../../crypto.h" + #include <crypto_stream_aes128ctr.h> @@ -33,26 +34,25 @@ struct __attribute__((aligned(16))) fastd_cipher_state { }; -static fastd_cipher_state_t* aes128_ctr_init(fastd_context_t *ctx, const uint8_t *key) { +static fastd_cipher_state_t* aes128_ctr_init(const uint8_t *key) { fastd_block128_t k; memcpy(k.b, key, sizeof(fastd_block128_t)); fastd_cipher_state_t *state; - int err = posix_memalign((void**)&state, 16, sizeof(fastd_cipher_state_t)); - if (err) - exit_error(ctx, "posix_memalign: %s", strerror(err)); + if (posix_memalign((void**)&state, 16, sizeof(fastd_cipher_state_t))) + abort(); crypto_stream_aes128ctr_beforenm(state->d, k.b); 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 uint8_t *iv) { +static bool aes128_ctr_crypt(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; } -static void aes128_ctr_free(fastd_context_t *ctx UNUSED, fastd_cipher_state_t *state) { +static void aes128_ctr_free(fastd_cipher_state_t *state) { if (state) { secure_memzero(state, sizeof(*state)); free(state); diff --git a/src/crypto/cipher/aes128_ctr/openssl/aes128_ctr_openssl.c b/src/crypto/cipher/aes128_ctr/openssl/aes128_ctr_openssl.c index b3c739c..22b0ebe 100644 --- a/src/crypto/cipher/aes128_ctr/openssl/aes128_ctr_openssl.c +++ b/src/crypto/cipher/aes128_ctr/openssl/aes128_ctr_openssl.c @@ -25,6 +25,7 @@ #include "../../../../crypto.h" + #include <openssl/evp.h> @@ -33,7 +34,7 @@ struct fastd_cipher_state { }; -static fastd_cipher_state_t* aes128_ctr_init(fastd_context_t *ctx UNUSED, const uint8_t *key) { +static fastd_cipher_state_t* aes128_ctr_init(const uint8_t *key) { fastd_cipher_state_t *state = malloc(sizeof(fastd_cipher_state_t)); state->aes = EVP_CIPHER_CTX_new(); @@ -42,7 +43,7 @@ static fastd_cipher_state_t* aes128_ctr_init(fastd_context_t *ctx UNUSED, const 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 uint8_t *iv) { +static bool aes128_ctr_crypt(const fastd_cipher_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t len, const uint8_t *iv) { int clen, clen2; if (!EVP_EncryptInit(state->aes, NULL, NULL, iv)) @@ -60,7 +61,7 @@ static bool aes128_ctr_crypt(fastd_context_t *ctx UNUSED, const fastd_cipher_sta return true; } -static void aes128_ctr_free(fastd_context_t *ctx UNUSED, fastd_cipher_state_t *state) { +static void aes128_ctr_free(fastd_cipher_state_t *state) { if (state) { EVP_CIPHER_CTX_free(state->aes); free(state); |