aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/idea
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block/idea')
-rw-r--r--src/lib/block/idea/idea.cpp27
-rw-r--r--src/lib/block/idea/idea.h17
2 files changed, 32 insertions, 12 deletions
diff --git a/src/lib/block/idea/idea.cpp b/src/lib/block/idea/idea.cpp
index 4182c59a7..db55c5c26 100644
--- a/src/lib/block/idea/idea.cpp
+++ b/src/lib/block/idea/idea.cpp
@@ -7,6 +7,7 @@
#include <botan/idea.h>
#include <botan/loadstor.h>
+#include <botan/cpuid.h>
#include <botan/internal/ct_utils.h>
namespace Botan {
@@ -113,6 +114,19 @@ void idea_op(const byte in[], byte out[], size_t blocks, const u16bit K[52])
*/
void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
+#if defined(BOTAN_HAS_IDEA_SSE2)
+ if(CPUID::has_sse2())
+ {
+ while(blocks >= 8)
+ {
+ sse2_idea_op_8(in, out, m_EK.data());
+ in += 8 * BLOCK_SIZE;
+ out += 8 * BLOCK_SIZE;
+ blocks -= 8;
+ }
+ }
+#endif
+
idea_op(in, out, blocks, m_EK.data());
}
@@ -121,6 +135,19 @@ void IDEA::encrypt_n(const byte in[], byte out[], size_t blocks) const
*/
void IDEA::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
+#if defined(BOTAN_HAS_IDEA_SSE2)
+ if(CPUID::has_sse2())
+ {
+ while(blocks >= 8)
+ {
+ sse2_idea_op_8(in, out, m_DK.data());
+ in += 8 * BLOCK_SIZE;
+ out += 8 * BLOCK_SIZE;
+ blocks -= 8;
+ }
+ }
+#endif
+
idea_op(in, out, blocks, m_DK.data());
}
diff --git a/src/lib/block/idea/idea.h b/src/lib/block/idea/idea.h
index 59f98da9e..063ec65c4 100644
--- a/src/lib/block/idea/idea.h
+++ b/src/lib/block/idea/idea.h
@@ -15,7 +15,7 @@ namespace Botan {
/**
* IDEA
*/
-class BOTAN_DLL IDEA : public Block_Cipher_Fixed_Params<8, 16>
+class BOTAN_DLL IDEA final : public Block_Cipher_Fixed_Params<8, 16>
{
public:
void encrypt_n(const byte in[], byte out[], size_t blocks) const override;
@@ -24,18 +24,11 @@ class BOTAN_DLL IDEA : public Block_Cipher_Fixed_Params<8, 16>
void clear() override;
std::string name() const override { return "IDEA"; }
BlockCipher* clone() const override { return new IDEA; }
- protected:
- /**
- * @return const reference to encryption subkeys
- */
- const secure_vector<u16bit>& get_EK() const { return m_EK; }
-
- /**
- * @return const reference to decryption subkeys
- */
- const secure_vector<u16bit>& get_DK() const { return m_DK; }
-
private:
+#if defined(BOTAN_HAS_IDEA_SSE2)
+ void sse2_idea_op_8(const byte in[64], byte out[64], const u16bit EK[52]) const;
+#endif
+
void key_schedule(const byte[], size_t) override;
secure_vector<u16bit> m_EK, m_DK;