diff options
Diffstat (limited to 'src/crypto/mac/ghash')
4 files changed, 18 insertions, 5 deletions
diff --git a/src/crypto/mac/ghash/builtin/ghash_builtin.c b/src/crypto/mac/ghash/builtin/ghash_builtin.c index 981b588..32ed5e7 100644 --- a/src/crypto/mac/ghash/builtin/ghash_builtin.c +++ b/src/crypto/mac/ghash/builtin/ghash_builtin.c @@ -31,6 +31,7 @@ #include "../../../../crypto.h" +#include "../../../../log.h" /** MAC state used by this GHASH implmentation */ @@ -119,7 +120,12 @@ static fastd_mac_state_t * ghash_init(const uint8_t *key) { } /** Calculates the GHASH of the supplied blocks */ -static bool ghash_hash(const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t n_blocks) { +static bool ghash_digest(const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t length) { + if (length % sizeof(fastd_block128_t)) + exit_bug("ghash_digest (builtin): invalid length"); + + size_t n_blocks = length / sizeof(fastd_block128_t); + memset(out, 0, sizeof(fastd_block128_t)); size_t i; @@ -142,6 +148,6 @@ static void ghash_free(fastd_mac_state_t *state) { /** The builtin GHASH implementation */ const fastd_mac_t fastd_mac_ghash_builtin = { .init = ghash_init, - .hash = ghash_hash, + .digest = ghash_digest, .free = ghash_free, }; diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c index 5d5977a..2fe5bca 100644 --- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c +++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c @@ -46,6 +46,6 @@ const fastd_mac_t fastd_mac_ghash_pclmulqdq = { .available = ghash_available, .init = fastd_ghash_pclmulqdq_init, - .hash = fastd_ghash_pclmulqdq_hash, + .digest = fastd_ghash_pclmulqdq_digest, .free = fastd_ghash_pclmulqdq_free, }; diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h index bd10de4..f1a3f52 100644 --- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h +++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h @@ -36,5 +36,5 @@ fastd_mac_state_t * fastd_ghash_pclmulqdq_init(const uint8_t *key); -bool fastd_ghash_pclmulqdq_hash(const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t n_blocks); +bool fastd_ghash_pclmulqdq_digest(const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t length); void fastd_ghash_pclmulqdq_free(fastd_mac_state_t *state); diff --git a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c index 17e7aa2..6117735 100644 --- a/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c +++ b/src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c @@ -31,6 +31,8 @@ #include "ghash_pclmulqdq.h" +#include "../../../../log.h" + #include <wmmintrin.h> #include <emmintrin.h> #include <tmmintrin.h> @@ -150,7 +152,12 @@ static __m128i gmul(__m128i v, __m128i h) { /** Calculates the GHASH of the supplied input blocks */ -bool fastd_ghash_pclmulqdq_hash(const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t n_blocks) { +bool fastd_ghash_pclmulqdq_digest(const fastd_mac_state_t *state, fastd_block128_t *out, const fastd_block128_t *in, size_t length) { + if (length % sizeof(fastd_block128_t)) + exit_bug("ghash_digest (pclmulqdq): invalid length"); + + size_t n_blocks = length / sizeof(fastd_block128_t); + vecblock_t v = {.v = _mm_setzero_si128()}; size_t i; |