5 #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 57 #if (CRYPTOPP_MSC_VERSION >= 1410) 58 # pragma strict_gs_check (on) 62 #if CRYPTOPP_MSC_VERSION 63 # pragma warning(disable: 4996) 66 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 67 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" 73 bool ValidateAll(
bool thorough)
75 bool pass=TestSettings();
76 pass=TestOS_RNG() && pass;
77 pass=TestAutoSeeded() && pass;
78 pass=TestAutoSeededX917() && pass;
80 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 81 pass=TestRDRAND() && pass;
82 pass=TestRDSEED() && pass;
85 #if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) 87 pass=TestSecBlock() && pass;
89 pass=TestPolynomialMod2() && pass;
91 pass=TestHuffmanCodes() && pass;
94 pass=ValidateCRC32() && pass;
95 pass=ValidateCRC32C() && pass;
96 pass=ValidateAdler32() && pass;
97 pass=ValidateMD2() && pass;
98 pass=ValidateMD5() && pass;
99 pass=ValidateSHA() && pass;
101 pass=RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/keccak.txt") && pass;
102 pass=RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/sha3_fips_202.txt") && pass;
104 pass=ValidateTiger() && pass;
105 pass=ValidateRIPEMD() && pass;
106 pass=ValidatePanama() && pass;
107 pass=ValidateWhirlpool() && pass;
108 pass=ValidateBLAKE2s() && pass;
109 pass=ValidateBLAKE2b() && pass;
111 pass=ValidateHMAC() && pass;
112 pass=ValidateTTMAC() && pass;
114 pass=ValidatePBKDF() && pass;
115 pass=ValidateHKDF() && pass;
117 pass=ValidateDES() && pass;
118 pass=ValidateCipherModes() && pass;
119 pass=ValidateIDEA() && pass;
120 pass=ValidateSAFER() && pass;
121 pass=ValidateRC2() && pass;
122 pass=ValidateARC4() && pass;
123 pass=ValidateRC5() && pass;
124 pass=ValidateBlowfish() && pass;
125 pass=ValidateThreeWay() && pass;
126 pass=ValidateGOST() && pass;
127 pass=ValidateSHARK() && pass;
128 pass=ValidateCAST() && pass;
129 pass=ValidateSquare() && pass;
130 pass=ValidateSKIPJACK() && pass;
131 pass=ValidateSEAL() && pass;
132 pass=ValidateRC6() && pass;
133 pass=ValidateMARS() && pass;
134 pass=ValidateRijndael() && pass;
135 pass=ValidateTwofish() && pass;
136 pass=ValidateSerpent() && pass;
137 pass=ValidateSHACAL2() && pass;
138 pass=ValidateCamellia() && pass;
139 pass=ValidateSalsa() && pass;
140 pass=ValidateSosemanuk() && pass;
141 pass=ValidateVMAC() && pass;
142 pass=ValidateCCM() && pass;
143 pass=ValidateGCM() && pass;
144 pass=ValidateCMAC() && pass;
145 pass=RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/eax.txt") && pass;
146 pass=RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/seed.txt") && pass;
148 pass=ValidateBBS() && pass;
149 pass=ValidateDH() && pass;
150 pass=ValidateMQV() && pass;
151 pass=ValidateHMQV() && pass;
152 pass=ValidateFHMQV() && pass;
153 pass=ValidateRSA() && pass;
154 pass=ValidateElGamal() && pass;
155 pass=ValidateDLIES() && pass;
156 pass=ValidateNR() && pass;
157 pass=ValidateDSA(thorough) && pass;
158 pass=ValidateLUC() && pass;
159 pass=ValidateLUC_DH() && pass;
160 pass=ValidateLUC_DL() && pass;
161 pass=ValidateXTR_DH() && pass;
162 pass=ValidateRabin() && pass;
163 pass=ValidateRW() && pass;
165 pass=ValidateECP() && pass;
166 pass=ValidateEC2N() && pass;
167 pass=ValidateECDSA() && pass;
168 pass=ValidateESIGN() && pass;
171 cout <<
"\nAll tests passed!\n";
173 cout <<
"\nOops! Not all tests passed.\n";
181 #if defined(__MINGW32__) 187 cout <<
"\nTesting Settings...\n\n";
190 memcpy_s(&w,
sizeof(w),
"\x01\x02\x03\x04", 4);
192 if (w == 0x04030201L)
194 #ifdef IS_LITTLE_ENDIAN 200 cout <<
"Your machine is little endian.\n";
202 else if (w == 0x01020304L)
204 #ifndef IS_LITTLE_ENDIAN 210 cout <<
"Your machine is big endian.\n";
214 cout <<
"FAILED: Your machine is neither big endian nor little endian.\n";
218 #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS 220 byte testvals[10] = {1,2,2,3,3,3,3,2,2,1};
221 if (*(word32 *)(
void *)(testvals+3) == 0x03030303 && *(word64 *)(
void *)(testvals+1) == W64LIT(0x0202030303030202))
222 cout <<
"passed: Your machine allows unaligned data access.\n";
225 cout <<
"FAILED: Unaligned data access gave incorrect results.\n";
229 cout <<
"passed: CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS is not defined. Will restrict to aligned data access.\n";
232 if (
sizeof(byte) == 1)
239 cout <<
"sizeof(byte) == " <<
sizeof(byte) << endl;
241 if (
sizeof(word16) == 2)
248 cout <<
"sizeof(word16) == " <<
sizeof(word16) << endl;
250 if (
sizeof(word32) == 4)
257 cout <<
"sizeof(word32) == " <<
sizeof(word32) << endl;
259 if (
sizeof(word64) == 8)
266 cout <<
"sizeof(word64) == " <<
sizeof(word64) << endl;
268 #ifdef CRYPTOPP_WORD128_AVAILABLE 269 if (
sizeof(word128) == 16)
276 cout <<
"sizeof(word128) == " <<
sizeof(word128) << endl;
279 if (
sizeof(word) == 2*
sizeof(hword)
280 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE
281 &&
sizeof(dword) == 2*
sizeof(word)
290 cout <<
"sizeof(hword) == " <<
sizeof(hword) <<
", sizeof(word) == " <<
sizeof(word);
291 #ifdef CRYPTOPP_NATIVE_DWORD_AVAILABLE 292 cout <<
", sizeof(dword) == " <<
sizeof(dword);
296 #ifdef CRYPTOPP_CPUID_AVAILABLE 305 if ((isP4 && (!hasMMX || !hasSSE2)) || (hasSSE2 && !hasMMX) || (cacheLineSize < 16 || cacheLineSize > 256 || !
IsPowerOf2(cacheLineSize)))
313 cout <<
"hasMMX == " << hasMMX <<
", hasISSE == " << hasISSE <<
", hasSSE2 == " << hasSSE2 <<
", hasSSSE3 == " << hasSSSE3 <<
", hasSSE4 == " << hasSSE4;
315 cout <<
", isP4 == " << isP4 <<
", cacheLineSize == " << cacheLineSize <<
", AESNI_INTRINSICS == " << CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE << endl;
317 #elif (CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARM64) 318 bool hasNEON = HasNEON();
319 bool hasPMULL = HasPMULL();
320 bool hasCRC32 = HasCRC32();
321 bool hasAES = HasAES();
322 bool hasSHA1 = HasSHA1();
323 bool hasSHA2 = HasSHA2();
326 cout <<
"hasNEON == " << hasNEON <<
", hasPMULL == " << hasPMULL <<
", hasCRC32 == " << hasCRC32 <<
", hasAES == " << hasAES <<
", hasSHA1 == " << hasSHA1 <<
", hasSHA2 == " << hasSHA2 << endl;
331 cout <<
"Some critical setting in config.h is in error. Please fix it and recompile." << endl;
337 #if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) 340 cout <<
"\nTesting SecBlock...\n\n";
342 bool pass1=
true, pass2=
true, pass3=
true, pass4=
true, pass5=
true, pass6=
true, pass7=
true, temp=
false;
351 for (
size_t i = 0; i < z1.size(); i++)
352 temp &= (z1[i] == 0);
359 cout <<
" Zeroized byte array" << endl;
364 for (
size_t i = 0; i < z2.size(); i++)
365 temp &= (z2[i] == 0);
372 cout <<
" Zeroized word32 array" << endl;
377 for (
size_t i = 0; i < z3.size(); i++)
378 temp &= (z3[i] == 0);
385 cout <<
" Zeroized word64 array" << endl;
387 #if defined(CRYPTOPP_WORD128_AVAILABLE) 391 for (
size_t i = 0; i < z4.size(); i++)
392 temp &= (z4[i] == 0);
399 cout <<
" Zeroized word128 array" << endl;
410 a.
Assign((
const byte*)
"a", 1);
411 b.
Assign((
const byte*)
"b", 1);
415 temp &= (a[0] ==
'a');
416 temp &= (b[0] ==
'b');
418 a.
Assign((
const byte*)
"ab", 2);
419 b.
Assign((
const byte*)
"cd", 2);
423 temp &= (a[0] ==
'a' && a[1] ==
'b');
424 temp &= (b[0] ==
'c' && b[1] ==
'd');
436 cout <<
" Assign byte" << endl;
443 word32 one[1] = {1}, two[1] = {2};
452 word32 three[2] = {1,2}, four[2] = {3,4};
458 temp &= (a[0] == 1 && a[1] == 2);
459 temp &= (b[0] == 3 && b[1] == 4);
471 cout <<
" Assign word32" << endl;
478 word64 one[1] = {1}, two[1] = {2};
487 word64 three[2] = {1,2}, four[2] = {3,4};
493 temp &= (a[0] == 1 && a[1] == 2);
494 temp &= (b[0] == 3 && b[1] == 4);
506 cout <<
" Assign word64" << endl;
508 #if defined(CRYPTOPP_WORD128_AVAILABLE) 514 word128 one[1] = {1}, two[1] = {2};
523 word128 three[2] = {1,2}, four[2] = {3,4};
529 temp &= (a[0] == 1 && a[1] == 2);
530 temp &= (b[0] == 3 && b[1] == 4);
542 cout <<
" Assign word128" << endl;
552 a.
Assign((
const byte*)
"a", 1);
553 b.
Assign((
const byte*)
"b", 1);
557 temp &= (a[0] ==
'a' && a[1] ==
'b');
559 a.
Assign((
const byte*)
"ab", 2);
560 b.
Assign((
const byte*)
"cd", 2);
564 temp &= (a[0] ==
'a' && a[1] ==
'b' && a[2] ==
'c' && a[3] ==
'd');
566 a.
Assign((
const byte*)
"a", 1);
570 temp &= (a[0] ==
'a' && a[1] ==
'a');
572 a.
Assign((
const byte*)
"ab", 2);
576 temp &= (a[0] ==
'a' && a[1] ==
'b' && a[2] ==
'a' && a[3] ==
'b');
588 cout <<
" Append byte" << endl;
595 const word32 one[1] = {1}, two[1] = {2};
601 temp &= (a[0] == 1 && a[1] == 2);
603 const word32 three[2] = {1,2}, four[2] = {3,4};
609 temp &= (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4);
615 temp &= (a[0] == 1 && a[1] == 1);
621 temp &= (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 2);
633 cout <<
" Append word32" << endl;
640 const word64 one[1] = {1}, two[1] = {2};
646 temp &= (a[0] == 1 && a[1] == 2);
648 const word64 three[2] = {1,2}, four[2] = {3,4};
654 temp &= (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4);
660 temp &= (a[0] == 1 && a[1] == 1);
666 temp &= (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 2);
678 cout <<
" Append word64" << endl;
680 #if defined(CRYPTOPP_WORD128_AVAILABLE) 686 const word128 one[1] = {1}, two[1] = {2};
692 temp &= (a[0] == 1 && a[1] == 2);
694 const word128 three[2] = {1,2}, four[2] = {3,4};
700 temp &= (a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4);
706 temp &= (a[0] == 1 && a[1] == 1);
712 temp &= (a[0] == 1 && a[1] == 2 && a[2] == 1 && a[3] == 2);
724 cout <<
" Append word128" << endl;
735 a.
Assign((
const byte*)
"a", 1);
736 b.
Assign((
const byte*)
"b", 1);
739 temp &= (a[0] ==
'a');
740 temp &= (b[0] ==
'b');
742 temp &= (c[0] ==
'a' && c[1] ==
'b');
744 a.
Assign((
const byte*)
"ab", 2);
745 b.Assign((
const byte*)
"cd", 2);
748 temp &= (a[0] ==
'a' && a[1] ==
'b');
749 temp &= (b[0] ==
'c' && b[1] ==
'd');
751 temp &= (c[0] ==
'a' && c[1] ==
'b' && c[2] ==
'c' && c[3] ==
'd');
763 cout <<
" Concatenate byte" << endl;
771 const word32 one[1] = {1}, two[1] = {2};
779 temp &= (c[0] == 1 && c[1] == 2);
781 const word32 three[2] = {1,2}, four[2] = {3,4};
786 temp &= (a[0] == 1 && a[1] == 2);
787 temp &= (b[0] == 3 && b[1] == 4);
789 temp &= (c[0] == 1 && c[1] == 2 && c[2] == 3 && c[3] == 4);
801 cout <<
" Concatenate word32" << endl;
809 const word64 one[1] = {1}, two[1] = {2};
817 temp &= (c[0] == 1 && c[1] == 2);
819 const word64 three[2] = {1,2}, four[2] = {3,4};
824 temp &= (a[0] == 1 && a[1] == 2);
825 temp &= (b[0] == 3 && b[1] == 4);
827 temp &= (c[0] == 1 && c[1] == 2 && c[2] == 3 && c[3] == 4);
839 cout <<
" Concatenate word64" << endl;
841 #if defined(CRYPTOPP_WORD128_AVAILABLE) 847 const word128 one[1] = {1}, two[1] = {2};
855 temp &= (c[0] == 1 && c[1] == 2);
857 const word128 three[2] = {1,2}, four[2] = {3,4};
862 temp &= (a[0] == 1 && a[1] == 2);
863 temp &= (b[0] == 3 && b[1] == 4);
865 temp &= (c[0] == 1 && c[1] == 2 && c[2] == 3 && c[3] == 4);
877 cout <<
" Concatenate word128" << endl;
885 static const byte str1[] =
"abcdefghijklmnopqrstuvwxyz";
886 static const byte str2[] =
"zyxwvutsrqponmlkjihgfedcba";
887 static const byte str3[] =
"0123456789";
894 temp &= (a.operator==(b));
902 temp &= (a.operator!=(b));
918 cout <<
" Equality byte" << endl;
923 static const word32 str1[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
924 static const word32 str2[] = {97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2};
925 static const word32 str3[] = {0,1,2,3,4,5,6,7,8,9};
932 temp &= (a.operator==(b));
940 temp &= (a.operator!=(b));
956 cout <<
" Equality word32" << endl;
961 static const word64 str1[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
962 static const word64 str2[] = {97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2};
963 static const word64 str3[] = {0,1,2,3,4,5,6,7,8,9};
970 temp &= (a.operator==(b));
978 temp &= (a.operator!=(b));
994 cout <<
" Equality word64" << endl;
996 #if defined(CRYPTOPP_WORD128_AVAILABLE) 1000 static const word128 str1[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
1001 static const word128 str2[] = {97,89,83,79,73,71,67,61,59,53,47,43,41,37,31,29,23,19,17,13,11,7,5,3,2};
1002 static const word128 str3[] = {0,1,2,3,4,5,6,7,8,9};
1009 temp &= (a.operator==(b));
1017 temp &= (a.operator!=(b));
1033 cout <<
" Equality word128" << endl;
1050 catch(
const std::exception& )
1060 cout <<
" Overflow word32" << endl;
1074 catch(
const std::exception& )
1084 cout <<
" Overflow word64" << endl;
1086 #if defined(CRYPTOPP_WORD128_AVAILABLE) 1099 catch(
const std::exception& )
1109 cout <<
" Overflow word128" << endl;
1117 static const unsigned int SIZE = 8;
1119 memset(block, 0xaa, block.SizeInBytes());
1122 block.CleanGrow(SIZE*2);
1123 temp &= (block.size() == SIZE*2);
1125 for (
size_t i = 0; i < block.size()/2; i++)
1126 temp &= (block[i] == 0xaa);
1127 for (
size_t i = block.size()/2; i < block.size(); i++)
1128 temp &= (block[i] == 0);
1130 block.CleanNew(SIZE*4);
1131 temp &= (block.size() == SIZE*4);
1132 for (
size_t i = 0; i < block.size(); i++)
1133 temp &= (block[i] == 0);
1139 catch(
const std::exception& )
1149 cout <<
" FixedSizeAllocator Grow with byte" << endl;
1154 static const unsigned int SIZE = 8;
1156 memset(block, 0xaa, block.SizeInBytes());
1159 block.CleanGrow(SIZE*2);
1160 temp &= (block.size() == SIZE*2);
1162 for (
size_t i = 0; i < block.size()/2; i++)
1163 temp &= (block[i] == 0xaaaaaaaa);
1165 for (
size_t i = block.size()/2; i < block.size(); i++)
1166 temp &= (block[i] == 0);
1168 block.CleanNew(SIZE*4);
1169 temp &= (block.size() == SIZE*4);
1170 for (
size_t i = 0; i < block.size(); i++)
1171 temp &= (block[i] == 0);
1177 catch(
const std::exception& )
1187 cout <<
" FixedSizeAllocator Grow with word32" << endl;
1192 static const unsigned int SIZE = 8;
1194 memset(block, 0xaa, block.SizeInBytes());
1197 block.CleanGrow(SIZE*2);
1198 temp &= (block.size() == SIZE*2);
1200 for (
size_t i = 0; i < block.size()/2; i++)
1201 temp &= (block[i] == W64LIT(0xaaaaaaaaaaaaaaaa));
1203 for (
size_t i = block.size()/2; i < block.size(); i++)
1204 temp &= (block[i] == 0);
1206 block.CleanNew(SIZE*4);
1207 temp &= (block.size() == SIZE*4);
1208 for (
size_t i = 0; i < block.size(); i++)
1209 temp &= (block[i] == 0);
1215 catch(
const std::exception& )
1225 cout <<
" FixedSizeAllocator Grow with word64" << endl;
1227 #if defined(CRYPTOPP_WORD128_AVAILABLE) 1231 static const unsigned int SIZE = 8;
1233 memset(block, 0xaa, block.SizeInBytes());
1236 block.CleanGrow(SIZE*2);
1237 temp &= (block.size() == SIZE*2);
1239 for (
size_t i = 0; i < block.size()/2; i++)
1240 temp &= (block[i] == (((word128)W64LIT(0xaaaaaaaaaaaaaaaa) << 64U) | W64LIT(0xaaaaaaaaaaaaaaaa)));
1242 for (
size_t i = block.size()/2; i < block.size(); i++)
1243 temp &= (block[i] == 0);
1245 block.CleanNew(SIZE*4);
1246 temp &= (block.size() == SIZE*4);
1247 for (
size_t i = 0; i < block.size(); i++)
1248 temp &= (block[i] == 0);
1254 catch(
const std::exception& )
1264 cout <<
" FixedSizeAllocator Grow with word128" << endl;
1267 return pass1 && pass2 && pass3 && pass4 && pass5 && pass6 && pass7;
1271 #if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) 1272 bool TestHuffmanCodes()
1274 cout <<
"\nTesting Huffman codes...\n\n";
1277 static const size_t nCodes = 30;
1278 const unsigned int codeCounts[nCodes] = {
1279 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1280 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1283 static const unsigned int maxCodeBits = nCodes >> 1;
1284 unsigned int codeBits[nCodes] = {
1285 ~0u, ~0u, ~0u, ~0u, ~0u,
1286 ~0u, ~0u, ~0u, ~0u, ~0u,
1287 ~0u, ~0u, ~0u, ~0u, ~0u,
1292 HuffmanEncoder::GenerateCodeLengths(codeBits, maxCodeBits, codeCounts, nCodes);
1303 cout <<
" GenerateCodeLengths" << endl;
1315 #ifdef BLOCKING_RNG_AVAILABLE 1322 cout <<
"\nTesting operating system provided blocking random number generator...\n\n";
1326 unsigned long total=0, length=0;
1327 time_t t = time(NULL), t1 = 0;
1328 CRYPTOPP_UNUSED(length);
1331 while (total < 16 && (t1 < 10 || total*8 > (
unsigned long)t1))
1335 t1 = time(NULL) - t;
1345 cout <<
" it took " << long(t1) <<
" seconds to generate " << total <<
" bytes" << endl;
1347 #if 0 // disable this part. it's causing an unpredictable pause during the validation testing 1353 while (time(NULL) - t < 2)
1362 while (time(NULL) - t < 2)
1375 cout <<
" it generated " << length <<
" bytes in " << long(time(NULL) - t) <<
" seconds" << endl;
1379 test.AttachedTransformation()->MessageEnd();
1381 if (meter.GetTotalBytes() < total)
1388 cout <<
" " << total <<
" generated bytes compressed to " << meter.GetTotalBytes() <<
" bytes by DEFLATE" << endl;
1391 cout <<
"\nNo operating system provided blocking random number generator, skipping test." << endl;
1394 #ifdef NONBLOCKING_RNG_AVAILABLE 1401 cout <<
"\nTesting operating system provided nonblocking random number generator...\n\n";
1406 if (meter.GetTotalBytes() < 100000)
1413 cout <<
" 100000 generated bytes compressed to " << meter.GetTotalBytes() <<
" bytes by DEFLATE" << endl;
1416 cout <<
"\nNo operating system provided nonblocking random number generator, skipping test." << endl;
1421 #if defined(NO_OS_DEPENDENCE) || !defined(OS_RNG_AVAILABLE) 1422 bool TestAutoSeeded()
1426 bool TestAutoSeededX917()
1431 bool TestAutoSeeded()
1434 cout <<
"\nTesting AutoSeeded generator...\n\n";
1437 static const unsigned int ENTROPY_SIZE = 32;
1438 bool generate =
true, discard =
true, incorporate =
false;
1443 if (meter.GetTotalBytes() < 100000)
1450 cout <<
" 100000 generated bytes compressed to " << meter.GetTotalBytes() <<
" bytes by DEFLATE" << endl;
1465 cout <<
" discarded 10000 bytes" << endl;
1490 cout <<
" IncorporateEntropy with " << 4*ENTROPY_SIZE <<
" bytes" << endl;
1492 return generate && discard && incorporate;
1495 bool TestAutoSeededX917()
1498 cout <<
"\nTesting AutoSeeded X917 generator...\n\n";
1501 static const unsigned int ENTROPY_SIZE = 32;
1502 bool generate =
true, discard =
true, incorporate =
false;
1507 if (meter.GetTotalBytes() < 100000)
1514 cout <<
" 100000 generated bytes compressed to " << meter.GetTotalBytes() <<
" bytes by DEFLATE" << endl;
1529 cout <<
" discarded 10000 bytes" << endl;
1554 cout <<
" IncorporateEntropy with " << 4*ENTROPY_SIZE <<
" bytes" << endl;
1556 return generate && discard && incorporate;
1558 #endif // NO_OS_DEPENDENCE 1560 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 1565 bool entropy =
true, compress =
true, discard =
true;
1566 static const unsigned int SIZE = 10000;
1570 cout <<
"\nTesting RDRAND generator...\n\n";
1577 chsw.AddDefaultRoute(deflator);
1578 chsw.AddDefaultRoute(maurer);
1581 deflator.Flush(
true);
1584 const double mv = maurer.GetTestValue();
1595 cout << std::setiosflags(std::ios::fixed) << std::setprecision(6);
1596 cout <<
" Maurer Randomness Test returned value " << mv << endl;
1598 if (meter.GetTotalBytes() < SIZE)
1605 cout <<
" " << SIZE <<
" generated bytes compressed to " << meter.GetTotalBytes() <<
" bytes by DEFLATE\n";
1620 cout <<
" discarded " << SIZE <<
" bytes\n";
1623 cout <<
"\nRDRAND generator not available, skipping test.\n";
1631 if (!(entropy && compress && discard))
1634 return entropy && compress && discard;
1638 #if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64) 1644 bool entropy =
true, compress =
true, discard =
true;
1645 static const unsigned int SIZE = 10000;
1649 cout <<
"\nTesting RDSEED generator...\n\n";
1656 chsw.AddDefaultRoute(deflator);
1657 chsw.AddDefaultRoute(maurer);
1660 deflator.Flush(
true);
1663 const double mv = maurer.GetTestValue();
1674 cout << std::setiosflags(std::ios::fixed) << std::setprecision(6);
1675 cout <<
" Maurer Randomness Test returned value " << mv << endl;
1677 if (meter.GetTotalBytes() < SIZE)
1684 cout <<
" " << SIZE <<
" generated bytes compressed to " << meter.GetTotalBytes() <<
" bytes by DEFLATE\n";
1688 rdseed.DiscardBytes(SIZE);
1699 cout <<
" discarded " << SIZE <<
" bytes\n";
1702 cout <<
"\nRDSEED generator not available, skipping test.\n";
1705 (
void)rdseed.AlgorithmName();
1706 (
void)rdseed.CanIncorporateEntropy();
1707 rdseed.SetRetries(rdseed.GetRetries());
1708 rdseed.IncorporateEntropy(NULL, 0);
1710 if (!(entropy && compress && discard))
1713 return entropy && compress && discard;
1718 typedef auto_ptr<BlockTransformation> apbt;
1723 virtual unsigned int BlockSize()
const =0;
1724 virtual unsigned int KeyLength()
const =0;
1726 virtual apbt NewEncryption(
const byte *keyStr)
const =0;
1727 virtual apbt NewDecryption(
const byte *keyStr)
const =0;
1734 unsigned int BlockSize()
const {
return E::BLOCKSIZE;}
1735 unsigned int KeyLength()
const {
return m_keylen;}
1737 apbt NewEncryption(
const byte *keyStr)
const 1738 {
return apbt(
new E(keyStr, m_keylen));}
1739 apbt NewDecryption(
const byte *keyStr)
const 1740 {
return apbt(
new D(keyStr, m_keylen));}
1742 unsigned int m_keylen;
1749 : m_keylen(keylen ? keylen : E::DEFAULT_KEYLENGTH), m_rounds(rounds ? rounds : E::DEFAULT_ROUNDS) {}
1750 unsigned int BlockSize()
const {
return E::BLOCKSIZE;}
1751 unsigned int KeyLength()
const {
return m_keylen;}
1753 apbt NewEncryption(
const byte *keyStr)
const 1754 {
return apbt(
new E(keyStr, m_keylen, m_rounds));}
1755 apbt NewDecryption(
const byte *keyStr)
const 1756 {
return apbt(
new D(keyStr, m_keylen, m_rounds));}
1758 unsigned int m_keylen, m_rounds;
1764 SecByteBlock plain(cg.BlockSize()), cipher(cg.BlockSize()), out(cg.BlockSize()), outplain(cg.BlockSize());
1766 bool pass=
true, fail;
1770 valdata.
Get(key, cg.KeyLength());
1771 valdata.
Get(plain, cg.BlockSize());
1772 valdata.
Get(cipher, cg.BlockSize());
1774 apbt transE = cg.NewEncryption(key);
1775 transE->ProcessBlock(plain, out);
1776 fail = memcmp(out, cipher, cg.BlockSize()) != 0;
1778 apbt transD = cg.NewDecryption(key);
1779 transD->ProcessBlock(out, outplain);
1780 fail=fail || memcmp(outplain, plain, cg.BlockSize());
1782 pass = pass && !fail;
1784 cout << (fail ?
"FAILED " :
"passed ");
1785 output.
Put(key, cg.KeyLength());
1787 output.
Put(outplain, cg.BlockSize());
1789 output.
Put(out, cg.BlockSize());
1798 FilterTester(
const byte *validOutput,
size_t outputLen)
1799 : validOutput(validOutput), outputLen(outputLen), counter(0), fail(
false) {}
1800 void PutByte(byte inByte)
1802 if (counter >= outputLen || validOutput[counter] != inByte)
1804 std::cerr <<
"incorrect output " << counter <<
", " << (word16)validOutput[counter] <<
", " << (word16)inByte <<
"\n";
1810 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
1812 CRYPTOPP_UNUSED(messageEnd), CRYPTOPP_UNUSED(blocking);
1815 FilterTester::PutByte(*inString++);
1818 if (counter != outputLen)
1831 const byte *validOutput;
1832 size_t outputLen, counter;
1836 bool TestFilter(
BufferedTransformation &bt,
const byte *in,
size_t inLen,
const byte *out,
size_t outLen)
1844 bt.
Put(in, randomLen);
1849 return ft->GetResult();
1854 cout <<
"\nDES validation suite running...\n\n";
1859 cout <<
"\nTesting EDE2, EDE3, and XEX3 variants...\n\n";
1877 for (
unsigned int i=1; i<20480; i*=2)
1891 if (!TestFilter(filter, plaintext, length, plaintext, length))
1898 bool ValidateCipherModes()
1900 cout <<
"\nTesting DES modes...\n\n";
1901 const byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
1902 const byte iv[] = {0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
1903 const byte plain[] = {
1904 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,
1905 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,
1906 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20};
1909 bool pass=
true, fail;
1913 const byte encrypted[] = {
1914 0x3f, 0xa4, 0x0e, 0x8a, 0x98, 0x4d, 0x48, 0x15,
1915 0x6a, 0x27, 0x17, 0x87, 0xab, 0x88, 0x83, 0xf9,
1916 0x89, 0x3d, 0x51, 0xec, 0x4b, 0x56, 0x3b, 0x53};
1920 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
1921 pass = pass && !fail;
1922 cout << (fail ?
"FAILED " :
"passed ") <<
"ECB encryption" << endl;
1926 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
1927 pass = pass && !fail;
1928 cout << (fail ?
"FAILED " :
"passed ") <<
"ECB decryption" << endl;
1932 const byte encrypted[] = {
1933 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C,
1934 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F,
1935 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6};
1939 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
1940 pass = pass && !fail;
1941 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC encryption with no padding" << endl;
1945 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
1946 pass = pass && !fail;
1947 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC decryption with no padding" << endl;
1949 fail = !TestModeIV(modeE, modeD);
1950 pass = pass && !fail;
1951 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC mode IV generation" << endl;
1956 const byte encrypted[] = {
1957 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C,
1958 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F,
1959 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6,
1960 0x62, 0xC1, 0x6A, 0x27, 0xE4, 0xFC, 0xF2, 0x77};
1964 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
1965 pass = pass && !fail;
1966 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC encryption with PKCS #7 padding" << endl;
1970 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
1971 pass = pass && !fail;
1972 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC decryption with PKCS #7 padding" << endl;
1977 const byte encrypted[] = {
1978 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C,
1979 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F,
1980 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6,
1981 0xcf, 0xb7, 0xc7, 0x64, 0x0e, 0x7c, 0xd9, 0xa7};
1985 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
1986 pass = pass && !fail;
1987 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC encryption with one-and-zeros padding" << endl;
1991 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
1992 pass = pass && !fail;
1993 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC decryption with one-and-zeros padding" << endl;
1996 const byte plain_1[] = {
'a', 0, 0, 0, 0, 0, 0, 0};
1998 const byte encrypted[] = {
1999 0x9B, 0x47, 0x57, 0x59, 0xD6, 0x9C, 0xF6, 0xD0};
2003 plain_1, 1, encrypted,
sizeof(encrypted));
2004 pass = pass && !fail;
2005 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC encryption with zeros padding" << endl;
2009 encrypted,
sizeof(encrypted), plain_1,
sizeof(plain_1));
2010 pass = pass && !fail;
2011 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC decryption with zeros padding" << endl;
2016 const byte encrypted[] = {
2017 0xE5, 0xC7, 0xCD, 0xDE, 0x87, 0x2B, 0xF2, 0x7C,
2018 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6,
2019 0x43, 0xE9, 0x34, 0x00, 0x8C, 0x38, 0x9C, 0x0F};
2023 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
2024 pass = pass && !fail;
2025 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC encryption with ciphertext stealing (CTS)" << endl;
2029 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
2030 pass = pass && !fail;
2031 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC decryption with ciphertext stealing (CTS)" << endl;
2033 fail = !TestModeIV(modeE, modeD);
2034 pass = pass && !fail;
2035 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC CTS IV generation" << endl;
2039 const byte decryptionIV[] = {0x4D, 0xD0, 0xAC, 0x8F, 0x47, 0xCF, 0x79, 0xCE};
2040 const byte encrypted[] = {0x12, 0x34, 0x56};
2045 modeE.SetStolenIV(stolenIV);
2047 plain, 3, encrypted,
sizeof(encrypted));
2048 fail = memcmp(stolenIV, decryptionIV, 8) != 0 || fail;
2049 pass = pass && !fail;
2050 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC encryption with ciphertext and IV stealing" << endl;
2054 encrypted,
sizeof(encrypted), plain, 3);
2055 pass = pass && !fail;
2056 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC decryption with ciphertext and IV stealing" << endl;
2059 const byte encrypted[] = {
2060 0xF3,0x09,0x62,0x49,0xC7,0xF4,0x6E,0x51,
2061 0xA6,0x9E,0x83,0x9B,0x1A,0x92,0xF7,0x84,
2062 0x03,0x46,0x71,0x33,0x89,0x8E,0xA6,0x22};
2066 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
2067 pass = pass && !fail;
2068 cout << (fail ?
"FAILED " :
"passed ") <<
"CFB encryption" << endl;
2072 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
2073 pass = pass && !fail;
2074 cout << (fail ?
"FAILED " :
"passed ") <<
"CFB decryption" << endl;
2076 fail = !TestModeIV(modeE, modeD);
2077 pass = pass && !fail;
2078 cout << (fail ?
"FAILED " :
"passed ") <<
"CFB mode IV generation" << endl;
2081 const byte plain_2[] = {
2082 0x4e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,0x68,0x65};
2083 const byte encrypted[] = {
2084 0xf3,0x1f,0xda,0x07,0x01,0x14,0x62,0xee,0x18,0x7f};
2088 plain_2,
sizeof(plain_2), encrypted,
sizeof(encrypted));
2089 pass = pass && !fail;
2090 cout << (fail ?
"FAILED " :
"passed ") <<
"CFB (8-bit feedback) encryption" << endl;
2094 encrypted,
sizeof(encrypted), plain_2,
sizeof(plain_2));
2095 pass = pass && !fail;
2096 cout << (fail ?
"FAILED " :
"passed ") <<
"CFB (8-bit feedback) decryption" << endl;
2098 fail = !TestModeIV(modeE, modeD);
2099 pass = pass && !fail;
2100 cout << (fail ?
"FAILED " :
"passed ") <<
"CFB (8-bit feedback) IV generation" << endl;
2103 const byte encrypted[] = {
2104 0xf3,0x09,0x62,0x49,0xc7,0xf4,0x6e,0x51,
2105 0x35,0xf2,0x4a,0x24,0x2e,0xeb,0x3d,0x3f,
2106 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3};
2110 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
2111 pass = pass && !fail;
2112 cout << (fail ?
"FAILED " :
"passed ") <<
"OFB encryption" << endl;
2116 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
2117 pass = pass && !fail;
2118 cout << (fail ?
"FAILED " :
"passed ") <<
"OFB decryption" << endl;
2120 fail = !TestModeIV(modeE, modeD);
2121 pass = pass && !fail;
2122 cout << (fail ?
"FAILED " :
"passed ") <<
"OFB IV generation" << endl;
2125 const byte encrypted[] = {
2126 0xF3, 0x09, 0x62, 0x49, 0xC7, 0xF4, 0x6E, 0x51,
2127 0x16, 0x3A, 0x8C, 0xA0, 0xFF, 0xC9, 0x4C, 0x27,
2128 0xFA, 0x2F, 0x80, 0xF4, 0x80, 0xB8, 0x6F, 0x75};
2132 plain,
sizeof(plain), encrypted,
sizeof(encrypted));
2133 pass = pass && !fail;
2134 cout << (fail ?
"FAILED " :
"passed ") <<
"Counter Mode encryption" << endl;
2138 encrypted,
sizeof(encrypted), plain,
sizeof(plain));
2139 pass = pass && !fail;
2140 cout << (fail ?
"FAILED " :
"passed ") <<
"Counter Mode decryption" << endl;
2142 fail = !TestModeIV(modeE, modeD);
2143 pass = pass && !fail;
2144 cout << (fail ?
"FAILED " :
"passed ") <<
"Counter Mode IV generation" << endl;
2147 const byte plain_3[] = {
2148 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x20,
2149 0x4e, 0x6f, 0x77, 0x20, 0x69, 0x73, 0x20, 0x74,
2150 0x68, 0x65, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20,
2151 0x66, 0x6f, 0x72, 0x20};
2152 const byte mac1[] = {
2153 0xf1, 0xd3, 0x0f, 0x68, 0x49, 0x31, 0x2c, 0xa4};
2154 const byte mac2[] = {
2155 0x35, 0x80, 0xC5, 0xC4, 0x6B, 0x81, 0x24, 0xE2};
2159 fail = !TestFilter(cbcmacFilter, plain_3,
sizeof(plain_3), mac1,
sizeof(mac1));
2160 pass = pass && !fail;
2161 cout << (fail ?
"FAILED " :
"passed ") <<
"CBC MAC" << endl;
2165 fail = !TestFilter(dmacFilter, plain_3,
sizeof(plain_3), mac2,
sizeof(mac2));
2166 pass = pass && !fail;
2167 cout << (fail ?
"FAILED " :
"passed ") <<
"DMAC" << endl;
2172 fail = !TestModeIV(modeE, modeD);
2173 pass = pass && !fail;
2174 cout << (fail ?
"FAILED " :
"passed ") <<
"AES CTR Mode" << endl;
2179 fail = !TestModeIV(modeE, modeD);
2180 pass = pass && !fail;
2181 cout << (fail ?
"FAILED " :
"passed ") <<
"AES OFB Mode" << endl;
2186 fail = !TestModeIV(modeE, modeD);
2187 pass = pass && !fail;
2188 cout << (fail ?
"FAILED " :
"passed ") <<
"AES CFB Mode" << endl;
2193 fail = !TestModeIV(modeE, modeD);
2194 pass = pass && !fail;
2195 cout << (fail ?
"FAILED " :
"passed ") <<
"AES CBC Mode" << endl;
2203 cout <<
"\nIDEA validation suite running...\n\n";
2209 bool ValidateSAFER()
2211 cout <<
"\nSAFER validation suite running...\n\n";
2224 cout <<
"\nRC2 validation suite running...\n\n";
2228 SecByteBlock plain(RC2Encryption::BLOCKSIZE), cipher(RC2Encryption::BLOCKSIZE), out(RC2Encryption::BLOCKSIZE), outplain(RC2Encryption::BLOCKSIZE);
2230 bool pass=
true, fail;
2234 byte keyLen, effectiveLen;
2236 valdata.
Get(keyLen);
2237 valdata.
Get(effectiveLen);
2238 valdata.
Get(key, keyLen);
2239 valdata.
Get(plain, RC2Encryption::BLOCKSIZE);
2240 valdata.
Get(cipher, RC2Encryption::BLOCKSIZE);
2243 transE->ProcessBlock(plain, out);
2244 fail = memcmp(out, cipher, RC2Encryption::BLOCKSIZE) != 0;
2247 transD->ProcessBlock(out, outplain);
2248 fail=fail || memcmp(outplain, plain, RC2Encryption::BLOCKSIZE);
2250 pass = pass && !fail;
2252 cout << (fail ?
"FAILED " :
"passed ");
2253 output.
Put(key, keyLen);
2255 output.
Put(outplain, RC2Encryption::BLOCKSIZE);
2257 output.
Put(out, RC2Encryption::BLOCKSIZE);
2265 unsigned char Key0[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef };
2266 unsigned char Input0[]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
2267 unsigned char Output0[] = {0x75,0xb7,0x87,0x80,0x99,0xe0,0xc5,0x96};
2269 unsigned char Key1[]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
2270 unsigned char Input1[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
2271 unsigned char Output1[]={0x74,0x94,0xc2,0xe7,0x10,0x4b,0x08,0x79};
2273 unsigned char Key2[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
2274 unsigned char Input2[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
2275 unsigned char Output2[]={0xde,0x18,0x89,0x41,0xa3,0x37,0x5d,0x3a};
2277 unsigned char Key3[]={0xef,0x01,0x23,0x45};
2278 unsigned char Input3[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
2279 unsigned char Output3[]={0xd6,0xa1,0x41,0xa7,0xec,0x3c,0x38,0xdf,0xbd,0x61};
2281 unsigned char Key4[]={ 0x01,0x23,0x45,0x67,0x89,0xab, 0xcd,0xef };
2282 unsigned char Input4[] =
2283 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2284 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2285 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2286 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2287 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2288 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2289 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2290 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2291 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2292 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2293 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2294 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2295 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2296 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2297 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2298 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2299 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2300 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2301 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2302 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2303 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2304 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2305 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2306 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2307 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2308 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2309 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2310 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2311 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2312 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2313 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2314 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2315 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2316 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2317 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2318 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2319 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2320 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2321 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2322 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2323 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2324 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2325 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2326 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2327 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2328 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2329 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2330 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2331 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2332 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2333 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
2335 unsigned char Output4[]= {
2336 0x75,0x95,0xc3,0xe6,0x11,0x4a,0x09,0x78,0x0c,0x4a,0xd4,
2337 0x52,0x33,0x8e,0x1f,0xfd,0x9a,0x1b,0xe9,0x49,0x8f,
2338 0x81,0x3d,0x76,0x53,0x34,0x49,0xb6,0x77,0x8d,0xca,
2339 0xd8,0xc7,0x8a,0x8d,0x2b,0xa9,0xac,0x66,0x08,0x5d,
2340 0x0e,0x53,0xd5,0x9c,0x26,0xc2,0xd1,0xc4,0x90,0xc1,
2341 0xeb,0xbe,0x0c,0xe6,0x6d,0x1b,0x6b,0x1b,0x13,0xb6,
2342 0xb9,0x19,0xb8,0x47,0xc2,0x5a,0x91,0x44,0x7a,0x95,
2343 0xe7,0x5e,0x4e,0xf1,0x67,0x79,0xcd,0xe8,0xbf,0x0a,
2344 0x95,0x85,0x0e,0x32,0xaf,0x96,0x89,0x44,0x4f,0xd3,
2345 0x77,0x10,0x8f,0x98,0xfd,0xcb,0xd4,0xe7,0x26,0x56,
2346 0x75,0x00,0x99,0x0b,0xcc,0x7e,0x0c,0xa3,0xc4,0xaa,
2347 0xa3,0x04,0xa3,0x87,0xd2,0x0f,0x3b,0x8f,0xbb,0xcd,
2348 0x42,0xa1,0xbd,0x31,0x1d,0x7a,0x43,0x03,0xdd,0xa5,
2349 0xab,0x07,0x88,0x96,0xae,0x80,0xc1,0x8b,0x0a,0xf6,
2350 0x6d,0xff,0x31,0x96,0x16,0xeb,0x78,0x4e,0x49,0x5a,
2351 0xd2,0xce,0x90,0xd7,0xf7,0x72,0xa8,0x17,0x47,0xb6,
2352 0x5f,0x62,0x09,0x3b,0x1e,0x0d,0xb9,0xe5,0xba,0x53,
2353 0x2f,0xaf,0xec,0x47,0x50,0x83,0x23,0xe6,0x71,0x32,
2354 0x7d,0xf9,0x44,0x44,0x32,0xcb,0x73,0x67,0xce,0xc8,
2355 0x2f,0x5d,0x44,0xc0,0xd0,0x0b,0x67,0xd6,0x50,0xa0,
2356 0x75,0xcd,0x4b,0x70,0xde,0xdd,0x77,0xeb,0x9b,0x10,
2357 0x23,0x1b,0x6b,0x5b,0x74,0x13,0x47,0x39,0x6d,0x62,
2358 0x89,0x74,0x21,0xd4,0x3d,0xf9,0xb4,0x2e,0x44,0x6e,
2359 0x35,0x8e,0x9c,0x11,0xa9,0xb2,0x18,0x4e,0xcb,0xef,
2360 0x0c,0xd8,0xe7,0xa8,0x77,0xef,0x96,0x8f,0x13,0x90,
2361 0xec,0x9b,0x3d,0x35,0xa5,0x58,0x5c,0xb0,0x09,0x29,
2362 0x0e,0x2f,0xcd,0xe7,0xb5,0xec,0x66,0xd9,0x08,0x4b,
2363 0xe4,0x40,0x55,0xa6,0x19,0xd9,0xdd,0x7f,0xc3,0x16,
2364 0x6f,0x94,0x87,0xf7,0xcb,0x27,0x29,0x12,0x42,0x64,
2365 0x45,0x99,0x85,0x14,0xc1,0x5d,0x53,0xa1,0x8c,0x86,
2366 0x4c,0xe3,0xa2,0xb7,0x55,0x57,0x93,0x98,0x81,0x26,
2367 0x52,0x0e,0xac,0xf2,0xe3,0x06,0x6e,0x23,0x0c,0x91,
2368 0xbe,0xe4,0xdd,0x53,0x04,0xf5,0xfd,0x04,0x05,0xb3,
2369 0x5b,0xd9,0x9c,0x73,0x13,0x5d,0x3d,0x9b,0xc3,0x35,
2370 0xee,0x04,0x9e,0xf6,0x9b,0x38,0x67,0xbf,0x2d,0x7b,
2371 0xd1,0xea,0xa5,0x95,0xd8,0xbf,0xc0,0x06,0x6f,0xf8,
2372 0xd3,0x15,0x09,0xeb,0x0c,0x6c,0xaa,0x00,0x6c,0x80,
2373 0x7a,0x62,0x3e,0xf8,0x4c,0x3d,0x33,0xc1,0x95,0xd2,
2374 0x3e,0xe3,0x20,0xc4,0x0d,0xe0,0x55,0x81,0x57,0xc8,
2375 0x22,0xd4,0xb8,0xc5,0x69,0xd8,0x49,0xae,0xd5,0x9d,
2376 0x4e,0x0f,0xd7,0xf3,0x79,0x58,0x6b,0x4b,0x7f,0xf6,
2377 0x84,0xed,0x6a,0x18,0x9f,0x74,0x86,0xd4,0x9b,0x9c,
2378 0x4b,0xad,0x9b,0xa2,0x4b,0x96,0xab,0xf9,0x24,0x37,
2379 0x2c,0x8a,0x8f,0xff,0xb1,0x0d,0x55,0x35,0x49,0x00,
2380 0xa7,0x7a,0x3d,0xb5,0xf2,0x05,0xe1,0xb9,0x9f,0xcd,
2381 0x86,0x60,0x86,0x3a,0x15,0x9a,0xd4,0xab,0xe4,0x0f,
2382 0xa4,0x89,0x34,0x16,0x3d,0xdd,0xe5,0x42,0xa6,0x58,
2383 0x55,0x40,0xfd,0x68,0x3c,0xbf,0xd8,0xc0,0x0f,0x12,
2384 0x12,0x9a,0x28,0x4d,0xea,0xcc,0x4c,0xde,0xfe,0x58,
2385 0xbe,0x71,0x37,0x54,0x1c,0x04,0x71,0x26,0xc8,0xd4,
2386 0x9e,0x27,0x55,0xab,0x18,0x1a,0xb7,0xe9,0x40,0xb0,
2391 bool pass=
true, fail;
2394 cout <<
"\nARC4 validation suite running...\n\n";
2396 arc4.reset(
new Weak::ARC4(Key0,
sizeof(Key0)));
2397 arc4->ProcessString(Input0,
sizeof(Input0));
2398 fail = memcmp(Input0, Output0,
sizeof(Input0)) != 0;
2399 cout << (fail ?
"FAILED" :
"passed") <<
" Test 0" << endl;
2400 pass = pass && !fail;
2402 arc4.reset(
new Weak::ARC4(Key1,
sizeof(Key1)));
2403 arc4->ProcessString(Key1, Input1,
sizeof(Key1));
2404 fail = memcmp(Output1, Key1,
sizeof(Key1)) != 0;
2405 cout << (fail ?
"FAILED" :
"passed") <<
" Test 1" << endl;
2406 pass = pass && !fail;
2408 arc4.reset(
new Weak::ARC4(Key2,
sizeof(Key2)));
2409 for (i=0, fail=
false; i<
sizeof(Input2); i++)
2410 if (arc4->ProcessByte(Input2[i]) != Output2[i])
2412 cout << (fail ?
"FAILED" :
"passed") <<
" Test 2" << endl;
2413 pass = pass && !fail;
2415 arc4.reset(
new Weak::ARC4(Key3,
sizeof(Key3)));
2416 for (i=0, fail=
false; i<
sizeof(Input3); i++)
2417 if (arc4->ProcessByte(Input3[i]) != Output3[i])
2419 cout << (fail ?
"FAILED" :
"passed") <<
" Test 3" << endl;
2420 pass = pass && !fail;
2422 arc4.reset(
new Weak::ARC4(Key4,
sizeof(Key4)));
2423 for (i=0, fail=
false; i<
sizeof(Input4); i++)
2424 if (arc4->ProcessByte(Input4[i]) != Output4[i])
2426 cout << (fail ?
"FAILED" :
"passed") <<
" Test 4" << endl;
2427 pass = pass && !fail;
2434 cout <<
"\nRC5 validation suite running...\n\n";
2435 bool pass1 =
true, pass2 =
true;
2438 pass1 = RC5Encryption::DEFAULT_KEYLENGTH == 16 && pass1;
2439 pass1 = enc.StaticGetValidKeyLength(0) == 0 && pass1;
2440 pass1 = enc.StaticGetValidKeyLength(254) == 254 && pass1;
2441 pass1 = enc.StaticGetValidKeyLength(255) == 255 && pass1;
2442 pass1 = enc.StaticGetValidKeyLength(256) == 255 && pass1;
2443 pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
2444 pass1 = enc.StaticGetValidKeyLength(
SIZE_MAX) == enc.MaxKeyLength() && pass1;
2447 pass2 = RC5Decryption::DEFAULT_KEYLENGTH == 16 && pass2;
2448 pass2 = dec.StaticGetValidKeyLength(0) == 0 && pass2;
2449 pass2 = dec.StaticGetValidKeyLength(254) == 254 && pass2;
2450 pass2 = dec.StaticGetValidKeyLength(255) == 255 && pass2;
2451 pass2 = dec.StaticGetValidKeyLength(256) == 255 && pass2;
2452 pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
2453 pass2 = dec.StaticGetValidKeyLength(
SIZE_MAX) == dec.MaxKeyLength() && pass2;
2454 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2462 cout <<
"\nRC6 validation suite running...\n\n";
2463 bool pass1 =
true, pass2 =
true, pass3 =
true;
2466 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2467 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2468 pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
2469 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
2470 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
2471 pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
2472 pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
2473 pass1 = enc.StaticGetValidKeyLength(
SIZE_MAX) == enc.MaxKeyLength() && pass1;
2476 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2477 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2478 pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
2479 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
2480 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
2481 pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
2482 pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
2483 pass2 = dec.StaticGetValidKeyLength(
SIZE_MAX) == dec.MaxKeyLength() && pass2;
2484 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2490 return pass1 && pass2 && pass3;
2495 cout <<
"\nMARS validation suite running...\n\n";
2496 bool pass1 =
true, pass2 =
true, pass3 =
true;
2499 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2500 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2501 pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
2502 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
2503 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
2504 pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
2505 pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
2506 pass1 = enc.StaticGetValidKeyLength(
SIZE_MAX) == enc.MaxKeyLength() && pass1;
2509 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2510 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2511 pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
2512 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
2513 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
2514 pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
2515 pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
2516 pass2 = dec.StaticGetValidKeyLength(
SIZE_MAX) == dec.MaxKeyLength() && pass2;
2517 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2523 return pass1 && pass2 && pass3;
2526 bool ValidateRijndael()
2528 cout <<
"\nRijndael (AES) validation suite running...\n\n";
2529 bool pass1 =
true, pass2 =
true, pass3 =
true;
2532 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2533 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2534 pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
2535 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
2536 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
2537 pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
2538 pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
2539 pass1 = enc.StaticGetValidKeyLength(
SIZE_MAX) == enc.MaxKeyLength() && pass1;
2542 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2543 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2544 pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
2545 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
2546 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
2547 pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
2548 pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
2549 pass2 = dec.StaticGetValidKeyLength(
SIZE_MAX) == dec.MaxKeyLength() && pass2;
2550 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2556 pass3 = RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/aes.txt") && pass3;
2557 return pass1 && pass2 && pass3;
2560 bool ValidateTwofish()
2562 cout <<
"\nTwofish validation suite running...\n\n";
2563 bool pass1 =
true, pass2 =
true, pass3 =
true;
2566 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2567 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2568 pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
2569 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
2570 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
2571 pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
2574 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2575 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2576 pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
2577 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
2578 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
2579 pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
2580 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2586 return pass1 && pass2 && pass3;
2589 bool ValidateSerpent()
2591 cout <<
"\nSerpent validation suite running...\n\n";
2592 bool pass1 =
true, pass2 =
true, pass3 =
true;
2595 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2596 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2597 pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
2598 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
2599 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
2600 pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
2603 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2604 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2605 pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
2606 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
2607 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
2608 pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
2609 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2616 return pass1 && pass2 && pass3;
2619 bool ValidateBlowfish()
2621 cout <<
"\nBlowfish validation suite running...\n\n";
2622 bool pass1 =
true, pass2 =
true, pass3 =
true, fail;
2625 pass1 = enc1.StaticGetValidKeyLength(3) == 4 && pass1;
2626 pass1 = enc1.StaticGetValidKeyLength(4) == 4 && pass1;
2627 pass1 = enc1.StaticGetValidKeyLength(5) == 5 && pass1;
2628 pass1 = enc1.StaticGetValidKeyLength(8) == 8 && pass1;
2629 pass1 = enc1.StaticGetValidKeyLength(16) == 16 && pass1;
2630 pass1 = enc1.StaticGetValidKeyLength(24) == 24 && pass1;
2631 pass1 = enc1.StaticGetValidKeyLength(32) == 32 && pass1;
2632 pass1 = enc1.StaticGetValidKeyLength(56) == 56 && pass1;
2633 pass1 = enc1.StaticGetValidKeyLength(57) == 56 && pass1;
2634 pass1 = enc1.StaticGetValidKeyLength(60) == 56 && pass1;
2635 pass1 = enc1.StaticGetValidKeyLength(64) == 56 && pass1;
2636 pass1 = enc1.StaticGetValidKeyLength(128) == 56 && pass1;
2639 pass2 = dec1.StaticGetValidKeyLength(3) == 4 && pass2;
2640 pass2 = dec1.StaticGetValidKeyLength(4) == 4 && pass2;
2641 pass2 = dec1.StaticGetValidKeyLength(5) == 5 && pass2;
2642 pass2 = dec1.StaticGetValidKeyLength(8) == 8 && pass2;
2643 pass2 = dec1.StaticGetValidKeyLength(16) == 16 && pass2;
2644 pass2 = dec1.StaticGetValidKeyLength(24) == 24 && pass2;
2645 pass2 = dec1.StaticGetValidKeyLength(32) == 32 && pass2;
2646 pass2 = dec1.StaticGetValidKeyLength(56) == 56 && pass2;
2647 pass2 = dec1.StaticGetValidKeyLength(57) == 56 && pass2;
2648 pass2 = dec1.StaticGetValidKeyLength(60) == 56 && pass2;
2649 pass2 = dec1.StaticGetValidKeyLength(64) == 56 && pass2;
2650 pass2 = dec1.StaticGetValidKeyLength(128) == 56 && pass2;
2651 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2654 const char *key[]={
"abcdefghijklmnopqrstuvwxyz",
"Who is John Galt?"};
2655 byte *plain[]={(byte *)
"BLOWFISH", (byte *)
"\xfe\xdc\xba\x98\x76\x54\x32\x10"};
2656 byte *cipher[]={(byte *)
"\x32\x4e\xd0\xfe\xf4\x13\xa2\x03", (byte *)
"\xcc\x91\x73\x2b\x80\x22\xf6\x84"};
2657 byte out[8], outplain[8];
2659 for (
int i=0; i<2; i++)
2662 enc2.ProcessData(out, plain[i], 8);
2663 fail = memcmp(out, cipher[i], 8) != 0;
2666 dec2.ProcessData(outplain, cipher[i], 8);
2667 fail = fail || memcmp(outplain, plain[i], 8);
2668 pass3 = pass3 && !fail;
2670 cout << (fail ?
"FAILED " :
"passed ");
2671 cout <<
'\"' << key[i] <<
'\"';
2672 for (
int j=0; j<(
signed int)(30-strlen(key[i])); j++)
2674 output.Put(outplain, 8);
2679 return pass1 && pass2 && pass3;
2682 bool ValidateThreeWay()
2684 cout <<
"\n3-WAY validation suite running...\n\n";
2685 bool pass1 =
true, pass2 =
true;
2688 pass1 = ThreeWayEncryption::KEYLENGTH == 12 && pass1;
2689 pass1 = enc.StaticGetValidKeyLength(8) == 12 && pass1;
2690 pass1 = enc.StaticGetValidKeyLength(12) == 12 && pass1;
2691 pass1 = enc.StaticGetValidKeyLength(16) == 12 && pass1;
2694 pass2 = ThreeWayDecryption::KEYLENGTH == 12 && pass2;
2695 pass2 = dec.StaticGetValidKeyLength(8) == 12 && pass2;
2696 pass2 = dec.StaticGetValidKeyLength(12) == 12 && pass2;
2697 pass2 = dec.StaticGetValidKeyLength(16) == 12 && pass2;
2698 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2706 cout <<
"\nGOST validation suite running...\n\n";
2707 bool pass1 =
true, pass2 =
true;
2710 pass1 = GOSTEncryption::KEYLENGTH == 32 && pass1;
2711 pass1 = enc.StaticGetValidKeyLength(16) == 32 && pass1;
2712 pass1 = enc.StaticGetValidKeyLength(24) == 32 && pass1;
2713 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
2714 pass1 = enc.StaticGetValidKeyLength(40) == 32 && pass1;
2715 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
2718 pass2 = GOSTDecryption::KEYLENGTH == 32 && pass2;
2719 pass2 = dec.StaticGetValidKeyLength(16) == 32 && pass2;
2720 pass2 = dec.StaticGetValidKeyLength(24) == 32 && pass2;
2721 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
2722 pass2 = dec.StaticGetValidKeyLength(40) == 32 && pass2;
2723 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
2724 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2730 bool ValidateSHARK()
2732 cout <<
"\nSHARK validation suite running...\n\n";
2733 bool pass1 =
true, pass2 =
true;
2736 pass1 = SHARKEncryption::KEYLENGTH == 16 && pass1;
2737 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2738 pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1;
2739 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2740 pass1 = enc.StaticGetValidKeyLength(17) == 16 && pass1;
2741 pass1 = enc.StaticGetValidKeyLength(32) == 16 && pass1;
2744 pass2 = SHARKDecryption::KEYLENGTH == 16 && pass2;
2745 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2746 pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2;
2747 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2748 pass2 = dec.StaticGetValidKeyLength(17) == 16 && pass2;
2749 pass2 = dec.StaticGetValidKeyLength(32) == 16 && pass2;
2750 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2758 cout <<
"\nCAST-128 validation suite running...\n\n";
2759 bool pass1 =
true, pass2 =
true, pass3 =
true;
2762 pass1 = CAST128Encryption::DEFAULT_KEYLENGTH == 16 && pass1;
2763 pass1 = enc1.StaticGetValidKeyLength(4) == 5 && pass1;
2764 pass1 = enc1.StaticGetValidKeyLength(5) == 5 && pass1;
2765 pass1 = enc1.StaticGetValidKeyLength(15) == 15 && pass1;
2766 pass1 = enc1.StaticGetValidKeyLength(16) == 16 && pass1;
2767 pass1 = enc1.StaticGetValidKeyLength(17) == 16 && pass1;
2770 pass2 = CAST128Decryption::DEFAULT_KEYLENGTH == 16 && pass2;
2771 pass2 = dec1.StaticGetValidKeyLength(4) == 5 && pass2;
2772 pass2 = dec1.StaticGetValidKeyLength(5) == 5 && pass2;
2773 pass2 = dec1.StaticGetValidKeyLength(15) == 15 && pass2;
2774 pass2 = dec1.StaticGetValidKeyLength(16) == 16 && pass2;
2775 pass2 = dec1.StaticGetValidKeyLength(17) == 16 && pass2;
2776 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2783 cout <<
"\nCAST-256 validation suite running...\n\n";
2784 bool pass4 =
true, pass5 =
true, pass6 =
true;
2787 pass1 = CAST128Encryption::DEFAULT_KEYLENGTH == 16 && pass1;
2788 pass4 = enc2.StaticGetValidKeyLength(15) == 16 && pass4;
2789 pass4 = enc2.StaticGetValidKeyLength(16) == 16 && pass4;
2790 pass4 = enc2.StaticGetValidKeyLength(17) == 20 && pass4;
2791 pass4 = enc2.StaticGetValidKeyLength(20) == 20 && pass4;
2792 pass4 = enc2.StaticGetValidKeyLength(24) == 24 && pass4;
2793 pass4 = enc2.StaticGetValidKeyLength(28) == 28 && pass4;
2794 pass4 = enc2.StaticGetValidKeyLength(31) == 32 && pass4;
2795 pass4 = enc2.StaticGetValidKeyLength(32) == 32 && pass4;
2796 pass4 = enc2.StaticGetValidKeyLength(33) == 32 && pass4;
2799 pass2 = CAST256Decryption::DEFAULT_KEYLENGTH == 16 && pass2;
2800 pass5 = dec2.StaticGetValidKeyLength(15) == 16 && pass5;
2801 pass5 = dec2.StaticGetValidKeyLength(16) == 16 && pass5;
2802 pass5 = dec2.StaticGetValidKeyLength(17) == 20 && pass5;
2803 pass5 = dec2.StaticGetValidKeyLength(20) == 20 && pass5;
2804 pass5 = dec2.StaticGetValidKeyLength(24) == 24 && pass5;
2805 pass5 = dec2.StaticGetValidKeyLength(28) == 28 && pass5;
2806 pass5 = dec2.StaticGetValidKeyLength(31) == 32 && pass5;
2807 pass5 = dec2.StaticGetValidKeyLength(32) == 32 && pass5;
2808 pass5 = dec2.StaticGetValidKeyLength(33) == 32 && pass5;
2809 cout << (pass4 && pass5 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2816 return pass1 && pass2 && pass3 && pass4 && pass5 && pass6;
2819 bool ValidateSquare()
2821 cout <<
"\nSquare validation suite running...\n\n";
2822 bool pass1 =
true, pass2 =
true;
2825 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2826 pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1;
2827 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2828 pass1 = enc.StaticGetValidKeyLength(17) == 16 && pass1;
2831 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2832 pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2;
2833 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2834 pass2 = dec.StaticGetValidKeyLength(17) == 16 && pass2;
2835 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2841 bool ValidateSKIPJACK()
2843 cout <<
"\nSKIPJACK validation suite running...\n\n";
2844 bool pass1 =
true, pass2 =
true;
2847 pass1 = enc.StaticGetValidKeyLength(8) == 10 && pass1;
2848 pass1 = enc.StaticGetValidKeyLength(9) == 10 && pass1;
2849 pass1 = enc.StaticGetValidKeyLength(10) == 10 && pass1;
2850 pass1 = enc.StaticGetValidKeyLength(16) == 10 && pass1;
2853 pass2 = dec.StaticGetValidKeyLength(8) == 10 && pass2;
2854 pass2 = dec.StaticGetValidKeyLength(9) == 10 && pass2;
2855 pass2 = dec.StaticGetValidKeyLength(10) == 10 && pass2;
2856 pass2 = dec.StaticGetValidKeyLength(16) == 10 && pass2;
2857 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2865 static const byte input[] = {0x37,0xa0,0x05,0x95,0x9b,0x84,0xc4,0x9c,0xa4,0xbe,0x1e,0x05,0x06,0x73,0x53,0x0f,0x5f,0xb0,0x97,0xfd,0xf6,0xa1,0x3f,0xbd,0x6c,0x2c,0xde,0xcd,0x81,0xfd,0xee,0x7c};
2866 static const byte key[] = {0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0};
2867 static const byte iv[] = {0x01, 0x35, 0x77, 0xaf};
2870 cout <<
"\nSEAL validation suite running...\n\n";
2873 unsigned int size =
sizeof(input);
2876 memset(output, 1, size);
2877 seal.ProcessString(output, input, size);
2878 for (
unsigned int i=0; i<size; i++)
2883 output[1] = seal.ProcessByte(output[1]);
2884 seal.ProcessString(output+2, size-2);
2885 pass = pass && memcmp(output+1, input+1, size-1) == 0;
2887 cout << (pass ?
"passed" :
"FAILED") << endl;
2891 bool ValidateBaseCode()
2893 bool pass =
true, fail;
2895 for (
unsigned int i=0; i<255; i++)
2897 static const char hexEncoded[] =
2898 "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627" 2899 "28292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F" 2900 "505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F7071727374757677" 2901 "78797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9F" 2902 "A0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7" 2903 "C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF" 2904 "F0F1F2F3F4F5F6F7F8F9FAFBFCFDFE";
2905 static const char base32Encoded[] =
2906 "AAASEA2EAWDAQCAJBIFS2DIQB6IBCESVCSKTNF22DEPBYHA7D2RUAIJCENUCKJTHFAWUWK3NFWZC8NBT" 2907 "GI3VIPJYG66DUQT5HS8V6R4AIFBEGTCFI3DWSUKKJPGE4VURKBIXEW4WKXMFQYC3MJPX2ZK8M7SGC2VD" 2908 "NTUYN35IPFXGY5DPP3ZZA6MUQP4HK7VZRB6ZW856RX9H9AEBSKB2JBNGS8EIVCWMTUG27D6SUGJJHFEX" 2909 "U4M3TGN4VQQJ5HW9WCS4FI7EWYVKRKFJXKX43MPQX82MDNXVYU45PP72ZG7MZRF7Z496BSQC2RCNMTYH" 2910 "3DE6XU8N3ZHN9WGT4MJ7JXQY49NPVYY55VQ77Z9A6HTQH3HF65V8T4RK7RYQ55ZR8D29F69W8Z5RR8H3" 2912 const char *base64AndHexEncoded =
2913 "41414543417751464267634943516F4C4441304F4478415245684D554652595847426B6147787764" 2914 "486838674953496A4A43556D4A7967704B6973734C5334764D4445794D7A51310A4E6A63344F546F" 2915 "375044302B50304242516B4E4552555A4853456C4B5330784E546B395155564A5456465657563168" 2916 "5A576C746358563566594746695932526C5A6D646F615770720A6247317562334278636E4E306458" 2917 "5A3365486C3665337839666E2B4167594B44684957476834694A696F754D6A5936506B4A47536B35" 2918 "53566C7065596D5A71626E4A32656E3643680A6F714F6B7061616E714B6D717136797472712B7773" 2919 "624B7A744C573274376935757275387662362F774D484377385446787366497963724C7A4D334F7A" 2920 "39445230745055316462580A324E6E6132397A6433742F6734654C6A354F586D352B6A7036757673" 2921 "3765377638504879382F5431397666342B6672372F50332B0A";
2923 cout <<
"\nBase64, base32 and hex coding validation suite running...\n\n";
2925 fail = !TestFilter(
HexEncoder().Ref(), data, 255, (
const byte *)hexEncoded, strlen(hexEncoded));
2926 cout << (fail ?
"FAILED " :
"passed ");
2927 cout <<
"Hex Encoding\n";
2928 pass = pass && !fail;
2930 fail = !TestFilter(
HexDecoder().Ref(), (
const byte *)hexEncoded, strlen(hexEncoded), data, 255);
2931 cout << (fail ?
"FAILED " :
"passed ");
2932 cout <<
"Hex Decoding\n";
2933 pass = pass && !fail;
2935 fail = !TestFilter(
Base32Encoder().Ref(), data, 255, (
const byte *)base32Encoded, strlen(base32Encoded));
2936 cout << (fail ?
"FAILED " :
"passed ");
2937 cout <<
"Base32 Encoding\n";
2938 pass = pass && !fail;
2940 fail = !TestFilter(
Base32Decoder().Ref(), (
const byte *)base32Encoded, strlen(base32Encoded), data, 255);
2941 cout << (fail ?
"FAILED " :
"passed ");
2942 cout <<
"Base32 Decoding\n";
2943 pass = pass && !fail;
2945 fail = !TestFilter(
Base64Encoder(
new HexEncoder).Ref(), data, 255, (
const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded));
2946 cout << (fail ?
"FAILED " :
"passed ");
2947 cout <<
"Base64 Encoding\n";
2948 pass = pass && !fail;
2950 fail = !TestFilter(
HexDecoder(
new Base64Decoder).Ref(), (
const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded), data, 255);
2951 cout << (fail ?
"FAILED " :
"passed ");
2952 cout <<
"Base64 Decoding\n";
2953 pass = pass && !fail;
2958 bool ValidateSHACAL2()
2960 cout <<
"\nSHACAL-2 validation suite running...\n\n";
2961 bool pass1 =
true, pass2 =
true, pass3 =
true;
2964 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2965 pass1 = enc.StaticGetValidKeyLength(15) == 16 && pass1;
2966 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2967 pass1 = enc.StaticGetValidKeyLength(64) == 64 && pass1;
2968 pass1 = enc.StaticGetValidKeyLength(65) == 64 && pass1;
2969 pass1 = enc.StaticGetValidKeyLength(128) == 64 && pass1;
2970 pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
2971 pass1 = enc.StaticGetValidKeyLength(
SIZE_MAX) == enc.MaxKeyLength() && pass1;
2974 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
2975 pass2 = dec.StaticGetValidKeyLength(15) == 16 && pass2;
2976 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
2977 pass2 = dec.StaticGetValidKeyLength(64) == 64 && pass2;
2978 pass2 = dec.StaticGetValidKeyLength(65) == 64 && pass2;
2979 pass2 = dec.StaticGetValidKeyLength(128) == 64 && pass2;
2980 pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
2981 pass2 = dec.StaticGetValidKeyLength(
SIZE_MAX) == dec.MaxKeyLength() && pass2;
2982 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
2987 return pass1 && pass2 && pass3;
2990 bool ValidateCamellia()
2992 cout <<
"\nCamellia validation suite running...\n\n";
2993 bool pass1 =
true, pass2 =
true, pass3 =
true;
2996 pass1 = enc.StaticGetValidKeyLength(8) == 16 && pass1;
2997 pass1 = enc.StaticGetValidKeyLength(16) == 16 && pass1;
2998 pass1 = enc.StaticGetValidKeyLength(24) == 24 && pass1;
2999 pass1 = enc.StaticGetValidKeyLength(32) == 32 && pass1;
3000 pass1 = enc.StaticGetValidKeyLength(64) == 32 && pass1;
3001 pass1 = enc.StaticGetValidKeyLength(128) == 32 && pass1;
3002 pass1 = enc.StaticGetValidKeyLength(0) == enc.MinKeyLength() && pass1;
3003 pass1 = enc.StaticGetValidKeyLength(
SIZE_MAX) == enc.MaxKeyLength() && pass1;
3006 pass2 = dec.StaticGetValidKeyLength(8) == 16 && pass2;
3007 pass2 = dec.StaticGetValidKeyLength(16) == 16 && pass2;
3008 pass2 = dec.StaticGetValidKeyLength(24) == 24 && pass2;
3009 pass2 = dec.StaticGetValidKeyLength(32) == 32 && pass2;
3010 pass2 = dec.StaticGetValidKeyLength(64) == 32 && pass2;
3011 pass2 = dec.StaticGetValidKeyLength(128) == 32 && pass2;
3012 pass2 = dec.StaticGetValidKeyLength(0) == dec.MinKeyLength() && pass2;
3013 pass2 = dec.StaticGetValidKeyLength(
SIZE_MAX) == dec.MaxKeyLength() && pass2;
3014 cout << (pass1 && pass2 ?
"passed:" :
"FAILED:") <<
" Algorithm key lengths\n";
3020 return pass1 && pass2 && pass3;
3023 bool ValidateSalsa()
3025 cout <<
"\nSalsa validation suite running...\n";
3027 return RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/salsa.txt");
3030 bool ValidateSosemanuk()
3032 cout <<
"\nSosemanuk validation suite running...\n";
3033 return RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/sosemanuk.txt");
3038 cout <<
"\nVMAC validation suite running...\n";
3039 return RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/vmac.txt");
3044 cout <<
"\nAES/CCM validation suite running...\n";
3045 return RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/ccm.txt");
3050 cout <<
"\nAES/GCM validation suite running...\n";
3051 cout <<
"\n2K tables:";
3053 cout <<
"\n64K tables:";
3059 cout <<
"\nCMAC validation suite running...\n";
3060 return RunTestDataFile(CRYPTOPP_DATA_DIR
"TestVectors/cmac.txt");
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
Base class for all exceptions thrown by the library.
bool HasISSE()
Determines SSE availability.
Stack-based SecBlock that grows into the heap.
unsigned int BytesNeeded() const
Provides the number of bytes of input is needed by the test.
Wrapper class for /dev/random and /dev/srandom.
bool HasSSE4()
Determines SSE4 availability.
Class file for modes of operation.
bool HasSSSE3()
Determines SSSE3 availability.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
This file contains helper classes/functions for implementing public key algorithms.
bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
Hardware generated random numbers using RDRAND instruction.
file-based implementation of Source interface
Converts given data to base 16.
Classes for the RC5 block cipher.
virtual word32 GenerateWord32(word32 min=0, word32 max=0xffffffffUL)
Generate a random 32 bit word in the range min to max, inclusive.
Decode base 16 data back to bytes.
Abstract base classes that provide a uniform interface to this library.
void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count)
Bounds checking replacement for memcpy()
Classes for the RC2 block cipher.
BufferedTransformation & TheBitBucket()
An input discarding BufferedTransformation.
Manages resources for an array of objects.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
virtual void DiscardBytes(size_t n)
Generate and discard n bytes.
Classes for automatic resource management.
bool IsP4()
Determines if the CPU is an Intel P4.
DEFLATE compressor (RFC 1951)
virtual bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
Classes for the GIST block cipher.
Classes for the Cameliia block cipher.
Classes for RDRAND and RDSEED.
int GetCacheLineSize()
Provides the cache line size.
virtual void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
Classes for Base32Encoder and Base32Decoder.
bool HasRDRAND()
Determines RDRAND availability.
Classes for the RC6 block cipher.
size_type max_size() const
Returns the maximum number of elements the allocator can provide.
DEFLATE compression and decompression (RFC 1951)
Route input to different and/or multiple channels based on channel ID.
Classes for multiple named channels.
Classes for the Twofish block cipher.
1 and 0's padding added to a block
Classes for the Blowfish block cipher.
Classes for the MARS block cipher (IBM AES submission)
const char * TableSize()
int, in bytes
Classes for the SKIPJACK block cipher.
Filter wrapper for HashTransformation.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Exception thrown when an operating system error is encountered.
Block cipher mode of operation aggregate.
virtual void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
Classes for HexEncoder and HexDecoder.
Maurer's Universal Statistical Test for Random Bit Generators.
virtual void DiscardBytes(size_t n)
Generate and discard n bytes.
bool HasRDSEED()
Determines RDSEED availability.
bool HasCLMUL()
Determines Carryless Multiply availability.
Automatically Seeded Randomness Pool.
void Assign(const T *ptr, size_type len)
Set contents and size from an array.
Class file for the AES cipher (Rijndael)
Classes for the CAST-128 and CAST-256 block ciphers.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Provides class member functions to key a block cipher.
Classes for DMAC message authentication code.
Implementation of schemes based on DL over GF(p)
bool IsPowerOf2(const T &value)
Tests whether a value is a power of 2.
#define COUNTOF(arr)
Counts elements in an array.
Miscellaneous classes for RNGs.
Automatically Seeded X9.17 RNG.
Classes for SEAL stream cipher.
Redirect input to another BufferedTransformation without owning it.
Classes for Rijndael encryption algorithm.
Functions for CPU features and intrinsics.
Classes for DES, 2-key Triple-DES, 3-key Triple-DES and DESX.
std::string AlgorithmName() const
Provides the name of this algorithm.
Implementation of BufferedTransformation's attachment interface.
Hardware generated random numbers using RDSEED instruction.
Classes for the Base64Encoder, Base64Decoder, Base64URLEncoder and Base64URLDecoder.
bool HasAESNI()
Determines AES-NI availability.
Classes for the SAFER and SAFER-K block ciphers.
Base class for unflushable filters.
Wrapper class for /dev/random and /dev/srandom.
bool CanIncorporateEntropy() const
Determines if a generator can accept additional entropy.
bool HasSSE2()
Determines SSE2 availability.
void OS_GenerateRandomBlock(bool blocking, byte *output, size_t size)
OS_GenerateRandomBlock.
0's padding added to a block
Measure how many bytes and messages pass through the filter.
bool HasMMX()
Determines MMX availability.
const T & STDMAX(const T &a, const T &b)
Replacement function for std::max.
Classes for the 3-Way block cipher.
void SetRetries(unsigned int retries)
Set the number of retries used by the generator.
No padding added to a block.
Classes and functions for Elliptic Curves over prime and binary fields.
Classes for the Serpent block cipher.
Crypto++ library namespace.
SymmetricCipher implementation.
Class specific methods used to operate the cipher in the reverse direction.
RNG-based implementation of Source interface.
unsigned int GetRetries() const
Retrieve the number of retries used by the generator.
size_type SizeInBytes() const
Provides the number of bytes in the SecBlock.
Classes for the SHARK block cipher.
Class specific methods used to operate the cipher in the forward direction.
file-based implementation of Sink interface
Classes for the Square block cipher.
virtual void GetNextIV(RandomNumberGenerator &rng, byte *iv)
Retrieves a secure IV for the next message.
virtual unsigned int IVSize() const
Returns length of the IV accepted by this object.
Classes for access to the operating system's random number generators.
Classes for the IDEA block cipher.
void IncorporateEntropy(const byte *input, size_t length)
Update RNG state with additional unpredictable values.
#define SIZE_MAX
The maximum value of a machine word.
Classes for the SHACAL-2 block cipher.