aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/aes
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-08-14 05:33:44 -0400
committerJack Lloyd <[email protected]>2017-08-14 05:33:44 -0400
commit7e2c92527209d47098c0b7b9712fafcd2455590e (patch)
treeea8f7f18a70fa63fc54d7664509002ab68c38d0b /src/lib/block/aes
parent38775f8927747c414046632dd03a436b192c95a1 (diff)
Notify callers of parallel ops for AES, IDEA, Noekeon, SHACAL2 and Threefish
Diffstat (limited to 'src/lib/block/aes')
-rw-r--r--src/lib/block/aes/aes.cpp16
-rw-r--r--src/lib/block/aes/aes.h6
2 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index 21228e0c1..75591bfd2 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -414,6 +414,18 @@ void aes_key_schedule(const uint8_t key[], size_t length,
copy_mem(DK.data(), XDK.data(), DK.size());
}
+size_t aes_parallelism()
+ {
+#if defined(BOTAN_HAS_AES_NI)
+ if(CPUID::has_aes_ni())
+ {
+ return 4;
+ }
+#endif
+
+ return 1;
+ }
+
const char* aes_provider()
{
#if defined(BOTAN_HAS_AES_NI)
@@ -439,6 +451,10 @@ std::string AES_128::provider() const { return aes_provider(); }
std::string AES_192::provider() const { return aes_provider(); }
std::string AES_256::provider() const { return aes_provider(); }
+size_t AES_128::parallelism() const { return aes_parallelism(); }
+size_t AES_192::parallelism() const { return aes_parallelism(); }
+size_t AES_256::parallelism() const { return aes_parallelism(); }
+
void AES_128::encrypt_n(const uint8_t in[], uint8_t 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 52f877e36..a74280947 100644
--- a/src/lib/block/aes/aes.h
+++ b/src/lib/block/aes/aes.h
@@ -26,6 +26,8 @@ class BOTAN_DLL AES_128 final : public Block_Cipher_Fixed_Params<16, 16>
std::string provider() const override;
std::string name() const override { return "AES-128"; }
BlockCipher* clone() const override { return new AES_128; }
+ size_t parallelism() const override;
+
private:
void key_schedule(const uint8_t key[], size_t length) override;
@@ -59,6 +61,8 @@ class BOTAN_DLL AES_192 final : public Block_Cipher_Fixed_Params<16, 24>
std::string provider() const override;
std::string name() const override { return "AES-192"; }
BlockCipher* clone() const override { return new AES_192; }
+ size_t parallelism() const override;
+
private:
#if defined(BOTAN_HAS_AES_SSSE3)
void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;
@@ -93,6 +97,8 @@ class BOTAN_DLL AES_256 final : public Block_Cipher_Fixed_Params<16, 32>
std::string name() const override { return "AES-256"; }
BlockCipher* clone() const override { return new AES_256; }
+ size_t parallelism() const override;
+
private:
#if defined(BOTAN_HAS_AES_SSSE3)
void ssse3_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const;