aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block/threefish/threefish.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-08-10 13:51:25 -0400
committerJack Lloyd <[email protected]>2016-11-26 12:34:15 -0500
commit3bc46d79c4509cbf871f762e39a366e95e8342ce (patch)
tree80359e3d3955412ae027393ec72db51456d5f575 /src/lib/block/threefish/threefish.cpp
parent5372d0b499ad317ab3776c9ac92df866cc6a1e84 (diff)
Add Cilk/OpenMP support
Diffstat (limited to 'src/lib/block/threefish/threefish.cpp')
-rw-r--r--src/lib/block/threefish/threefish.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/lib/block/threefish/threefish.cpp b/src/lib/block/threefish/threefish.cpp
index f592021fb..2acdef020 100644
--- a/src/lib/block/threefish/threefish.cpp
+++ b/src/lib/block/threefish/threefish.cpp
@@ -122,16 +122,10 @@ void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
}
#endif
- for(size_t i = 0; i != blocks; ++i)
+ BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit X0 = load_le<u64bit>(in, 0);
- u64bit X1 = load_le<u64bit>(in, 1);
- u64bit X2 = load_le<u64bit>(in, 2);
- u64bit X3 = load_le<u64bit>(in, 3);
- u64bit X4 = load_le<u64bit>(in, 4);
- u64bit X5 = load_le<u64bit>(in, 5);
- u64bit X6 = load_le<u64bit>(in, 6);
- u64bit X7 = load_le<u64bit>(in, 7);
+ u64bit X0, X1, X2, X3, X4, X5, X6, X7;
+ load_le(in + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
THREEFISH_INJECT_KEY(0);
@@ -145,10 +139,7 @@ void Threefish_512::encrypt_n(const byte in[], byte out[], size_t blocks) const
THREEFISH_ENC_8_ROUNDS(15,16);
THREEFISH_ENC_8_ROUNDS(17,18);
- store_le(out, X0, X1, X2, X3, X4, X5, X6, X7);
-
- in += 64;
- out += 64;
+ store_le(out + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
}
}
@@ -211,16 +202,10 @@ void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
THREEFISH_INJECT_KEY(R2); \
} while(0)
- for(size_t i = 0; i != blocks; ++i)
+ BOTAN_PARALLEL_FOR(size_t i = 0; i < blocks; ++i)
{
- u64bit X0 = load_le<u64bit>(in, 0);
- u64bit X1 = load_le<u64bit>(in, 1);
- u64bit X2 = load_le<u64bit>(in, 2);
- u64bit X3 = load_le<u64bit>(in, 3);
- u64bit X4 = load_le<u64bit>(in, 4);
- u64bit X5 = load_le<u64bit>(in, 5);
- u64bit X6 = load_le<u64bit>(in, 6);
- u64bit X7 = load_le<u64bit>(in, 7);
+ u64bit X0, X1, X2, X3, X4, X5, X6, X7;
+ load_le(in + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
THREEFISH_INJECT_KEY(18);
@@ -234,10 +219,7 @@ void Threefish_512::decrypt_n(const byte in[], byte out[], size_t blocks) const
THREEFISH_DEC_8_ROUNDS(3,2);
THREEFISH_DEC_8_ROUNDS(1,0);
- store_le(out, X0, X1, X2, X3, X4, X5, X6, X7);
-
- in += 64;
- out += 64;
+ store_le(out + BLOCK_SIZE*i, X0, X1, X2, X3, X4, X5, X6, X7);
}
#undef THREEFISH_DEC_8_ROUNDS