diff options
author | Jeffrey Walton <noloader@gmail.com> | 2021-03-17 17:38:54 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2021-03-17 17:38:54 -0400 |
commit | d4975aa6081947b3bbdd73818bc9825550574dd3 (patch) | |
tree | b41a45abda641904e6c27eb3a72cf632a44ab0a7 | |
parent | 17a1e8ade46774384abf53e5fe3f3686e79bea29 (diff) | |
download | cryptopp-git-d4975aa6081947b3bbdd73818bc9825550574dd3.tar.gz |
Cleanup xorbuf and VerifyBufsEqual (GH #1020)
-rw-r--r-- | misc.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -94,8 +94,23 @@ void xorbuf(byte *buf, const byte *mask, size_t count) if (count == 0) return;
#endif
+#if CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64
// word64 and stride of 8 slows things down on x86_64.
// word64 and stride of 8 makes no difference on ARM.
+ // word64 and stride of 16 benefits PowerPC.
+ while (count >= 16)
+ {
+ word64 r[2], b[2], m[2];
+ memcpy(&b, buf, 16); memcpy(&m, mask, 16);
+
+ r[0] = b[0] ^ m[0];
+ r[1] = b[1] ^ m[1];
+ memcpy(buf, &r, 16);
+
+ buf += 16; mask += 16; count -= 16;
+ }
+#endif
+
while (count >= 4)
{
word32 r, b, m;
@@ -152,8 +167,23 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count) if (count == 0) return;
#endif
+#if CRYPTOPP_BOOL_PPC32 || CRYPTOPP_BOOL_PPC64
// word64 and stride of 8 slows things down on x86_64.
// word64 and stride of 8 makes no difference on ARM.
+ // word64 and stride of 16 benefits PowerPC.
+ while (count >= 16)
+ {
+ word64 b[2], m[2], r[2];
+ memcpy(&b, input, 16); memcpy(&m, mask, 16);
+
+ r[0] = b[0] ^ m[0];
+ r[1] = b[1] ^ m[1];
+ memcpy(output, &r, 16);
+
+ output += 16; input += 16; mask += 16; count -= 16;
+ }
+#endif
+
while (count >= 4)
{
word32 b, m, r;
|