summaryrefslogtreecommitdiffstats
path: root/src/crypto/mac/ghash/pclmulqdq
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-25 00:09:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-25 00:09:19 +0200
commitf2d84afd9d8373bf2778d1a1635384000c03f887 (patch)
tree42af8a7430278871e3a1b1e14006099aa50eae80 /src/crypto/mac/ghash/pclmulqdq
parent9855a34f48acf6ae3aaeba9ec37756da41507e64 (diff)
downloadfastd-f2d84afd9d8373bf2778d1a1635384000c03f887.tar
fastd-f2d84afd9d8373bf2778d1a1635384000c03f887.zip
MAC: rename hash() to digest() and change length unit from blocks to bytes
Diffstat (limited to 'src/crypto/mac/ghash/pclmulqdq')
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.c2
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq.h2
-rw-r--r--src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c9
3 files changed, 10 insertions, 3 deletions
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;