Merge branch 'master' into hmqv
commit
11c723e1b9
20
blake2.cpp
20
blake2.cpp
|
|
@ -14,21 +14,9 @@
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
// Uncomment for benchmarking C++ against SSE2 or NEON
|
// Uncomment for benchmarking C++ against SSE2 or NEON
|
||||||
#undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
|
// #undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
|
||||||
// #undef CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE
|
// #undef CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE
|
||||||
|
|
||||||
// Visual Studio needs both VS2005 (1400) and _M_64 for SSE2 and _mm_set_epi64x()
|
|
||||||
// http://msdn.microsoft.com/en-us/library/y0dh78ez%28v=vs.80%29.aspx
|
|
||||||
#if defined(_MSC_VER) && ((_MSC_VER < 1400) || !defined(_M_X64))
|
|
||||||
# undef CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Visual Studio needs VS2008 (1500); no dependency on _mm_set_epi64x()
|
|
||||||
// http://msdn.microsoft.com/en-us/library/bb892950%28v=vs.90%29.aspx
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1500)
|
|
||||||
# undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Apple Clang 6.0/Clang 3.5 does not have SSSE3 intrinsics
|
// Apple Clang 6.0/Clang 3.5 does not have SSSE3 intrinsics
|
||||||
// http://llvm.org/bugs/show_bug.cgi?id=20213
|
// http://llvm.org/bugs/show_bug.cgi?id=20213
|
||||||
#if (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 60000)) || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION <= 30500))
|
#if (defined(CRYPTOPP_APPLE_CLANG_VERSION) && (CRYPTOPP_APPLE_CLANG_VERSION <= 60000)) || (defined(CRYPTOPP_LLVM_CLANG_VERSION) && (CRYPTOPP_LLVM_CLANG_VERSION <= 30500))
|
||||||
|
|
@ -37,12 +25,12 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
// Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x.
|
// Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x.
|
||||||
// Also see http://stackoverflow.com/a/38547909/608639
|
// Also see http://stackoverflow.com/a/38547909/608639
|
||||||
#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5130)
|
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600))
|
||||||
inline __m128i _mm_set_epi64x(const uint64_t a, const uint64_t b)
|
inline __m128i _mm_set_epi64x(const word64 a, const word64 b)
|
||||||
{
|
{
|
||||||
union INT_128_64x2 {
|
union INT_128_64x2 {
|
||||||
__m128i v128;
|
__m128i v128;
|
||||||
uint64_t v64[2];
|
word64 v64[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
INT_128_64x2 val;
|
INT_128_64x2 val;
|
||||||
|
|
|
||||||
3
config.h
3
config.h
|
|
@ -217,6 +217,9 @@ typedef unsigned int word32;
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
typedef unsigned __int64 word64;
|
typedef unsigned __int64 word64;
|
||||||
#define W64LIT(x) x##ui64
|
#define W64LIT(x) x##ui64
|
||||||
|
#elif ((__arm64__ || __aarch64__) && (_LP64 || __LP64__))
|
||||||
|
typedef unsigned long word64;
|
||||||
|
#define W64LIT(x) x##UL
|
||||||
#else
|
#else
|
||||||
typedef unsigned long long word64;
|
typedef unsigned long long word64;
|
||||||
#define W64LIT(x) x##ULL
|
#define W64LIT(x) x##ULL
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,9 @@ typedef unsigned int word32;
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
typedef unsigned __int64 word64;
|
typedef unsigned __int64 word64;
|
||||||
#define W64LIT(x) x##ui64
|
#define W64LIT(x) x##ui64
|
||||||
|
#elif ((__arm64__ || __aarch64__) && (_LP64 || __LP64__))
|
||||||
|
typedef unsigned long word64;
|
||||||
|
#define W64LIT(x) x##UL
|
||||||
#else
|
#else
|
||||||
typedef unsigned long long word64;
|
typedef unsigned long long word64;
|
||||||
#define W64LIT(x) x##ULL
|
#define W64LIT(x) x##ULL
|
||||||
|
|
|
||||||
64
cpu.cpp
64
cpu.cpp
|
|
@ -319,8 +319,8 @@ void DetectX86Features()
|
||||||
// http://community.arm.com/groups/android-community/blog/2014/10/10/runtime-detection-of-cpu-features-on-an-armv8-a-cpu
|
// http://community.arm.com/groups/android-community/blog/2014/10/10/runtime-detection-of-cpu-features-on-an-armv8-a-cpu
|
||||||
//
|
//
|
||||||
bool CRYPTOPP_SECTION_INIT g_ArmDetectionDone = false;
|
bool CRYPTOPP_SECTION_INIT g_ArmDetectionDone = false;
|
||||||
bool CRYPTOPP_SECTION_INIT g_hasNEON = false, CRYPTOPP_SECTION_INIT g_hasCRC32 = false, CRYPTOPP_SECTION_INIT g_hasAES = false, CRYPTOPP_SECTION_INIT g_hasSHA1 = false;
|
bool CRYPTOPP_SECTION_INIT g_hasNEON = false, CRYPTOPP_SECTION_INIT g_hasPMULL = false, CRYPTOPP_SECTION_INIT g_hasCRC32 = false;
|
||||||
bool CRYPTOPP_SECTION_INIT g_hasSHA2 = false;
|
bool CRYPTOPP_SECTION_INIT g_hasAES = false, CRYPTOPP_SECTION_INIT g_hasSHA1 = false, CRYPTOPP_SECTION_INIT g_hasSHA2 = false;
|
||||||
word32 CRYPTOPP_SECTION_INIT g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
|
word32 CRYPTOPP_SECTION_INIT g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
|
||||||
|
|
||||||
#ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
|
#ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
|
||||||
|
|
@ -332,6 +332,12 @@ extern "C"
|
||||||
longjmp(s_jmpNoNEON, 1);
|
longjmp(s_jmpNoNEON, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static jmp_buf s_jmpNoPMULL;
|
||||||
|
static void SigIllHandlerPMULL(int)
|
||||||
|
{
|
||||||
|
longjmp(s_jmpNoPMULL, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static jmp_buf s_jmpNoCRC32;
|
static jmp_buf s_jmpNoCRC32;
|
||||||
static void SigIllHandlerCRC32(int)
|
static void SigIllHandlerCRC32(int)
|
||||||
{
|
{
|
||||||
|
|
@ -426,6 +432,59 @@ static bool TryNEON()
|
||||||
#endif // CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE
|
#endif // CRYPTOPP_BOOL_NEON_INTRINSICS_AVAILABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool TryPMULL()
|
||||||
|
{
|
||||||
|
#if (CRYPTOPP_BOOL_ARM_CRYPTO_INTRINSICS_AVAILABLE)
|
||||||
|
# if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
|
||||||
|
volatile bool result = true;
|
||||||
|
__try
|
||||||
|
{
|
||||||
|
const poly64_t a1={1}, b1={2};
|
||||||
|
const poly64x2_t a2={1}, b2={2};
|
||||||
|
const poly128_t r1 = vmull_p64(a1, b1);
|
||||||
|
const poly128_t r2 = vmull_high_p64(a2, b2);
|
||||||
|
|
||||||
|
result = (r1 != r2);
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
# else
|
||||||
|
// longjmp and clobber warnings. Volatile is required.
|
||||||
|
// http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
|
||||||
|
volatile bool result = true;
|
||||||
|
|
||||||
|
volatile SigHandler oldHandler = signal(SIGILL, SigIllHandlerPMULL);
|
||||||
|
if (oldHandler == SIG_ERR)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
volatile sigset_t oldMask;
|
||||||
|
if (sigprocmask(0, NULL, (sigset_t*)&oldMask))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (setjmp(s_jmpNoPMULL))
|
||||||
|
result = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const poly64_t a1={1}, b1={2};
|
||||||
|
const poly64x2_t a2={1}, b2={2};
|
||||||
|
const poly128_t r1 = vmull_p64(a1, b1);
|
||||||
|
const poly128_t r2 = vmull_high_p64(a2, b2);
|
||||||
|
|
||||||
|
result = (r1 != r2);
|
||||||
|
}
|
||||||
|
|
||||||
|
sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL);
|
||||||
|
signal(SIGILL, oldHandler);
|
||||||
|
return result;
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif // CRYPTOPP_BOOL_CRYPTO_INTRINSICS_AVAILABLE
|
||||||
|
}
|
||||||
|
|
||||||
static bool TryCRC32()
|
static bool TryCRC32()
|
||||||
{
|
{
|
||||||
#if (CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE)
|
#if (CRYPTOPP_BOOL_ARM_CRC32_INTRINSICS_AVAILABLE)
|
||||||
|
|
@ -660,6 +719,7 @@ void DetectArmFeatures()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
g_hasNEON = TryNEON();
|
g_hasNEON = TryNEON();
|
||||||
|
g_hasPMULL = TryPMULL();
|
||||||
g_hasCRC32 = TryCRC32();
|
g_hasCRC32 = TryCRC32();
|
||||||
g_hasAES = TryAES();
|
g_hasAES = TryAES();
|
||||||
g_hasSHA1 = TrySHA1();
|
g_hasSHA1 = TrySHA1();
|
||||||
|
|
|
||||||
59
cpu.h
59
cpu.h
|
|
@ -364,7 +364,7 @@ inline int GetCacheLineSize()
|
||||||
#elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
|
#elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
|
||||||
|
|
||||||
extern bool g_ArmDetectionDone;
|
extern bool g_ArmDetectionDone;
|
||||||
extern bool g_hasNEON, g_hasCRC32, g_hasAES, g_hasSHA1, g_hasSHA2;
|
extern bool g_hasNEON, g_hasPMULL, g_hasCRC32, g_hasAES, g_hasSHA1, g_hasSHA2;
|
||||||
void CRYPTOPP_API DetectArmFeatures();
|
void CRYPTOPP_API DetectArmFeatures();
|
||||||
|
|
||||||
//! \brief Determine if an ARM processor has Advanced SIMD available
|
//! \brief Determine if an ARM processor has Advanced SIMD available
|
||||||
|
|
@ -380,6 +380,19 @@ inline bool HasNEON()
|
||||||
return g_hasNEON;
|
return g_hasNEON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \brief Determine if an ARM processor provides Polynomial Multiplication (long)
|
||||||
|
//! \returns true if the hardware is capable of polynomial multiplications at runtime, false otherwise.
|
||||||
|
//! \details The multiplication instructions are available under Aarch64 (ARM-64) and Aarch32 (ARM-32).
|
||||||
|
//! \details Runtime support requires compile time support. When compiling with GCC, you may
|
||||||
|
//! need to compile with <tt>-march=armv8-a+crypto</tt>; while Apple requires
|
||||||
|
//! <tt>-arch arm64</tt>. Also see ARM's <tt>__ARM_FEATURE_CRYPTO</tt> preprocessor macro.
|
||||||
|
inline bool HasPMULL()
|
||||||
|
{
|
||||||
|
if (!g_ArmDetectionDone)
|
||||||
|
DetectArmFeatures();
|
||||||
|
return g_hasPMULL;
|
||||||
|
}
|
||||||
|
|
||||||
//! \brief Determine if an ARM processor has CRC32 available
|
//! \brief Determine if an ARM processor has CRC32 available
|
||||||
//! \returns true if the hardware is capable of CRC32 at runtime, false otherwise.
|
//! \returns true if the hardware is capable of CRC32 at runtime, false otherwise.
|
||||||
//! \details CRC32 instructions provide access to the processor's CRC32 and CRC32-C intructions.
|
//! \details CRC32 instructions provide access to the processor's CRC32 and CRC32-C intructions.
|
||||||
|
|
@ -485,20 +498,6 @@ inline int GetCacheLineSize()
|
||||||
#else
|
#else
|
||||||
#define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
|
#define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
|
||||||
|
|
||||||
#if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
|
|
||||||
#define NEW_LINE "\n"
|
|
||||||
#define INTEL_PREFIX ".intel_syntax;"
|
|
||||||
#define INTEL_NOPREFIX ".intel_syntax;"
|
|
||||||
#define ATT_PREFIX ".att_syntax;"
|
|
||||||
#define ATT_NOPREFIX ".att_syntax;"
|
|
||||||
#else
|
|
||||||
#define NEW_LINE
|
|
||||||
#define INTEL_PREFIX ".intel_syntax prefix;"
|
|
||||||
#define INTEL_NOPREFIX ".intel_syntax noprefix;"
|
|
||||||
#define ATT_PREFIX ".att_syntax prefix;"
|
|
||||||
#define ATT_NOPREFIX ".att_syntax noprefix;"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// define these in two steps to allow arguments to be expanded
|
// define these in two steps to allow arguments to be expanded
|
||||||
#define GNU_AS1(x) #x ";" NEW_LINE
|
#define GNU_AS1(x) #x ";" NEW_LINE
|
||||||
#define GNU_AS2(x, y) #x ", " #y ";" NEW_LINE
|
#define GNU_AS2(x, y) #x ", " #y ";" NEW_LINE
|
||||||
|
|
@ -519,21 +518,6 @@ inline int GetCacheLineSize()
|
||||||
#define IF0(y)
|
#define IF0(y)
|
||||||
#define IF1(y) y
|
#define IF1(y) y
|
||||||
|
|
||||||
// Should be confined to GCC, but its used to help manage Clang 3.4 compiler error.
|
|
||||||
// Also see LLVM Bug 24232, http://llvm.org/bugs/show_bug.cgi?id=24232 .
|
|
||||||
#ifndef INTEL_PREFIX
|
|
||||||
#define INTEL_PREFIX
|
|
||||||
#endif
|
|
||||||
#ifndef INTEL_NOPREFIX
|
|
||||||
#define INTEL_NOPREFIX
|
|
||||||
#endif
|
|
||||||
#ifndef ATT_PREFIX
|
|
||||||
#define ATT_PREFIX
|
|
||||||
#endif
|
|
||||||
#ifndef ATT_NOPREFIX
|
|
||||||
#define ATT_NOPREFIX
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CRYPTOPP_GENERATE_X64_MASM
|
#ifdef CRYPTOPP_GENERATE_X64_MASM
|
||||||
#define ASM_MOD(x, y) ((x) MOD (y))
|
#define ASM_MOD(x, y) ((x) MOD (y))
|
||||||
#define XMMWORD_PTR XMMWORD PTR
|
#define XMMWORD_PTR XMMWORD PTR
|
||||||
|
|
@ -666,6 +650,21 @@ inline int GetCacheLineSize()
|
||||||
|
|
||||||
#endif // X86/X32/X64
|
#endif // X86/X32/X64
|
||||||
|
|
||||||
|
// Applies to both X86/X32/X64 and ARM32/ARM64
|
||||||
|
#if defined(CRYPTOPP_LLVM_CLANG_VERSION) || defined(CRYPTOPP_APPLE_CLANG_VERSION) || defined(CRYPTOPP_CLANG_INTEGRATED_ASSEMBLER)
|
||||||
|
#define NEW_LINE "\n"
|
||||||
|
#define INTEL_PREFIX ".intel_syntax;"
|
||||||
|
#define INTEL_NOPREFIX ".intel_syntax;"
|
||||||
|
#define ATT_PREFIX ".att_syntax;"
|
||||||
|
#define ATT_NOPREFIX ".att_syntax;"
|
||||||
|
#else
|
||||||
|
#define NEW_LINE
|
||||||
|
#define INTEL_PREFIX ".intel_syntax prefix;"
|
||||||
|
#define INTEL_NOPREFIX ".intel_syntax noprefix;"
|
||||||
|
#define ATT_PREFIX ".att_syntax prefix;"
|
||||||
|
#define ATT_NOPREFIX ".att_syntax noprefix;"
|
||||||
|
#endif
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
||||||
#endif // CRYPTOPP_CPU_H
|
#endif // CRYPTOPP_CPU_H
|
||||||
|
|
|
||||||
10
datatest.cpp
10
datatest.cpp
|
|
@ -24,7 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__COVERITY__)
|
#if defined(__COVERITY__)
|
||||||
extern "C" void __coverity_tainted_data_sanitize__(void *);
|
extern "C" void __coverity_tainted_data_sanitize__(void *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USING_NAMESPACE(CryptoPP)
|
USING_NAMESPACE(CryptoPP)
|
||||||
|
|
@ -113,7 +113,7 @@ void PutDecodedDatumInto(const TestData &data, const char *name, BufferedTransfo
|
||||||
repeat = atoi(s1.c_str()+1);
|
repeat = atoi(s1.c_str()+1);
|
||||||
s1 = s1.substr(s1.find(' ')+1);
|
s1 = s1.substr(s1.find(' ')+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
s2 = ""; // MSVC 6 doesn't have clear();
|
s2 = ""; // MSVC 6 doesn't have clear();
|
||||||
|
|
||||||
if (s1[0] == '\"')
|
if (s1[0] == '\"')
|
||||||
|
|
@ -184,9 +184,9 @@ public:
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &value = i->second;
|
const std::string &value = i->second;
|
||||||
|
|
||||||
if (valueType == typeid(int))
|
if (valueType == typeid(int))
|
||||||
*reinterpret_cast<int *>(pValue) = atoi(value.c_str());
|
*reinterpret_cast<int *>(pValue) = atoi(value.c_str());
|
||||||
else if (valueType == typeid(Integer))
|
else if (valueType == typeid(Integer))
|
||||||
|
|
@ -637,7 +637,7 @@ void TestKeyDerivationFunction(TestData &v)
|
||||||
reinterpret_cast<const byte*>(key.data()), key.size(),
|
reinterpret_cast<const byte*>(key.data()), key.size(),
|
||||||
reinterpret_cast<const byte*>(salt.data()), salt.size(),
|
reinterpret_cast<const byte*>(salt.data()), salt.size(),
|
||||||
reinterpret_cast<const byte*>(info.data()), info.size());
|
reinterpret_cast<const byte*>(info.data()), info.size());
|
||||||
|
|
||||||
if(calc != derived || ret != length)
|
if(calc != derived || ret != length)
|
||||||
SignalTestFailure();
|
SignalTestFailure();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ void FIPS140_SampleApplication()
|
||||||
const byte message[] = {'a', 'b', 'c'};
|
const byte message[] = {'a', 'b', 'c'};
|
||||||
const byte expectedDigest[] = {0xA9,0x99,0x3E,0x36,0x47,0x06,0x81,0x6A,0xBA,0x3E,0x25,0x71,0x78,0x50,0xC2,0x6C,0x9C,0xD0,0xD8,0x9D};
|
const byte expectedDigest[] = {0xA9,0x99,0x3E,0x36,0x47,0x06,0x81,0x6A,0xBA,0x3E,0x25,0x71,0x78,0x50,0xC2,0x6C,0x9C,0xD0,0xD8,0x9D};
|
||||||
byte digest[20];
|
byte digest[20];
|
||||||
|
|
||||||
SHA1 sha;
|
SHA1 sha;
|
||||||
sha.Update(message, 3);
|
sha.Update(message, 3);
|
||||||
sha.Final(digest);
|
sha.Final(digest);
|
||||||
|
|
|
||||||
40
fipstest.cpp
40
fipstest.cpp
|
|
@ -82,8 +82,8 @@ void KnownAnswerTest(RandomNumberGenerator &rng, const char *output)
|
||||||
|
|
||||||
template <class CIPHER>
|
template <class CIPHER>
|
||||||
void X917RNG_KnownAnswerTest(
|
void X917RNG_KnownAnswerTest(
|
||||||
const char *key,
|
const char *key,
|
||||||
const char *seed,
|
const char *seed,
|
||||||
const char *deterministicTimeVector,
|
const char *deterministicTimeVector,
|
||||||
const char *output,
|
const char *output,
|
||||||
CIPHER *dummy = NULL)
|
CIPHER *dummy = NULL)
|
||||||
|
|
@ -119,9 +119,9 @@ void KnownAnswerTest(StreamTransformation &encryption, StreamTransformation &dec
|
||||||
|
|
||||||
template <class CIPHER>
|
template <class CIPHER>
|
||||||
void SymmetricEncryptionKnownAnswerTest(
|
void SymmetricEncryptionKnownAnswerTest(
|
||||||
const char *key,
|
const char *key,
|
||||||
const char *hexIV,
|
const char *hexIV,
|
||||||
const char *plaintext,
|
const char *plaintext,
|
||||||
const char *ecb,
|
const char *ecb,
|
||||||
const char *cbc,
|
const char *cbc,
|
||||||
const char *cfb,
|
const char *cfb,
|
||||||
|
|
@ -210,22 +210,22 @@ void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_D
|
||||||
std::string ciphertext, decrypted;
|
std::string ciphertext, decrypted;
|
||||||
|
|
||||||
StringSource(
|
StringSource(
|
||||||
testMessage,
|
testMessage,
|
||||||
true,
|
true,
|
||||||
new PK_EncryptorFilter(
|
new PK_EncryptorFilter(
|
||||||
rng,
|
rng,
|
||||||
encryptor,
|
encryptor,
|
||||||
new StringSink(ciphertext)));
|
new StringSink(ciphertext)));
|
||||||
|
|
||||||
if (ciphertext == testMessage)
|
if (ciphertext == testMessage)
|
||||||
throw 0;
|
throw 0;
|
||||||
|
|
||||||
StringSource(
|
StringSource(
|
||||||
ciphertext,
|
ciphertext,
|
||||||
true,
|
true,
|
||||||
new PK_DecryptorFilter(
|
new PK_DecryptorFilter(
|
||||||
rng,
|
rng,
|
||||||
decryptor,
|
decryptor,
|
||||||
new StringSink(decrypted)));
|
new StringSink(decrypted)));
|
||||||
|
|
||||||
if (decrypted != testMessage)
|
if (decrypted != testMessage)
|
||||||
|
|
@ -244,11 +244,11 @@ void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier
|
||||||
RandomPool rng;
|
RandomPool rng;
|
||||||
|
|
||||||
StringSource(
|
StringSource(
|
||||||
"test message",
|
"test message",
|
||||||
true,
|
true,
|
||||||
new SignerFilter(
|
new SignerFilter(
|
||||||
rng,
|
rng,
|
||||||
signer,
|
signer,
|
||||||
new VerifierFilter(verifier, NULL, VerifierFilter::THROW_EXCEPTION),
|
new VerifierFilter(verifier, NULL, VerifierFilter::THROW_EXCEPTION),
|
||||||
true));
|
true));
|
||||||
}
|
}
|
||||||
|
|
@ -530,7 +530,7 @@ void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac
|
||||||
"Sample #2",
|
"Sample #2",
|
||||||
"0922d3405faa3d194f82a45830737d5cc6c75d24");
|
"0922d3405faa3d194f82a45830737d5cc6c75d24");
|
||||||
|
|
||||||
const char *keyRSA1 =
|
const char *keyRSA1 =
|
||||||
"30820150020100300d06092a864886f70d01010105000482013a3082013602010002400a66791dc6988168de7ab77419bb7fb0"
|
"30820150020100300d06092a864886f70d01010105000482013a3082013602010002400a66791dc6988168de7ab77419bb7fb0"
|
||||||
"c001c62710270075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67cdc9a9af55d655620bbab0203010001"
|
"c001c62710270075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67cdc9a9af55d655620bbab0203010001"
|
||||||
"02400123c5b61ba36edb1d3679904199a89ea80c09b9122e1400c09adcf7784676d01d23356a7d44d6bd8bd50e94bfc723fa"
|
"02400123c5b61ba36edb1d3679904199a89ea80c09b9122e1400c09adcf7784676d01d23356a7d44d6bd8bd50e94bfc723fa"
|
||||||
|
|
@ -615,8 +615,8 @@ NAMESPACE_END
|
||||||
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
#ifdef CRYPTOPP_WIN32_AVAILABLE
|
||||||
|
|
||||||
// DllMain needs to be in the global namespace
|
// DllMain needs to be in the global namespace
|
||||||
BOOL APIENTRY DllMain(HANDLE hModule,
|
BOOL APIENTRY DllMain(HANDLE hModule,
|
||||||
DWORD dwReason,
|
DWORD dwReason,
|
||||||
LPVOID /*lpReserved*/)
|
LPVOID /*lpReserved*/)
|
||||||
{
|
{
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,6 @@ done
|
||||||
# Defaults if not set
|
# Defaults if not set
|
||||||
if [ -z "$APPLE_SDK" ]; then
|
if [ -z "$APPLE_SDK" ]; then
|
||||||
APPLE_SDK=iPhoneOS
|
APPLE_SDK=iPhoneOS
|
||||||
IOS_ARCH=armv7
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$IOS_ARCH" ]; then
|
if [ -z "$IOS_ARCH" ]; then
|
||||||
|
|
|
||||||
20
test.cpp
20
test.cpp
|
|
@ -299,7 +299,7 @@ int CRYPTOPP_API main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
if (fname.find(".txt") == std::string::npos)
|
if (fname.find(".txt") == std::string::npos)
|
||||||
fname = "TestVectors/" + fname + ".txt";
|
fname = "TestVectors/" + fname + ".txt";
|
||||||
|
|
||||||
PrintSeedAndThreads(seed);
|
PrintSeedAndThreads(seed);
|
||||||
return !RunTestDataFile(fname.c_str());
|
return !RunTestDataFile(fname.c_str());
|
||||||
}
|
}
|
||||||
|
|
@ -431,7 +431,7 @@ T StringToValue(const std::string& str) {
|
||||||
std::istringstream iss(str);
|
std::istringstream iss(str);
|
||||||
T value;
|
T value;
|
||||||
iss >> value;
|
iss >> value;
|
||||||
|
|
||||||
// Use fail(), not bad()
|
// Use fail(), not bad()
|
||||||
if (iss.fail())
|
if (iss.fail())
|
||||||
throw InvalidArgument("cryptest.exe: '" + str +"' is not a value");
|
throw InvalidArgument("cryptest.exe: '" + str +"' is not a value");
|
||||||
|
|
@ -441,7 +441,7 @@ T StringToValue(const std::string& str) {
|
||||||
throw InvalidArgument("cryptest.exe: '" + str +"' is negative");
|
throw InvalidArgument("cryptest.exe: '" + str +"' is negative");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
@ -449,11 +449,11 @@ int StringToValue<int, true>(const std::string& str)
|
||||||
{
|
{
|
||||||
Integer n(str.c_str());
|
Integer n(str.c_str());
|
||||||
long l = n.ConvertToLong();
|
long l = n.ConvertToLong();
|
||||||
|
|
||||||
int r;
|
int r;
|
||||||
if(!SafeConvert(l, r))
|
if(!SafeConvert(l, r))
|
||||||
throw InvalidArgument("cryptest.exe: '" + str +"' is not an integer value");
|
throw InvalidArgument("cryptest.exe: '" + str +"' is not an integer value");
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -754,8 +754,8 @@ void GzipFile(const char *in, const char *out, int deflate_level)
|
||||||
// \ Gunzip
|
// \ Gunzip
|
||||||
// \ |
|
// \ |
|
||||||
// \ v
|
// \ v
|
||||||
// > ComparisonFilter
|
// > ComparisonFilter
|
||||||
|
|
||||||
EqualityComparisonFilter comparison;
|
EqualityComparisonFilter comparison;
|
||||||
|
|
||||||
Gunzip gunzip(new ChannelSwitch(comparison, "0"));
|
Gunzip gunzip(new ChannelSwitch(comparison, "0"));
|
||||||
|
|
@ -815,12 +815,12 @@ void ForwardTcpPort(const char *sourcePortName, const char *destinationHost, con
|
||||||
|
|
||||||
sockListen.Create();
|
sockListen.Create();
|
||||||
sockListen.Bind(sourcePort);
|
sockListen.Bind(sourcePort);
|
||||||
|
|
||||||
int err = setsockopt(sockListen, IPPROTO_TCP, TCP_NODELAY, "\x01", 1);
|
int err = setsockopt(sockListen, IPPROTO_TCP, TCP_NODELAY, "\x01", 1);
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
if(err != 0)
|
if(err != 0)
|
||||||
throw Socket::Err(sockListen, "setsockopt", sockListen.GetLastError());
|
throw Socket::Err(sockListen, "setsockopt", sockListen.GetLastError());
|
||||||
|
|
||||||
cout << "Listing on port " << sourcePort << ".\n";
|
cout << "Listing on port " << sourcePort << ".\n";
|
||||||
sockListen.Listen();
|
sockListen.Listen();
|
||||||
|
|
||||||
|
|
@ -966,7 +966,7 @@ bool Validate(int alg, bool thorough, const char *seedInput)
|
||||||
tm localTime = {};
|
tm localTime = {};
|
||||||
char timeBuf[64];
|
char timeBuf[64];
|
||||||
errno_t err;
|
errno_t err;
|
||||||
|
|
||||||
const time_t endTime = time(NULL);
|
const time_t endTime = time(NULL);
|
||||||
err = localtime_s(&localTime, &endTime);
|
err = localtime_s(&localTime, &endTime);
|
||||||
assert(err == 0);
|
assert(err == 0);
|
||||||
|
|
|
||||||
|
|
@ -317,13 +317,14 @@ bool TestSettings()
|
||||||
|
|
||||||
#elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
|
#elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64)
|
||||||
bool hasNEON = HasNEON();
|
bool hasNEON = HasNEON();
|
||||||
|
bool hasPMULL = HasPMULL();
|
||||||
bool hasCRC32 = HasCRC32();
|
bool hasCRC32 = HasCRC32();
|
||||||
bool hasAES = HasAES();
|
bool hasAES = HasAES();
|
||||||
bool hasSHA1 = HasSHA1();
|
bool hasSHA1 = HasSHA1();
|
||||||
bool hasSHA2 = HasSHA2();
|
bool hasSHA2 = HasSHA2();
|
||||||
|
|
||||||
cout << "passed: ";
|
cout << "passed: ";
|
||||||
cout << "hasNEON == " << hasNEON << ", hasCRC32 == " << hasCRC32 << ", hasAES == " << hasAES << ", hasSHA1 == " << hasSHA1 << ", hasSHA2 == " << hasSHA2 << endl;
|
cout << "hasNEON == " << hasNEON << ", hasPMULL == " << hasPMULL << ", hasCRC32 == " << hasCRC32 << ", hasAES == " << hasAES << ", hasSHA1 == " << hasSHA1 << ", hasSHA2 == " << hasSHA2 << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!pass)
|
if (!pass)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue