aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/aes
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-09-15 09:16:46 -0400
committerJack Lloyd <[email protected]>2016-09-15 09:25:49 -0400
commit04bf8dc51861bab37d6260de8b318dc71ea4bba7 (patch)
tree03cf4b8d607607444049bc2b9880abc4c1fc6a8e /src/lib/block/aes
parenta7eba3629cc0d76444f5241fb4b9e8793ddb61cd (diff)
Add T::provider() to allow user to inquire about implementation used
For block ciphers, stream ciphers, hashes, MACs, and cipher modes. Cipher_Mode already had it, with a slightly different usage.
Diffstat (limited to 'src/lib/block/aes')
-rw-r--r--src/lib/block/aes/aes.cpp23
-rw-r--r--src/lib/block/aes/aes.h4
2 files changed, 27 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: