~zooko/cryptopp/trunk

« back to all changes in this revision

Viewing changes to fipstest.cpp

  • Committer: weidai
  • Date: 2010-06-18 01:52:34 UTC
  • Revision ID: svn-v4:57ff6487-cd31-0410-9ec3-f628ee90f5f0:trunk/c5:485
avoid SecBlock of arrays

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
#define _WIN32_WINNT 0x0400
12
12
#include <windows.h>
13
13
 
14
 
#if defined(_MSC_VER) && _MSC_VER >= 14
 
14
#if defined(_MSC_VER) && _MSC_VER >= 1400
15
15
#ifdef _M_IX86
16
16
#define _CRT_DEBUGGER_HOOK _crt_debugger_hook
17
17
#else
21
21
#endif
22
22
#endif
23
23
 
 
24
#include <iostream>
 
25
 
24
26
NAMESPACE_BEGIN(CryptoPP)
25
27
 
26
28
extern PowerUpSelfTestStatus g_powerUpSelfTestStatus;
153
155
void SignatureKnownAnswerTest(const char *key, const char *message, const char *signature, SCHEME *dummy = NULL)
154
156
{
155
157
#ifdef OS_RNG_AVAILABLE
156
 
        AutoSeededX917RNG<DES_EDE3> rng;
 
158
        DefaultAutoSeededRNG rng;
157
159
#else
158
160
        RandomNumberGenerator &rng = NullRNG();
159
161
#endif
179
181
        try
180
182
        {
181
183
#ifdef OS_RNG_AVAILABLE
182
 
                AutoSeededX917RNG<DES_EDE3> rng;
 
184
                DefaultAutoSeededRNG rng;
183
185
#else
184
186
                RandomNumberGenerator &rng = NullRNG();
185
187
#endif
219
221
        try
220
222
        {
221
223
#ifdef OS_RNG_AVAILABLE
222
 
                AutoSeededX917RNG<DES_EDE3> rng;
 
224
                DefaultAutoSeededRNG rng;
223
225
#else
224
226
                RandomNumberGenerator &rng = NullRNG();
225
227
#endif
277
279
        char moduleFilenameBuf[MAX_PATH] = "";
278
280
        if (moduleFilename == NULL)
279
281
        {
280
 
#ifdef _MSC_VER         // ifstream doesn't support wide filename on gcc 3.4.4 cygwin
 
282
#if (_MSC_VER >= 1400 && !defined(_STLPORT_VERSION))    // ifstream doesn't support wide filename on other compilers
281
283
                wchar_t wideModuleFilename[MAX_PATH];
282
284
                if (GetModuleFileNameW(s_hModule, wideModuleFilename, MAX_PATH) > 0)
283
285
                {
363
365
                                        }
364
366
                                }
365
367
 
366
 
#if defined(_MSC_VER) && _MSC_VER >= 14
 
368
#if defined(_MSC_VER) && _MSC_VER >= 1400
367
369
                                // first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file
368
370
                                if (IsDebuggerPresent())
369
371
                                {
397
399
#ifdef CRYPTOPP_WIN32_AVAILABLE
398
400
        // if that fails (could be caused by debug breakpoints or DLL base relocation modifying image in memory),
399
401
        // hash from disk instead
400
 
        if (memcmp(expectedModuleMac, actualMac, macSize) != 0)
 
402
        if (!VerifyBufsEqual(expectedModuleMac, actualMac, macSize))
401
403
        {
402
404
                OutputDebugString("In memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n");
403
405
                moduleStream.clear();
412
414
        }
413
415
#endif
414
416
 
415
 
        if (memcmp(expectedModuleMac, actualMac, macSize) == 0)
 
417
        if (VerifyBufsEqual(expectedModuleMac, actualMac, macSize))
416
418
                return true;
417
419
 
418
420
#ifdef CRYPTOPP_WIN32_AVAILABLE
438
440
 
439
441
                // algorithm tests
440
442
 
441
 
                X917RNG_KnownAnswerTest<DES_EDE3>(
442
 
                        "48851090B4992453E83CDA86416534E53EA2FCE1A0B3A40C",                                             // key
443
 
                        "7D00BD0A79F6B0F5",                                                                                                             // seed
444
 
                        "0000000000000001",                                                                                                             // time vector
445
 
                        "fdc31a6dd6b43aca81dfe8a696a2f9cf661955a44124a05033b7fff71b5b0341");    // output
 
443
                X917RNG_KnownAnswerTest<AES>(
 
444
                        "2b7e151628aed2a6abf7158809cf4f3c",                                                                             // key
 
445
                        "000102030405060708090a0b0c0d0e0f",                                                                             // seed
 
446
                        "00000000000000000000000000000001",                                                                             // time vector
 
447
                        "D176EDD27493B0395F4D10546232B0693DC7061C03C3A554F09CECF6F6B46D945A");  // output
446
448
 
447
449
                SymmetricEncryptionKnownAnswerTest<DES_EDE3>(
448
450
                        "385D7189A5C3D485E1370AA5D408082B5CCCCB5E19F2D90E",