diff options
Diffstat (limited to 'src/lib/block')
-rw-r--r-- | src/lib/block/aes/aes.cpp | 23 | ||||
-rw-r--r-- | src/lib/block/aes/aes.h | 4 | ||||
-rw-r--r-- | src/lib/block/block_cipher.h | 8 | ||||
-rw-r--r-- | src/lib/block/idea/idea.cpp | 12 | ||||
-rw-r--r-- | src/lib/block/idea/idea.h | 2 | ||||
-rw-r--r-- | src/lib/block/noekeon/noekeon.cpp | 12 | ||||
-rw-r--r-- | src/lib/block/noekeon/noekeon.h | 1 | ||||
-rw-r--r-- | src/lib/block/serpent/serpent.cpp | 12 | ||||
-rw-r--r-- | src/lib/block/serpent/serpent.h | 1 | ||||
-rw-r--r-- | src/lib/block/threefish/threefish.cpp | 12 | ||||
-rw-r--r-- | src/lib/block/threefish/threefish.h | 1 |
11 files changed, 88 insertions, 0 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp index eb24ce5a3..9483dc0eb 100644 --- a/src/lib/block/aes/aes.cpp +++ b/src/lib/block/aes/aes.cpp @@ -416,8 +416,31 @@ void aes_key_schedule(const byte key[], size_t length, copy_mem(DK.data(), XDK.data(), DK.size()); } +const char* aes_provider() + { +#if defined(BOTAN_HAS_AES_NI) + if(CPUID::has_aes_ni()) + { + return "aesni"; + } +#endif + +#if defined(BOTAN_HAS_AES_SSSE3) + if(CPUID::has_ssse3()) + { + return "ssse3"; + } +#endif + + return "base"; + } + } +const char* AES_128::provider() const { return aes_provider(); } +const char* AES_192::provider() const { return aes_provider(); } +const char* AES_256::provider() const { return aes_provider(); } + void AES_128::encrypt_n(const byte in[], byte out[], size_t blocks) const { #if defined(BOTAN_HAS_AES_NI) diff --git a/src/lib/block/aes/aes.h b/src/lib/block/aes/aes.h index d6b334d3c..e22e96e00 100644 --- a/src/lib/block/aes/aes.h +++ b/src/lib/block/aes/aes.h @@ -23,6 +23,7 @@ class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16> void clear() override; + const char* provider() const override; std::string name() const override { return "AES-128"; } BlockCipher* clone() const override { return new AES_128; } private: @@ -55,6 +56,7 @@ class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24> void clear() override; + const char* provider() const override; std::string name() const override { return "AES-192"; } BlockCipher* clone() const override { return new AES_192; } private: @@ -87,6 +89,8 @@ class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32> void clear() override; + const char* provider() const override; + std::string name() const override { return "AES-256"; } BlockCipher* clone() const override { return new AES_256; } private: diff --git a/src/lib/block/block_cipher.h b/src/lib/block/block_cipher.h index 0f4c2c1c5..68fc0f487 100644 --- a/src/lib/block/block_cipher.h +++ b/src/lib/block/block_cipher.h @@ -10,6 +10,7 @@ #include <botan/scan_name.h> #include <botan/sym_algo.h> +#include <string> namespace Botan { @@ -53,6 +54,13 @@ class BOTAN_DLL BlockCipher : public SymmetricAlgorithm } /** + * @return provider information about this implementation. Default is "base", + * might also return "sse2", "avx2", "openssl", or some other arbitrary string. + * The return value is guaranteed to point to a string literal constant. + */ + virtual const char* provider() const { return "base"; } + + /** * Encrypt a block. * @param in The plaintext block to be encrypted as a byte array. * Must be of length block_size(). diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp index db55c5c26..8616b7765 100644 --- a/src/lib/block/idea/idea.cpp +++ b/src/lib/block/idea/idea.cpp @@ -109,6 +109,18 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52]) } +const char* IDEA::provider() const + { +#if defined(BOTAN_HAS_IDEA_SSE2) + if(CPUID::has_sse2()) + { + return "sse2"; + } +#endif + + return "base"; + } + /* * IDEA Encryption */ diff --git a/src/lib/block/idea/idea.h b/src/lib/block/idea/idea.h index 063ec65c4..4a72685c8 100644 --- a/src/lib/block/idea/idea.h +++ b/src/lib/block/idea/idea.h @@ -22,6 +22,8 @@ class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16> void decrypt_n(const byte in[], byte out[], size_t blocks) const override; void clear() override; + + const char* provider() const override; std::string name() const override { return "IDEA"; } BlockCipher* clone() const override { return new IDEA; } private: diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp index 5e7c0229e..fbafe092e 100644 --- a/src/lib/block/noekeon/noekeon.cpp +++ b/src/lib/block/noekeon/noekeon.cpp @@ -73,6 +73,18 @@ inline void gamma(u32bit& A0, u32bit& A1, u32bit& A2, u32bit& A3) } +const char* Noekeon::provider() const + { +#if defined(BOTAN_HAS_NOEKEON_SIMD) + if(CPUID::has_simd_32()) + { + return "simd"; + } +#endif + + return "base"; + } + /* * Noekeon Round Constants */ diff --git a/src/lib/block/noekeon/noekeon.h b/src/lib/block/noekeon/noekeon.h index 30c15a001..31069eb75 100644 --- a/src/lib/block/noekeon/noekeon.h +++ b/src/lib/block/noekeon/noekeon.h @@ -21,6 +21,7 @@ class BOTAN_DLL Noekeon final : public Block_Cipher_Fixed_Params<16, 16> 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; + const char* provider() const override; void clear() override; std::string name() const override { return "Noekeon"; } BlockCipher* clone() const override { return new Noekeon; } diff --git a/src/lib/block/serpent/serpent.cpp b/src/lib/block/serpent/serpent.cpp index 1e3699914..f2a6035f1 100644 --- a/src/lib/block/serpent/serpent.cpp +++ b/src/lib/block/serpent/serpent.cpp @@ -231,4 +231,16 @@ void Serpent::clear() zap(m_round_key); } +const char* Serpent::provider() const + { +#if defined(BOTAN_HAS_SERPENT_SIMD) + if(CPUID::has_simd_32()) + { + return "simd"; + } +#endif + + return "base"; + } + } diff --git a/src/lib/block/serpent/serpent.h b/src/lib/block/serpent/serpent.h index 8f854678a..72c26d452 100644 --- a/src/lib/block/serpent/serpent.h +++ b/src/lib/block/serpent/serpent.h @@ -23,6 +23,7 @@ class BOTAN_DLL Serpent final : public Block_Cipher_Fixed_Params<16, 16, 32, 8> void decrypt_n(const byte in[], byte out[], size_t blocks) const override; void clear() override; + const char* provider() const override; std::string name() const override { return "Serpent"; } BlockCipher* clone() const override { return new Serpent; } diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp index 33b3e25c8..4ba834c94 100644 --- a/src/lib/block/threefish/threefish.cpp +++ b/src/lib/block/threefish/threefish.cpp @@ -98,6 +98,18 @@ void Threefish_512::skein_feedfwd(const secure_vector<u64bit>& M, m_K[4] ^ m_K[5] ^ m_K[6] ^ m_K[7] ^ 0x1BD11BDAA9FC1A22; } +const char* Threefish_512::provider() const + { +#if defined(BOTAN_HAS_THREEFISH_512_AVX2) + if(CPUID::has_avx2()) + { + return "avx2"; + } +#endif + + return "base"; + } + void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const { BOTAN_ASSERT(m_K.size() == 9, "Key was set"); diff --git a/src/lib/block/threefish/threefish.h b/src/lib/block/threefish/threefish.h index 270e71354..230c742f3 100644 --- a/src/lib/block/threefish/threefish.h +++ b/src/lib/block/threefish/threefish.h @@ -24,6 +24,7 @@ class BOTAN_DLL Threefish_512 final : public Block_Cipher_Fixed_Params<64, 64> void set_tweak(const byte tweak[], size_t len); void clear() override; + const char* provider() const override; std::string name() const override { return "Threefish-512"; } BlockCipher* clone() const override { return new Threefish_512; } protected: |