aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
parent38775f8927747c414046632dd03a436b192c95a1 (diff)
Notify callers of parallel ops for AES, IDEA, Noekeon, SHACAL2 and Threefish
Diffstat (limited to 'src')
-rw-r--r--src/lib/block/aes/aes.cpp16
-rw-r--r--src/lib/block/aes/aes.h6
-rw-r--r--src/lib/block/idea/idea.cpp12
-rw-r--r--src/lib/block/idea/idea.h2
-rw-r--r--src/lib/block/noekeon/noekeon.cpp12
-rw-r--r--src/lib/block/noekeon/noekeon.h2
-rw-r--r--src/lib/block/shacal2/shacal2.cpp19
-rw-r--r--src/lib/block/shacal2/shacal2.h2
-rw-r--r--src/lib/block/threefish/threefish.cpp12
-rw-r--r--src/lib/block/threefish/threefish.h2
10 files changed, 85 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;
diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp
index 4eab6a4f3..2be15be2e 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -107,6 +107,18 @@ void idea_op(const uint8_t in[], uint8_t out[], size_t blocks, const uint16_t K[
}
+size_t IDEA::parallelism() const
+ {
+#if defined(BOTAN_HAS_IDEA_SSE2)
+ if(CPUID::has_sse2())
+ {
+ return 8;
+ }
+#endif
+
+ return 1;
+ }
+
std::string IDEA::provider() const
{
#if defined(BOTAN_HAS_IDEA_SSE2)
diff --git a/src/lib/block/idea/idea.h b/src/lib/block/idea/idea.h
index 5a718867b..eaef5deee 100644
--- a/src/lib/block/idea/idea.h
+++ b/src/lib/block/idea/idea.h
@@ -26,6 +26,8 @@ class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16>
std::string provider() const override;
std::string name() const override { return "IDEA"; }
BlockCipher* clone() const override { return new IDEA; }
+ size_t parallelism() const override;
+
private:
#if defined(BOTAN_HAS_IDEA_SSE2)
void sse2_idea_op_8(const uint8_t in[64], uint8_t out[64], const uint16_t EK[52]) const;
diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp
index e8bd7b308..c82badd4c 100644
--- a/src/lib/block/noekeon/noekeon.cpp
+++ b/src/lib/block/noekeon/noekeon.cpp
@@ -73,6 +73,18 @@ inline void gamma(uint32_t& A0, uint32_t& A1, uint32_t& A2, uint32_t& A3)
}
+size_t Noekeon::parallelism() const
+ {
+#if defined(BOTAN_HAS_NOEKEON_SIMD)
+ if(CPUID::has_simd_32())
+ {
+ return 4;
+ }
+#endif
+
+ return 1;
+ }
+
std::string Noekeon::provider() const
{
#if defined(BOTAN_HAS_NOEKEON_SIMD)
diff --git a/src/lib/block/noekeon/noekeon.h b/src/lib/block/noekeon/noekeon.h
index 83af6d8d7..de49d658f 100644
--- a/src/lib/block/noekeon/noekeon.h
+++ b/src/lib/block/noekeon/noekeon.h
@@ -25,6 +25,8 @@ class BOTAN_DLL Noekeon final : public Block_Cipher_Fixed_Params<16, 16>
void clear() override;
std::string name() const override { return "Noekeon"; }
BlockCipher* clone() const override { return new Noekeon; }
+ size_t parallelism() const override;
+
private:
#if defined(BOTAN_HAS_NOEKEON_SIMD)
void simd_encrypt_4(const uint8_t in[], uint8_t out[]) const;
diff --git a/src/lib/block/shacal2/shacal2.cpp b/src/lib/block/shacal2/shacal2.cpp
index ea3cd9319..faf0a2d81 100644
--- a/src/lib/block/shacal2/shacal2.cpp
+++ b/src/lib/block/shacal2/shacal2.cpp
@@ -179,8 +179,27 @@ void SHACAL2::key_schedule(const uint8_t key[], size_t len)
}
}
+size_t SHACAL2::parallelism() const
+ {
+#if defined(BOTAN_HAS_SHACAL2_SIMD)
+ if(CPUID::has_simd_32())
+ {
+ return 4;
+ }
+#endif
+
+ return 1;
+ }
+
std::string SHACAL2::provider() const
{
+#if defined(BOTAN_HAS_SHACAL2_SIMD)
+ if(CPUID::has_simd_32())
+ {
+ return "simd";
+ }
+#endif
+
return "base";
}
diff --git a/src/lib/block/shacal2/shacal2.h b/src/lib/block/shacal2/shacal2.h
index f0ade5e50..7e1fa4ac0 100644
--- a/src/lib/block/shacal2/shacal2.h
+++ b/src/lib/block/shacal2/shacal2.h
@@ -25,6 +25,8 @@ class BOTAN_DLL SHACAL2 final : public Block_Cipher_Fixed_Params<32, 16, 64, 4>
void clear() override;
std::string name() const override { return "SHACAL2"; }
BlockCipher* clone() const override { return new SHACAL2; }
+ size_t parallelism() const override;
+
private:
void key_schedule(const uint8_t[], size_t) override;
diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp
index 28a144fb6..99ce135d5 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<uint64_t>& M,
m_K[4] ^ m_K[5] ^ m_K[6] ^ m_K[7] ^ 0x1BD11BDAA9FC1A22;
}
+size_t Threefish_512::parallelism() const
+ {
+#if defined(BOTAN_HAS_THREEFISH_512_AVX2)
+ if(CPUID::has_avx2())
+ {
+ return 2;
+ }
+#endif
+
+ return 1;
+ }
+
std::string Threefish_512::provider() const
{
#if defined(BOTAN_HAS_THREEFISH_512_AVX2)
diff --git a/src/lib/block/threefish/threefish.h b/src/lib/block/threefish/threefish.h
index 8fe690f52..cdd27cb11 100644
--- a/src/lib/block/threefish/threefish.h
+++ b/src/lib/block/threefish/threefish.h
@@ -27,6 +27,8 @@ class BOTAN_DLL Threefish_512 final : public Block_Cipher_Fixed_Params<64, 64>
std::string provider() const override;
std::string name() const override { return "Threefish-512"; }
BlockCipher* clone() const override { return new Threefish_512; }
+ size_t parallelism() const override;
+
protected:
const secure_vector<uint64_t>& get_T() const { return m_T; }
const secure_vector<uint64_t>& get_K() const { return m_K; }