Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

fipstest.cpp

00001 // fipstest.cpp - written and placed in the public domain by Wei Dai 00002 00003 #include "pch.h" 00004 00005 #ifndef CRYPTOPP_IMPORTS 00006 00007 #define CRYPTOPP_DEFAULT_NO_DLL 00008 #include "dll.h" 00009 00010 #ifdef CRYPTOPP_WIN32_AVAILABLE 00011 #include <windows.h> 00012 #endif 00013 00014 NAMESPACE_BEGIN(CryptoPP) 00015 00016 extern PowerUpSelfTestStatus g_powerUpSelfTestStatus; 00017 SecByteBlock g_actualMac; 00018 unsigned long g_macFileLocation = 0; 00019 00020 const byte * CRYPTOPP_API GetActualMacAndLocation(unsigned int &macSize, unsigned int &fileLocation) 00021 { 00022 macSize = g_actualMac.size(); 00023 fileLocation = g_macFileLocation; 00024 return g_actualMac; 00025 } 00026 00027 void KnownAnswerTest(RandomNumberGenerator &rng, const char *output) 00028 { 00029 EqualityComparisonFilter comparison; 00030 00031 RandomNumberStore(rng, strlen(output)/2).TransferAllTo(comparison, "0"); 00032 StringSource(output, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); 00033 00034 comparison.ChannelMessageSeriesEnd("0"); 00035 comparison.ChannelMessageSeriesEnd("1"); 00036 } 00037 00038 template <class CIPHER> 00039 void X917RNG_KnownAnswerTest( 00040 const char *key, 00041 const char *seed, 00042 const char *output, 00043 unsigned int deterministicTimeVector, 00044 CIPHER *dummy = NULL) 00045 { 00046 #ifdef OS_RNG_AVAILABLE 00047 std::string decodedKey, decodedSeed; 00048 StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); 00049 StringSource(seed, true, new HexDecoder(new StringSink(decodedSeed))); 00050 00051 AutoSeededX917RNG<CIPHER> rng; 00052 rng.Reseed((const byte *)decodedKey.data(), decodedKey.size(), (const byte *)decodedSeed.data(), deterministicTimeVector); 00053 KnownAnswerTest(rng, output); 00054 #else 00055 throw 0; 00056 #endif 00057 } 00058 00059 void KnownAnswerTest(StreamTransformation &encryption, StreamTransformation &decryption, const char *plaintext, const char *ciphertext) 00060 { 00061 EqualityComparisonFilter comparison; 00062 00063 StringSource(plaintext, true, new HexDecoder(new StreamTransformationFilter(encryption, new ChannelSwitch(comparison, "0"), StreamTransformationFilter::NO_PADDING))); 00064 StringSource(ciphertext, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); 00065 00066 StringSource(ciphertext, true, new HexDecoder(new StreamTransformationFilter(decryption, new ChannelSwitch(comparison, "0"), StreamTransformationFilter::NO_PADDING))); 00067 StringSource(plaintext, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); 00068 00069 comparison.ChannelMessageSeriesEnd("0"); 00070 comparison.ChannelMessageSeriesEnd("1"); 00071 } 00072 00073 template <class CIPHER> 00074 void SymmetricEncryptionKnownAnswerTest( 00075 const char *key, 00076 const char *hexIV, 00077 const char *plaintext, 00078 const char *ecb, 00079 const char *cbc, 00080 const char *cfb, 00081 const char *ofb, 00082 const char *ctr, 00083 CIPHER *dummy = NULL) 00084 { 00085 std::string decodedKey; 00086 StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); 00087 00088 typename CIPHER::Encryption encryption((const byte *)decodedKey.data(), decodedKey.size()); 00089 typename CIPHER::Decryption decryption((const byte *)decodedKey.data(), decodedKey.size()); 00090 00091 SecByteBlock iv(encryption.BlockSize()); 00092 StringSource(hexIV, true, new HexDecoder(new ArraySink(iv, iv.size()))); 00093 00094 if (ecb) 00095 KnownAnswerTest(ECB_Mode_ExternalCipher::Encryption(encryption).Ref(), ECB_Mode_ExternalCipher::Decryption(decryption).Ref(), plaintext, ecb); 00096 if (cbc) 00097 KnownAnswerTest(CBC_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), CBC_Mode_ExternalCipher::Decryption(decryption, iv).Ref(), plaintext, cbc); 00098 if (cfb) 00099 KnownAnswerTest(CFB_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), CFB_Mode_ExternalCipher::Decryption(encryption, iv).Ref(), plaintext, cfb); 00100 if (ofb) 00101 KnownAnswerTest(OFB_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), OFB_Mode_ExternalCipher::Decryption(encryption, iv).Ref(), plaintext, ofb); 00102 if (ctr) 00103 KnownAnswerTest(CTR_Mode_ExternalCipher::Encryption(encryption, iv).Ref(), CTR_Mode_ExternalCipher::Decryption(encryption, iv).Ref(), plaintext, ctr); 00104 } 00105 00106 void KnownAnswerTest(HashTransformation &hash, const char *message, const char *digest) 00107 { 00108 EqualityComparisonFilter comparison; 00109 StringSource(digest, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); 00110 StringSource(message, true, new HashFilter(hash, new ChannelSwitch(comparison, "0"))); 00111 00112 comparison.ChannelMessageSeriesEnd("0"); 00113 comparison.ChannelMessageSeriesEnd("1"); 00114 } 00115 00116 template <class HASH> 00117 void SecureHashKnownAnswerTest(const char *message, const char *digest, HASH *dummy = NULL) 00118 { 00119 HASH hash; 00120 KnownAnswerTest(hash, message, digest); 00121 } 00122 00123 template <class MAC> 00124 void MAC_KnownAnswerTest(const char *key, const char *message, const char *digest, MAC *dummy = NULL) 00125 { 00126 std::string decodedKey; 00127 StringSource(key, true, new HexDecoder(new StringSink(decodedKey))); 00128 00129 MAC mac((const byte *)decodedKey.data(), decodedKey.size()); 00130 KnownAnswerTest(mac, message, digest); 00131 } 00132 00133 template <class SCHEME> 00134 void SignatureKnownAnswerTest(const char *key, const char *message, const char *signature, SCHEME *dummy = NULL) 00135 { 00136 #ifdef OS_RNG_AVAILABLE 00137 AutoSeededX917RNG<DES_EDE3> rng; 00138 #else 00139 RandomNumberGenerator &rng = NullRNG(); 00140 #endif 00141 00142 typename SCHEME::Signer signer(StringSource(key, true, new HexDecoder).Ref()); 00143 typename SCHEME::Verifier verifier(signer); 00144 00145 EqualityComparisonFilter comparison; 00146 00147 StringSource(message, true, new SignerFilter(rng, signer, new ChannelSwitch(comparison, "0"))); 00148 StringSource(signature, true, new HexDecoder(new ChannelSwitch(comparison, "1"))); 00149 00150 comparison.ChannelMessageSeriesEnd("0"); 00151 comparison.ChannelMessageSeriesEnd("1"); 00152 00153 VerifierFilter verifierFilter(verifier, NULL, VerifierFilter::SIGNATURE_AT_BEGIN | VerifierFilter::THROW_EXCEPTION); 00154 StringSource(signature, true, new HexDecoder(new Redirector(verifierFilter, Redirector::DATA_ONLY))); 00155 StringSource(message, true, new Redirector(verifierFilter)); 00156 } 00157 00158 void EncryptionPairwiseConsistencyTest(const PK_Encryptor &encryptor, const PK_Decryptor &decryptor) 00159 { 00160 try 00161 { 00162 #ifdef OS_RNG_AVAILABLE 00163 AutoSeededX917RNG<DES_EDE3> rng; 00164 #else 00165 RandomNumberGenerator &rng = NullRNG(); 00166 #endif 00167 const char *testMessage ="test message"; 00168 std::string ciphertext, decrypted; 00169 00170 StringSource( 00171 testMessage, 00172 true, 00173 new PK_EncryptorFilter( 00174 rng, 00175 encryptor, 00176 new StringSink(ciphertext))); 00177 00178 if (ciphertext == testMessage) 00179 throw 0; 00180 00181 StringSource( 00182 ciphertext, 00183 true, 00184 new PK_DecryptorFilter( 00185 rng, 00186 decryptor, 00187 new StringSink(decrypted))); 00188 00189 if (decrypted != testMessage) 00190 throw 0; 00191 } 00192 catch (...) 00193 { 00194 throw SelfTestFailure(encryptor.AlgorithmName() + ": pairwise consistency test failed"); 00195 } 00196 } 00197 00198 void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier &verifier) 00199 { 00200 try 00201 { 00202 #ifdef OS_RNG_AVAILABLE 00203 AutoSeededX917RNG<DES_EDE3> rng; 00204 #else 00205 RandomNumberGenerator &rng = NullRNG(); 00206 #endif 00207 00208 StringSource( 00209 "test message", 00210 true, 00211 new SignerFilter( 00212 rng, 00213 signer, 00214 new VerifierFilter(verifier, NULL, VerifierFilter::THROW_EXCEPTION), 00215 true)); 00216 } 00217 catch (...) 00218 { 00219 throw SelfTestFailure(signer.AlgorithmName() + ": pairwise consistency test failed"); 00220 } 00221 } 00222 00223 template <class SCHEME> 00224 void SignaturePairwiseConsistencyTest(const char *key, SCHEME *dummy = NULL) 00225 { 00226 typename SCHEME::Signer signer(StringSource(key, true, new HexDecoder).Ref()); 00227 typename SCHEME::Verifier verifier(signer); 00228 00229 SignaturePairwiseConsistencyTest(signer, verifier); 00230 } 00231 00232 MessageAuthenticationCode * NewIntegrityCheckingMAC() 00233 { 00234 byte key[] = {0x47, 0x1E, 0x33, 0x96, 0x65, 0xB1, 0x6A, 0xED, 0x0B, 0xF8, 0x6B, 0xFD, 0x01, 0x65, 0x05, 0xCC}; 00235 return new HMAC<SHA1>(key, sizeof(key)); 00236 } 00237 00238 bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac, unsigned long *pMacFileLocation) 00239 { 00240 std::auto_ptr<MessageAuthenticationCode> mac(NewIntegrityCheckingMAC()); 00241 unsigned int macSize = mac->DigestSize(); 00242 00243 SecByteBlock tempMac; 00244 SecByteBlock &actualMac = pActualMac ? *pActualMac : tempMac; 00245 actualMac.resize(macSize); 00246 00247 unsigned long tempLocation; 00248 unsigned long &macFileLocation = pMacFileLocation ? *pMacFileLocation : tempLocation; 00249 macFileLocation = 0; 00250 00251 HashFilter verifier(*mac, new ArraySink(actualMac, actualMac.size())); 00252 // FileSink verifier("c:\\dt.tmp"); 00253 FileStore file(moduleFilename); 00254 00255 #ifdef CRYPTOPP_WIN32_AVAILABLE 00256 // try to hash from memory first 00257 HMODULE h = GetModuleHandle(moduleFilename); 00258 const byte *memBase = (const byte *)h; 00259 IMAGE_DOS_HEADER *ph = (IMAGE_DOS_HEADER *)h; 00260 IMAGE_NT_HEADERS *phnt = (IMAGE_NT_HEADERS *)((byte *)h + ph->e_lfanew); 00261 IMAGE_SECTION_HEADER *phs = IMAGE_FIRST_SECTION(phnt); 00262 DWORD nSections = phnt->FileHeader.NumberOfSections; 00263 DWORD currentFilePos = 0; 00264 00265 while (nSections--) 00266 { 00267 switch (phs->Characteristics) 00268 { 00269 default: 00270 break; 00271 case IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ: 00272 case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ: 00273 unsigned int sectionSize = STDMIN(phs->SizeOfRawData, phs->Misc.VirtualSize); 00274 const byte *sectionMemStart = memBase + phs->VirtualAddress; 00275 unsigned int sectionFileStart = phs->PointerToRawData; 00276 unsigned int subSectionStart = 0, nextSubSectionStart; 00277 00278 do 00279 { 00280 const byte *subSectionMemStart = sectionMemStart + subSectionStart; 00281 unsigned int subSectionFileStart = sectionFileStart + subSectionStart; 00282 unsigned int subSectionSize = sectionSize - subSectionStart; 00283 nextSubSectionStart = 0; 00284 00285 unsigned int entriesToReadFromDisk[] = {IMAGE_DIRECTORY_ENTRY_IMPORT, IMAGE_DIRECTORY_ENTRY_IAT}; 00286 for (unsigned int i=0; i<sizeof(entriesToReadFromDisk)/sizeof(entriesToReadFromDisk[0]); i++) 00287 { 00288 const IMAGE_DATA_DIRECTORY &entry = phnt->OptionalHeader.DataDirectory[entriesToReadFromDisk[i]]; 00289 const byte *entryMemStart = memBase + entry.VirtualAddress; 00290 if (subSectionMemStart <= entryMemStart && entryMemStart < subSectionMemStart + subSectionSize) 00291 { 00292 subSectionSize = entryMemStart - subSectionMemStart; 00293 nextSubSectionStart = entryMemStart - sectionMemStart + entry.Size; 00294 } 00295 } 00296 00297 file.TransferTo(verifier, subSectionFileStart - currentFilePos); 00298 if (subSectionMemStart <= expectedModuleMac && expectedModuleMac < subSectionMemStart + subSectionSize) 00299 { 00300 // skip over the MAC 00301 verifier.Put(subSectionMemStart, expectedModuleMac - subSectionMemStart); 00302 verifier.Put(expectedModuleMac + macSize, subSectionSize - macSize - (expectedModuleMac - subSectionMemStart)); 00303 macFileLocation = subSectionFileStart + (expectedModuleMac - subSectionMemStart); 00304 } 00305 else 00306 verifier.Put(subSectionMemStart, subSectionSize); 00307 file.Skip(subSectionSize); 00308 currentFilePos = subSectionFileStart + subSectionSize; 00309 subSectionStart = nextSubSectionStart; 00310 } while (nextSubSectionStart != 0); 00311 } 00312 phs++; 00313 } 00314 #endif 00315 file.TransferAllTo(verifier); 00316 00317 #ifdef CRYPTOPP_WIN32_AVAILABLE 00318 // if that fails (could be caused by debug breakpoints or DLL base relocation modifying image in memory), 00319 // hash from disk instead 00320 if (memcmp(expectedModuleMac, actualMac, macSize) != 0) 00321 { 00322 OutputDebugString("In memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n"); 00323 file.Initialize(MakeParameters("InputFileName", moduleFilename)); 00324 verifier.Detach(new ArraySink(actualMac, actualMac.size())); 00325 if (macFileLocation) 00326 { 00327 file.TransferTo(verifier, macFileLocation); 00328 file.Skip(macSize); 00329 } 00330 file.TransferAllTo(verifier); 00331 } 00332 #endif 00333 00334 if (memcmp(expectedModuleMac, actualMac, macSize) == 0) 00335 return true; 00336 00337 #ifdef CRYPTOPP_WIN32_AVAILABLE 00338 std::string hexMac; 00339 HexEncoder(new StringSink(hexMac)).PutMessageEnd(actualMac, actualMac.size()); 00340 OutputDebugString((moduleFilename + (" integrity check failed. Actual MAC is: " + hexMac) + "\n").c_str()); 00341 #endif 00342 return false; 00343 } 00344 00345 void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac) 00346 { 00347 g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_NOT_DONE; 00348 SetPowerUpSelfTestInProgressOnThisThread(true); 00349 00350 try 00351 { 00352 if (FIPS_140_2_ComplianceEnabled() || moduleFilename != NULL) 00353 { 00354 if (!IntegrityCheckModule(moduleFilename, expectedModuleMac, &g_actualMac, &g_macFileLocation)) 00355 throw 0; // throw here so we break in the debugger, this will be caught right away 00356 } 00357 00358 // algorithm tests 00359 00360 X917RNG_KnownAnswerTest<DES_EDE3>( 00361 "48851090B4992453E83CDA86416534E53EA2FCE1A0B3A40C", // key 00362 "7D00BD0A79F6B0F5", // seed 00363 "22B590B08B53363AEB89AD65F81A5B6FB83F326CE06BF35751E6C41B43B729C4", // output 00364 1489728269); // time vector 00365 00366 /* SymmetricEncryptionKnownAnswerTest<DES>( 00367 "0123456789abcdef", // key 00368 "1234567890abcdef", // IV 00369 "4e6f77206973207468652074696d6520666f7220616c6c20", // plaintext 00370 "3fa40e8a984d48156a271787ab8883f9893d51ec4b563b53", // ecb 00371 "E5C7CDDE872BF27C43E934008C389C0F683788499A7C05F6", // cbc 00372 "F3096249C7F46E51A69E839B1A92F78403467133898EA622", // cfb 00373 "f3096249c7f46e5135f24a242eeb3d3f3d6d5be3255af8c3", // ofb 00374 "F3096249C7F46E51163A8CA0FFC94C27FA2F80F480B86F75");// ctr 00375 */ 00376 SymmetricEncryptionKnownAnswerTest<DES_EDE3>( 00377 "385D7189A5C3D485E1370AA5D408082B5CCCCB5E19F2D90E", 00378 "C141B5FCCD28DC8A", 00379 "6E1BD7C6120947A464A6AAB293A0F89A563D8D40D3461B68", 00380 "64EAAD4ACBB9CEAD6C7615E7C7E4792FE587D91F20C7D2F4", 00381 "6235A461AFD312973E3B4F7AA7D23E34E03371F8E8C376C9", 00382 "E26BA806A59B0330DE40CA38E77A3E494BE2B212F6DD624B", 00383 "E26BA806A59B03307DE2BCC25A08BA40A8BA335F5D604C62", 00384 "E26BA806A59B03303C62C2EFF32D3ACDD5D5F35EBCC53371"); 00385 00386 SymmetricEncryptionKnownAnswerTest<SKIPJACK>( 00387 "1555E5531C3A169B2D65", 00388 "6EC9795701F49864", 00389 "00AFA48E9621E52E8CBDA312660184EDDB1F33D9DACDA8DA", 00390 "DBEC73562EFCAEB56204EB8AE9557EBF77473FBB52D17CD1", 00391 "0C7B0B74E21F99B8F2C8DF37879F6C044967F42A796DCA8B", 00392 "79FDDA9724E36CC2E023E9A5C717A8A8A7FDA465CADCBF63", 00393 "79FDDA9724E36CC26CACBD83C1ABC06EAF5B249BE5B1E040", 00394 "79FDDA9724E36CC211B0AEC607B95A96BCDA318440B82F49"); 00395 00396 SymmetricEncryptionKnownAnswerTest<AES>( 00397 "2b7e151628aed2a6abf7158809cf4f3c", 00398 "000102030405060708090a0b0c0d0e0f", 00399 "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710", // plaintext 00400 "3ad77bb40d7a3660a89ecaf32466ef97f5d3d58503b9699de785895a96fdbaaf43b1cd7f598ece23881b00e3ed0306887b0c785e27e8ad3f8223207104725dd4", // ecb 00401 "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a7", // cbc 00402 "3b3fd92eb72dad20333449f8e83cfb4ac8a64537a0b3a93fcde3cdad9f1ce58b26751f67a3cbb140b1808cf187a4f4dfc04b05357c5d1c0eeac4c66f9ff7f2e6", // cfb 00403 "3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e", // ofb 00404 NULL); 00405 00406 SymmetricEncryptionKnownAnswerTest<AES>( 00407 "2b7e151628aed2a6abf7158809cf4f3c", 00408 "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", 00409 "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710", 00410 NULL, 00411 NULL, 00412 NULL, 00413 NULL, 00414 "874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee"); // ctr 00415 00416 00417 SecureHashKnownAnswerTest<SHA>( 00418 "abc", 00419 "A9993E364706816ABA3E25717850C26C9CD0D89D"); 00420 /* 00421 SecureHashKnownAnswerTest<SHA256>( 00422 "abc", 00423 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"); 00424 00425 SecureHashKnownAnswerTest<SHA384>( 00426 "abc", 00427 "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"); 00428 00429 SecureHashKnownAnswerTest<SHA512>( 00430 "abc", 00431 "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); 00432 */ 00433 MAC_KnownAnswerTest<HMAC<SHA> >( 00434 "303132333435363738393a3b3c3d3e3f40414243", 00435 "Sample #2", 00436 "0922d3405faa3d194f82a45830737d5cc6c75d24"); 00437 /* 00438 MAC_KnownAnswerTest<HMAC<SHA256> >( 00439 "303132333435363738393a3b3c3d3e3f40414243", 00440 "abc", 00441 "D28363F335B2DAE468793A38680DEA9F7FB8BE1DCEDA197CDB3B1CB59A9F6422"); 00442 00443 MAC_KnownAnswerTest<HMAC<SHA384> >( 00444 "303132333435363738393a3b3c3d3e3f40414243", 00445 "abc", 00446 "E7740C592F1414C969190EFACF51FC8BE1CB52F5DC5E686200D2CA1773D151DB19C59112371CE374165A6BF72AEF69D0"); 00447 00448 MAC_KnownAnswerTest<HMAC<SHA512> >( 00449 "303132333435363738393a3b3c3d3e3f40414243", 00450 "abc", 00451 "BF07864E733B995862F3C2D432C7FF2F5EB073FFFC4F880CD94D5D21086476B7428F27BE694A9D9CB3BB500FE1255852BAFCBAF4042390B3706CDF02421B51AC"); 00452 */ 00453 SignatureKnownAnswerTest<RSASS<PKCS1v15, SHA> >( 00454 "30820150020100300d06092a864886f70d01010105000482013a3082013602010002400a66791dc6988168de7ab77419bb7fb0" 00455 "c001c62710270075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67cdc9a9af55d655620bbab0203010001" 00456 "02400123c5b61ba36edb1d3679904199a89ea80c09b9122e1400c09adcf7784676d01d23356a7d44d6bd8bd50e94bfc723fa" 00457 "87d8862b75177691c11d757692df8881022033d48445c859e52340de704bcdda065fbb4058d740bd1d67d29e9c146c11cf61" 00458 "0220335e8408866b0fd38dc7002d3f972c67389a65d5d8306566d5c4f2a5aa52628b0220045ec90071525325d3d46db79695e9af" 00459 "acc4523964360e02b119baa366316241022015eb327360c7b60d12e5e2d16bdcd97981d17fba6b70db13b20b436e24eada590220" 00460 "2ca6366d72781dfa24d34a9a24cbc2ae927a9958af426563ff63fb11658a461d", 00461 "Everyone gets Friday off.", 00462 "0610761F95FFD1B8F29DA34212947EC2AA0E358866A722F03CC3C41487ADC604A48FF54F5C6BEDB9FB7BD59F82D6E55D8F3174BA361B2214B2D74E8825E04E81"); 00463 00464 SignaturePairwiseConsistencyTest<DSA>( 00465 "3082014A0201003082012B06072A8648CE3804013082011E02818100F468699A6F6EBCC0120D3B34C8E007F125EC7D81F763B8D0F33869AE3BD6B9F2ECCC7DF34DF84C0307449E9B85D30D57194BCCEB310F48141914DD13A077AAF9B624A6CBE666BBA1D7EBEA95B5BA6F54417FD5D4E4220C601E071D316A24EA814E8B0122DBF47EE8AEEFD319EBB01DD95683F10DBB4FEB023F8262A07EAEB7FD02150082AD4E034DA6EEACDFDAE68C36F2BAD614F9E53B02818071AAF73361A26081529F7D84078ADAFCA48E031DB54AD57FB1A833ADBD8672328AABAA0C756247998D7A5B10DACA359D231332CE8120B483A784FE07D46EEBFF0D7D374A10691F78653E6DC29E27CCB1B174923960DFE5B959B919B2C3816C19251832AFD8E35D810E598F82877ABF7D40A041565168BD7F0E21E3FE2A8D8C1C0416021426EBA66E846E755169F84A1DA981D86502405DDF"); 00466 00467 SignaturePairwiseConsistencyTest<ECDSA<EC2N, SHA> >( 00468 "302D020100301006072A8648CE3D020106052B8104000404163014020101040F0070337065E1E196980A9D00E37211"); 00469 00470 SignaturePairwiseConsistencyTest<ECDSA<ECP, SHA> >( 00471 "3039020100301306072A8648CE3D020106082A8648CE3D030101041F301D02010104182BB8A13C8B867010BD9471D9E81FDB01ABD0538C64D6249A"); 00472 } 00473 catch (...) 00474 { 00475 g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_FAILED; 00476 goto done; 00477 } 00478 00479 g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_PASSED; 00480 00481 done: 00482 SetPowerUpSelfTestInProgressOnThisThread(false); 00483 return; 00484 } 00485 00486 #ifdef CRYPTOPP_WIN32_AVAILABLE 00487 00488 static const byte s_moduleMac[CryptoPP::HMAC<CryptoPP::SHA1>::DIGESTSIZE] = "reserved for mac"; 00489 static HMODULE s_hModule = NULL; 00490 00491 void DoDllPowerUpSelfTest() 00492 { 00493 char moduleFileName[MAX_PATH]; 00494 GetModuleFileNameA(s_hModule, moduleFileName, sizeof(moduleFileName)); 00495 CryptoPP::DoPowerUpSelfTest(moduleFileName, s_moduleMac); 00496 } 00497 00498 #else 00499 00500 void DoDllPowerUpSelfTest() 00501 { 00502 throw NotImplemented("DoDllPowerUpSelfTest() only available on Windows"); 00503 } 00504 00505 #endif // #ifdef CRYPTOPP_WIN32_AVAILABLE 00506 00507 NAMESPACE_END 00508 00509 #ifdef CRYPTOPP_WIN32_AVAILABLE 00510 00511 // DllMain needs to be in the global namespace 00512 BOOL APIENTRY DllMain(HANDLE hModule, 00513 DWORD ul_reason_for_call, 00514 LPVOID lpReserved) 00515 { 00516 if (ul_reason_for_call == DLL_PROCESS_ATTACH) 00517 { 00518 CryptoPP::s_hModule = (HMODULE)hModule; 00519 CryptoPP::DoDllPowerUpSelfTest(); 00520 } 00521 return TRUE; 00522 } 00523 00524 #endif // #ifdef CRYPTOPP_WIN32_AVAILABLE 00525 00526 #endif // #ifndef CRYPTOPP_IMPORTS

Generated on Fri Aug 27 11:32:36 2004 for Crypto++ by doxygen 1.3.8