aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/mac
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-10-17 18:30:40 -0400
committerJack Lloyd <[email protected]>2017-10-18 11:13:42 -0400
commiteab327defc290e21b36591a09d93609d6deca940 (patch)
tree75d8c372dfbd90e37203a7600ef513654d895fd1 /src/lib/mac
parentf01f37d142ef230b03ca6af46f1e1a0615e4879a (diff)
GCM and CTR optimizations
In CTR, special case for counter widths of special interest. In GHASH, uses a 4x reduction technique suggested by Intel. Split out GHASH to its own source file and header. With these changes GCM is over twice as fast on Skylake and about 50% faster on Westmere.
Diffstat (limited to 'src/lib/mac')
-rw-r--r--src/lib/mac/gmac/gmac.cpp9
-rw-r--r--src/lib/mac/gmac/gmac.h12
-rw-r--r--src/lib/mac/mac.cpp2
3 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/mac/gmac/gmac.cpp b/src/lib/mac/gmac/gmac.cpp
index be27aba4a..a4e84f57b 100644
--- a/src/lib/mac/gmac/gmac.cpp
+++ b/src/lib/mac/gmac/gmac.cpp
@@ -7,6 +7,8 @@
*/
#include <botan/gmac.h>
+#include <botan/ghash.h>
+#include <botan/block_cipher.h>
namespace Botan {
@@ -28,6 +30,13 @@ void GMAC::clear()
m_initialized = false;
}
+GMAC::~GMAC() { /* for unique_ptr */ }
+
+Key_Length_Specification GMAC::key_spec() const
+ {
+ return m_cipher->key_spec();
+ }
+
std::string GMAC::name() const
{
return "GMAC(" + m_cipher->name() + ")";
diff --git a/src/lib/mac/gmac/gmac.h b/src/lib/mac/gmac/gmac.h
index ef54a42bf..83094a5bc 100644
--- a/src/lib/mac/gmac/gmac.h
+++ b/src/lib/mac/gmac/gmac.h
@@ -10,11 +10,12 @@
#define BOTAN_GMAC_H_
#include <botan/mac.h>
-#include <botan/gcm.h>
-#include <botan/block_cipher.h>
namespace Botan {
+class BlockCipher;
+class GHASH;
+
/**
* GMAC
*
@@ -29,10 +30,7 @@ class BOTAN_PUBLIC_API(2,0) GMAC final : public MessageAuthenticationCode
size_t output_length() const override;
MessageAuthenticationCode* clone() const override;
- Key_Length_Specification key_spec() const override
- {
- return m_cipher->key_spec();
- }
+ Key_Length_Specification key_spec() const override;
/**
* Creates a new GMAC instance.
@@ -44,6 +42,8 @@ class BOTAN_PUBLIC_API(2,0) GMAC final : public MessageAuthenticationCode
GMAC(const GMAC&) = delete;
GMAC& operator=(const GMAC&) = delete;
+ virtual ~GMAC();
+
private:
void add_data(const uint8_t[], size_t) override;
void final_result(uint8_t[]) override;
diff --git a/src/lib/mac/mac.cpp b/src/lib/mac/mac.cpp
index 053e36b6f..65107470b 100644
--- a/src/lib/mac/mac.cpp
+++ b/src/lib/mac/mac.cpp
@@ -19,10 +19,12 @@
#if defined(BOTAN_HAS_GMAC)
#include <botan/gmac.h>
+ #include <botan/block_cipher.h>
#endif
#if defined(BOTAN_HAS_HMAC)
#include <botan/hmac.h>
+ #include <botan/hash.h>
#endif
#if defined(BOTAN_HAS_POLY1305)