summaryrefslogtreecommitdiffstats
path: root/src/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/cipher/aes128_ctr/nacl/cipher_aes128_ctr_nacl.c6
-rw-r--r--src/crypto/mac/ghash/builtin/ghash_builtin.c6
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c6
3 files changed, 6 insertions, 12 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 c9adfcd..9611b11 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
@@ -31,6 +31,7 @@
#include "../../../../crypto.h"
+#include "../../../../alloc.h"
#include <crypto_stream_aes128ctr.h>
@@ -46,10 +47,7 @@ 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;
- if (posix_memalign((void **)&state, 16, sizeof(fastd_cipher_state_t)))
- abort();
-
+ fastd_cipher_state_t *state = fastd_new_aligned(fastd_cipher_state_t, 16);
crypto_stream_aes128ctr_beforenm(state->d, k.b);
return state;
diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c
index 32ed5e7..2e70f52 100644
--- a/src/crypto/mac/ghash/builtin/ghash_builtin.c
+++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c
@@ -31,7 +31,7 @@
#include "../../../../crypto.h"
-#include "../../../../log.h"
+#include "../../../../alloc.h"
/** MAC state used by this GHASH implmentation */
@@ -74,9 +74,7 @@ static inline void mulH_a(fastd_block128_t *x, const fastd_mac_state_t *cstate)
/** Initializes the MAC state with the unpacked key data */
static fastd_mac_state_t * ghash_init(const uint8_t *key) {
- fastd_mac_state_t *state;
- if (posix_memalign((void **)&state, 16, sizeof(fastd_mac_state_t)))
- abort();
+ fastd_mac_state_t *state = fastd_new_aligned(fastd_mac_state_t, 16);
fastd_block128_t Hbase[4];
fastd_block128_t Rbase[4];
diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
index 6117735..040ce14 100644
--- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
+++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
@@ -31,7 +31,7 @@
#include "ghash_pclmulqdq.h"
-#include "../../../../log.h"
+#include "../../../../alloc.h"
#include <wmmintrin.h>
#include <emmintrin.h>
@@ -79,9 +79,7 @@ static inline __m128i byteswap(__m128i v) {
/** Initializes the state used by this GHASH implementation */
fastd_mac_state_t * fastd_ghash_pclmulqdq_init(const uint8_t *key) {
- fastd_mac_state_t *state;
- if (posix_memalign((void **)&state, 16, sizeof(fastd_mac_state_t)))
- abort();
+ fastd_mac_state_t *state = fastd_new_aligned(fastd_mac_state_t, 16);
memcpy(&state->H, key, sizeof(__m128i));
state->H.v = byteswap(state->H.v);