summaryrefslogtreecommitdiff
path: root/misc.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-02 02:39:17 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-02 02:39:17 +0000
commitcaf9e032e6b4ccb114a74a3936c916bcfaba262d (patch)
tree0fecaa7a6728d07549a41864ea2cedfb245f0bd3 /misc.cpp
parent4e4793cc591e26c788b53c487bee7cab2d377f5e (diff)
downloadcryptopp-caf9e032e6b4ccb114a74a3936c916bcfaba262d.tar.gz
changes for 5.6:
- added AuthenticatedSymmetricCipher interface class and Filter wrappers - added CCM, GCM (with SSE2 assembly), CMAC, and SEED - improved AES speed on x86 and x64 - removed WORD64_AVAILABLE; compiler 64-bit int support is now required git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@433 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'misc.cpp')
-rw-r--r--misc.cpp44
1 files changed, 38 insertions, 6 deletions
diff --git a/misc.cpp b/misc.cpp
index 305edfd..7e4fa89 100644
--- a/misc.cpp
+++ b/misc.cpp
@@ -16,8 +16,7 @@ void xorbuf(byte *buf, const byte *mask, size_t count)
if (IsAligned<word32>(buf) && IsAligned<word32>(mask))
{
- #if defined(WORD64_AVAILABLE) && !defined(CRYPTOPP_SLOW_WORD64)
- if (IsAligned<word64>(buf) && IsAligned<word64>(mask))
+ if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(buf) && IsAligned<word64>(mask))
{
for (i=0; i<count/8; i++)
((word64*)buf)[i] ^= ((word64*)mask)[i];
@@ -27,7 +26,6 @@ void xorbuf(byte *buf, const byte *mask, size_t count)
buf += 8*i;
mask += 8*i;
}
- #endif
for (i=0; i<count/4; i++)
((word32*)buf)[i] ^= ((word32*)mask)[i];
@@ -48,8 +46,7 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
if (IsAligned<word32>(output) && IsAligned<word32>(input) && IsAligned<word32>(mask))
{
- #if defined(WORD64_AVAILABLE) && !defined(CRYPTOPP_SLOW_WORD64)
- if (IsAligned<word64>(output) && IsAligned<word64>(input) && IsAligned<word64>(mask))
+ if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(output) && IsAligned<word64>(input) && IsAligned<word64>(mask))
{
for (i=0; i<count/8; i++)
((word64*)output)[i] = ((word64*)input)[i] ^ ((word64*)mask)[i];
@@ -60,7 +57,6 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
input += 8*i;
mask += 8*i;
}
- #endif
for (i=0; i<count/4; i++)
((word32*)output)[i] = ((word32*)input)[i] ^ ((word32*)mask)[i];
@@ -76,6 +72,42 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count)
output[i] = input[i] ^ mask[i];
}
+bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count)
+{
+ size_t i;
+ byte acc8 = 0;
+
+ if (IsAligned<word32>(buf) && IsAligned<word32>(mask))
+ {
+ word32 acc32 = 0;
+ if (!CRYPTOPP_BOOL_SLOW_WORD64 && IsAligned<word64>(buf) && IsAligned<word64>(mask))
+ {
+ word64 acc64 = 0;
+ for (i=0; i<count/8; i++)
+ acc64 |= ((word64*)buf)[i] ^ ((word64*)mask)[i];
+ count -= 8*i;
+ if (!count)
+ return acc64 == 0;
+ buf += 8*i;
+ mask += 8*i;
+ acc32 = word32(acc64) | word32(acc64>>32);
+ }
+
+ for (i=0; i<count/4; i++)
+ acc32 |= ((word32*)buf)[i] ^ ((word32*)mask)[i];
+ count -= 4*i;
+ if (!count)
+ return acc32 == 0;
+ buf += 4*i;
+ mask += 4*i;
+ acc8 = byte(acc32) | byte(acc32>>8) | byte(acc32>>16) | byte(acc32>>24);
+ }
+
+ for (i=0; i<count; i++)
+ acc8 |= buf[i] ^ mask[i];
+ return acc8 == 0;
+}
+
#if !(defined(_MSC_VER) && (_MSC_VER < 1300))
using std::new_handler;
using std::set_new_handler;