aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/noekeon/noekeon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/block/noekeon/noekeon.cpp')
-rw-r--r--src/lib/block/noekeon/noekeon.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/lib/block/noekeon/noekeon.cpp b/src/lib/block/noekeon/noekeon.cpp
index 01f7491f3..eac0979a4 100644
--- a/src/lib/block/noekeon/noekeon.cpp
+++ b/src/lib/block/noekeon/noekeon.cpp
@@ -7,6 +7,7 @@
#include <botan/noekeon.h>
#include <botan/loadstor.h>
+#include <botan/cpuid.h>
namespace Botan {
@@ -72,6 +73,18 @@ inline void gamma(u32bit& A0, u32bit& A1, u32bit& A2, u32bit& A3)
}
+std::string Noekeon::provider() const
+ {
+#if defined(BOTAN_HAS_NOEKEON_SIMD)
+ if(CPUID::has_simd_32())
+ {
+ return "simd";
+ }
+#endif
+
+ return "base";
+ }
+
/*
* Noekeon Round Constants
*/
@@ -85,6 +98,19 @@ const byte Noekeon::RC[] = {
*/
void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
{
+#if defined(BOTAN_HAS_NOEKEON_SIMD)
+ if(CPUID::has_simd_32())
+ {
+ while(blocks >= 4)
+ {
+ simd_encrypt_4(in, out);
+ in += 4 * BLOCK_SIZE;
+ out += 4 * BLOCK_SIZE;
+ blocks -= 4;
+ }
+ }
+#endif
+
for(size_t i = 0; i != blocks; ++i)
{
u32bit A0 = load_be<u32bit>(in, 0);
@@ -123,6 +149,32 @@ void Noekeon::encrypt_n(const byte in[], byte out[], size_t blocks) const
*/
void Noekeon::decrypt_n(const byte in[], byte out[], size_t blocks) const
{
+#if defined(BOTAN_HAS_NOEKEON_SIMD)
+ if(CPUID::has_simd_32())
+ {
+ /*
+ const size_t blocks4 = blocks / 4;
+ const size_t blocks_left = blocks % 4;
+
+ in += blocks4 * BLOCK_SIZE;
+ out += blocks4 * BLOCK_SIZE;
+ blocks = blocks % 4;
+
+ BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks4; ++i)
+ {
+ simd_encrypt_4(in + i*4*BLOCK_SIZE, out + i*4*BLOCK_SIZE);
+ }
+ */
+ while(blocks >= 4)
+ {
+ simd_decrypt_4(in, out);
+ in += 4 * BLOCK_SIZE;
+ out += 4 * BLOCK_SIZE;
+ blocks -= 4;
+ }
+ }
+#endif
+
for(size_t i = 0; i != blocks; ++i)
{
u32bit A0 = load_be<u32bit>(in, 0);