add word128

This commit is contained in:
weidai 2007-05-04 15:25:08 +00:00
parent d2510f30c7
commit 240a14e561
2 changed files with 31 additions and 6 deletions

View File

@ -135,6 +135,8 @@ typedef unsigned int word32;
typedef word32 hword; typedef word32 hword;
typedef word64 word; typedef word64 word;
typedef __uint128_t dword; typedef __uint128_t dword;
typedef __uint128_t word128;
#define CRYPTOPP_WORD128_AVAILABLE
#else #else
// if we're here, it means we're on a 64-bit CPU but we don't have a way to obtain 128-bit multiplication results // if we're here, it means we're on a 64-bit CPU but we don't have a way to obtain 128-bit multiplication results
typedef word16 hword; typedef word16 hword;
@ -277,6 +279,14 @@ NAMESPACE_END
#endif #endif
#endif #endif
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(_MSC_VER) && defined(_M_X64)
#define CRYPTOPP_X64_MASM_AVAILABLE
#endif
#if !defined(CRYPTOPP_DISABLE_ASM) && defined(__GNUC__) && defined(__x86_64__)
#define CRYPTOPP_X64_ASM_AVAILABLE
#endif
#if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__)) #if !defined(CRYPTOPP_DISABLE_SSE2) && (defined(CRYPTOPP_MSVC6PP_OR_LATER) || defined(__SSE2__))
#define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1 #define CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE 1
#else #else

View File

@ -2,7 +2,7 @@
#include "pch.h" #include "pch.h"
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include "files.h" #include "files.h"
#include "hex.h" #include "hex.h"
#include "base32.h" #include "base32.h"
@ -92,6 +92,7 @@ bool ValidateAll(bool thorough)
pass=ValidateCamellia() && pass; pass=ValidateCamellia() && pass;
pass=ValidateSalsa() && pass; pass=ValidateSalsa() && pass;
pass=ValidateSosemanuk() && pass; pass=ValidateSosemanuk() && pass;
pass=ValidateVMAC() && pass;
pass=ValidateBBS() && pass; pass=ValidateBBS() && pass;
pass=ValidateDH() && pass; pass=ValidateDH() && pass;
@ -199,6 +200,17 @@ bool TestSettings()
cout << "passed: word64 not available" << endl; cout << "passed: word64 not available" << endl;
#endif #endif
#ifdef CRYPTOPP_WORD128_AVAILABLE
if (sizeof(word128) == 16)
cout << "passed: ";
else
{
cout << "FAILED: ";
pass = false;
}
cout << "sizeof(word128) == " << sizeof(word128) << endl;
#endif
if (sizeof(word) == 2*sizeof(hword) if (sizeof(word) == 2*sizeof(hword)
#ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
&& sizeof(dword) == 2*sizeof(word) && sizeof(dword) == 2*sizeof(word)
@ -501,15 +513,13 @@ bool ValidateDES()
bool TestModeIV(SymmetricCipher &e, SymmetricCipher &d) bool TestModeIV(SymmetricCipher &e, SymmetricCipher &d)
{ {
SecByteBlock lastIV; SecByteBlock lastIV, iv(e.IVSize());
StreamTransformationFilter filter(e, new StreamTransformationFilter(d)); StreamTransformationFilter filter(e, new StreamTransformationFilter(d));
byte plaintext[20480]; byte plaintext[20480];
for (unsigned int i=1; i<sizeof(plaintext); i*=2) for (unsigned int i=1; i<sizeof(plaintext); i*=2)
{ {
SecByteBlock iv(e.IVSize()); e.GetNextIV(GlobalRNG(), iv);
e.GetNextIV(iv);
if (iv == lastIV) if (iv == lastIV)
return false; return false;
else else
@ -1330,6 +1340,11 @@ bool ValidateSalsa()
bool ValidateSosemanuk() bool ValidateSosemanuk()
{ {
cout << "\nSosemanuk validation suite running...\n"; cout << "\nSosemanuk validation suite running...\n";
return RunTestDataFile("TestVectors/sosemanuk.txt"); return RunTestDataFile("TestVectors/sosemanuk.txt");
} }
bool ValidateVMAC()
{
cout << "\nVMAC validation suite running...\n";
return RunTestDataFile("TestVectors/vmac.txt");
}