From 7b56f1bd570dc684ffd7c945dee0d9b5480354ff Mon Sep 17 00:00:00 2001 From: lloyd Date: Wed, 28 Jan 2015 04:32:10 +0000 Subject: Add a runtime map of string->func() which when called return Transforms and BlockCiphers. Registration for all types is done at startup but is very cheap as just a std::function and a std::map entry are created, no actual objects are created until needed. This is a huge improvement over Algorithm_Factory which used T::clone() as the function and thus kept a prototype object of each type in memory. Replace existing lookup mechanisms for ciphers, AEADs, and compression to use the transform lookup. The existing Engine framework remains in place for BlockCipher, but the engines now just call to the registry instead of having hardcoded lookups. s/Transformation/Transform/ with typedefs for compatability. Remove lib/selftest code (for runtime selftesting): not the right approach. --- src/lib/block/threefish_avx2/threefish_avx2.cpp | 6 +++++- src/lib/block/threefish_avx2/threefish_avx2.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/lib/block/threefish_avx2') diff --git a/src/lib/block/threefish_avx2/threefish_avx2.cpp b/src/lib/block/threefish_avx2/threefish_avx2.cpp index ee0ecde85..432059585 100644 --- a/src/lib/block/threefish_avx2/threefish_avx2.cpp +++ b/src/lib/block/threefish_avx2/threefish_avx2.cpp @@ -1,15 +1,19 @@ /* -* Threefish-512 +* Threefish-512 using AVX2 * (C) 2013 Jack Lloyd * * Botan is released under the Simplified BSD License (see license.txt) */ +#include #include +#include #include namespace Botan { +BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_avx2(), Threefish_512_AVX2, "Threefish-512", "avx2"); + namespace { inline void interleave_epi64(__m256i& X0, __m256i& X1) diff --git a/src/lib/block/threefish_avx2/threefish_avx2.h b/src/lib/block/threefish_avx2/threefish_avx2.h index ba24f114f..d851ff0dc 100644 --- a/src/lib/block/threefish_avx2/threefish_avx2.h +++ b/src/lib/block/threefish_avx2/threefish_avx2.h @@ -20,6 +20,12 @@ class BOTAN_DLL Threefish_512_AVX2 : public Threefish_512 private: void encrypt_n(const byte in[], byte out[], size_t blocks) const override; void decrypt_n(const byte in[], byte out[], size_t blocks) const override; + + /* TODO: + void skein_feedfwd(const secure_vector& M, + const secure_vector& T) override; + */ + BlockCipher* clone() const override { return new Threefish_512_AVX2; } }; -- cgit v1.2.3