Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 23e07fd43e778a61ff4b78161a3e2389 > files > 1745

cryptopp-doc-5.6.1-5.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Crypto++: fipstest.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Crypto++</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">fipstest.cpp</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// fipstest.cpp - written and placed in the public domain by Wei Dai</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;pch.h&quot;</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span>
<a name="l00007"></a>00007 <span class="preprocessor">#define CRYPTOPP_DEFAULT_NO_DLL</span>
<a name="l00008"></a>00008 <span class="preprocessor"></span><span class="preprocessor">#include &quot;dll.h&quot;</span>
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00011"></a>00011 <span class="preprocessor"></span><span class="preprocessor">#define _WIN32_WINNT 0x0400</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#include &lt;windows.h&gt;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#if defined(_MSC_VER) &amp;&amp; _MSC_VER &gt;= 1400</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#ifdef _M_IX86</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define _CRT_DEBUGGER_HOOK _crt_debugger_hook</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define _CRT_DEBUGGER_HOOK __crt_debugger_hook</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {_CRTIMP <span class="keywordtype">void</span> __cdecl _CRT_DEBUGGER_HOOK(<span class="keywordtype">int</span>);}
<a name="l00021"></a>00021 <span class="preprocessor">#endif</span>
<a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00023"></a>00023 <span class="preprocessor"></span>
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 NAMESPACE_BEGIN(CryptoPP)
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 extern <a class="code" href="fips140_8h.html#a8ccac50ac3bfc5abaa6cb457f0ded35d" title="enum values representing status of the power-up self test">PowerUpSelfTestStatus</a> g_powerUpSelfTestStatus;
<a name="l00029"></a>00029 <a class="code" href="class_sec_block.html">SecByteBlock</a> g_actualMac;
<a name="l00030"></a>00030 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> g_macFileLocation = 0;
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="comment">// use a random dummy string here, to be searched/replaced later with the real MAC</span>
<a name="l00033"></a>00033 static const byte s_moduleMac[CryptoPP::<a class="code" href="class_h_m_a_c.html" title="HMAC">HMAC</a>&lt;CryptoPP::<a class="code" href="class_s_h_a1.html" title="SHA-1">SHA1</a>&gt;::DIGESTSIZE] = CRYPTOPP_DUMMY_DLL_MAC;
<a name="l00034"></a>00034 CRYPTOPP_COMPILE_ASSERT(sizeof(s_moduleMac) == CryptoPP::<a class="code" href="class_s_h_a1.html" title="SHA-1">SHA1</a>::DIGESTSIZE);
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="keyword">static</span> HMODULE s_hModule = NULL;
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
<a name="l00039"></a>00039 <span class="preprocessor"></span>
<a name="l00040"></a>00040 <span class="keyword">const</span> byte * CRYPTOPP_API GetActualMacAndLocation(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> &amp;macSize, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> &amp;fileLocation)
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042         macSize = (<span class="keywordtype">unsigned</span> int)g_actualMac.size();
<a name="l00043"></a>00043         fileLocation = g_macFileLocation;
<a name="l00044"></a>00044         <span class="keywordflow">return</span> g_actualMac;
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 <span class="keywordtype">void</span> KnownAnswerTest(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <span class="keyword">const</span> <span class="keywordtype">char</span> *output)
<a name="l00048"></a>00048 {
<a name="l00049"></a>00049         <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a> comparison;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051         <a class="code" href="class_random_number_store.html" title="RNG-based implementation of Source interface.">RandomNumberStore</a>(rng, strlen(output)/2).TransferAllTo(comparison, <span class="stringliteral">&quot;0&quot;</span>);
<a name="l00052"></a>00052         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(output, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;1&quot;</span>)));
<a name="l00053"></a>00053 
<a name="l00054"></a>00054         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;0&quot;</span>);
<a name="l00055"></a>00055         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;1&quot;</span>);
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058 <span class="keyword">template</span> &lt;<span class="keyword">class</span> CIPHER&gt;
<a name="l00059"></a>00059 <span class="keywordtype">void</span> X917RNG_KnownAnswerTest(
<a name="l00060"></a>00060         <span class="keyword">const</span> <span class="keywordtype">char</span> *key, 
<a name="l00061"></a>00061         <span class="keyword">const</span> <span class="keywordtype">char</span> *seed, 
<a name="l00062"></a>00062         <span class="keyword">const</span> <span class="keywordtype">char</span> *deterministicTimeVector,
<a name="l00063"></a>00063         <span class="keyword">const</span> <span class="keywordtype">char</span> *output,
<a name="l00064"></a>00064         CIPHER *dummy = NULL)
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066 <span class="preprocessor">#ifdef OS_RNG_AVAILABLE</span>
<a name="l00067"></a>00067 <span class="preprocessor"></span>        std::string decodedKey, decodedSeed, decodedDeterministicTimeVector;
<a name="l00068"></a>00068         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(key, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(decodedKey)));
<a name="l00069"></a>00069         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(seed, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(decodedSeed)));
<a name="l00070"></a>00070         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(deterministicTimeVector, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(decodedDeterministicTimeVector)));
<a name="l00071"></a>00071 
<a name="l00072"></a>00072         <a class="code" href="class_auto_seeded_x917_r_n_g.html" title="RNG from ANSI X9.17 Appendix C, seeded using an OS provided RNG.">AutoSeededX917RNG&lt;CIPHER&gt;</a> rng(<span class="keyword">false</span>, <span class="keyword">false</span>);
<a name="l00073"></a>00073         rng.Reseed((<span class="keyword">const</span> byte *)decodedKey.data(), decodedKey.size(), (<span class="keyword">const</span> byte *)decodedSeed.data(), (<span class="keyword">const</span> byte *)decodedDeterministicTimeVector.data());
<a name="l00074"></a>00074         KnownAnswerTest(rng, output);
<a name="l00075"></a>00075 <span class="preprocessor">#else</span>
<a name="l00076"></a>00076 <span class="preprocessor"></span>        <span class="keywordflow">throw</span> 0;
<a name="l00077"></a>00077 <span class="preprocessor">#endif</span>
<a name="l00078"></a>00078 <span class="preprocessor"></span>}
<a name="l00079"></a>00079 
<a name="l00080"></a>00080 <span class="keywordtype">void</span> KnownAnswerTest(<a class="code" href="class_stream_transformation.html" title="interface for the data processing part of stream ciphers">StreamTransformation</a> &amp;encryption, <a class="code" href="class_stream_transformation.html" title="interface for the data processing part of stream ciphers">StreamTransformation</a> &amp;decryption, <span class="keyword">const</span> <span class="keywordtype">char</span> *plaintext, <span class="keyword">const</span> <span class="keywordtype">char</span> *ciphertext)
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082         <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a> comparison;
<a name="l00083"></a>00083 
<a name="l00084"></a>00084         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(plaintext, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_stream_transformation_filter.html" title="Filter Wrapper for StreamTransformation, optionally handling padding/unpadding when needed...">StreamTransformationFilter</a>(encryption, <span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;0&quot;</span>), StreamTransformationFilter::NO_PADDING)));
<a name="l00085"></a>00085         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(ciphertext, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;1&quot;</span>)));
<a name="l00086"></a>00086 
<a name="l00087"></a>00087         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(ciphertext, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_stream_transformation_filter.html" title="Filter Wrapper for StreamTransformation, optionally handling padding/unpadding when needed...">StreamTransformationFilter</a>(decryption, <span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;0&quot;</span>), StreamTransformationFilter::NO_PADDING)));
<a name="l00088"></a>00088         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(plaintext, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;1&quot;</span>)));
<a name="l00089"></a>00089 
<a name="l00090"></a>00090         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;0&quot;</span>);
<a name="l00091"></a>00091         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;1&quot;</span>);
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 <span class="keyword">template</span> &lt;<span class="keyword">class</span> CIPHER&gt;
<a name="l00095"></a>00095 <span class="keywordtype">void</span> SymmetricEncryptionKnownAnswerTest(
<a name="l00096"></a>00096         <span class="keyword">const</span> <span class="keywordtype">char</span> *key, 
<a name="l00097"></a>00097         <span class="keyword">const</span> <span class="keywordtype">char</span> *hexIV, 
<a name="l00098"></a>00098         <span class="keyword">const</span> <span class="keywordtype">char</span> *plaintext, 
<a name="l00099"></a>00099         <span class="keyword">const</span> <span class="keywordtype">char</span> *ecb,
<a name="l00100"></a>00100         <span class="keyword">const</span> <span class="keywordtype">char</span> *cbc,
<a name="l00101"></a>00101         <span class="keyword">const</span> <span class="keywordtype">char</span> *cfb,
<a name="l00102"></a>00102         <span class="keyword">const</span> <span class="keywordtype">char</span> *ofb,
<a name="l00103"></a>00103         <span class="keyword">const</span> <span class="keywordtype">char</span> *ctr,
<a name="l00104"></a>00104         CIPHER *dummy = NULL)
<a name="l00105"></a>00105 {
<a name="l00106"></a>00106         std::string decodedKey;
<a name="l00107"></a>00107         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(key, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(decodedKey)));
<a name="l00108"></a>00108 
<a name="l00109"></a>00109         <span class="keyword">typename</span> CIPHER::Encryption encryption((<span class="keyword">const</span> byte *)decodedKey.data(), decodedKey.size());
<a name="l00110"></a>00110         <span class="keyword">typename</span> CIPHER::Decryption decryption((<span class="keyword">const</span> byte *)decodedKey.data(), decodedKey.size());
<a name="l00111"></a>00111 
<a name="l00112"></a>00112         <a class="code" href="class_sec_block.html">SecByteBlock</a> iv(encryption.BlockSize());
<a name="l00113"></a>00113         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(hexIV, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_array_sink.html" title="Copy input to a memory buffer.">ArraySink</a>(iv, iv.size())));
<a name="l00114"></a>00114 
<a name="l00115"></a>00115         <span class="keywordflow">if</span> (ecb)
<a name="l00116"></a>00116                 KnownAnswerTest(<a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">ECB_Mode_ExternalCipher::Encryption</a>(encryption).Ref(), <a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">ECB_Mode_ExternalCipher::Decryption</a>(decryption).Ref(), plaintext, ecb);
<a name="l00117"></a>00117         <span class="keywordflow">if</span> (cbc)
<a name="l00118"></a>00118                 KnownAnswerTest(<a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">CBC_Mode_ExternalCipher::Encryption</a>(encryption, iv).Ref(), <a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">CBC_Mode_ExternalCipher::Decryption</a>(decryption, iv).Ref(), plaintext, cbc);
<a name="l00119"></a>00119         <span class="keywordflow">if</span> (cfb)
<a name="l00120"></a>00120                 KnownAnswerTest(<a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">CFB_Mode_ExternalCipher::Encryption</a>(encryption, iv).Ref(), <a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">CFB_Mode_ExternalCipher::Decryption</a>(encryption, iv).Ref(), plaintext, cfb);
<a name="l00121"></a>00121         <span class="keywordflow">if</span> (ofb)
<a name="l00122"></a>00122                 KnownAnswerTest(<a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">OFB_Mode_ExternalCipher::Encryption</a>(encryption, iv).Ref(), <a class="code" href="class_cipher_mode_final_template___external_cipher.html" title="_">OFB_Mode_ExternalCipher::Decryption</a>(encryption, iv).Ref(), plaintext, ofb);
<a name="l00123"></a>00123         <span class="keywordflow">if</span> (ctr)
<a name="l00124"></a>00124                 KnownAnswerTest(<a class="code" href="class_cipher_mode_final_template___external_cipher.html">CTR_Mode_ExternalCipher::Encryption</a>(encryption, iv).Ref(), <a class="code" href="class_cipher_mode_final_template___external_cipher.html">CTR_Mode_ExternalCipher::Decryption</a>(encryption, iv).Ref(), plaintext, ctr);
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127 <span class="keywordtype">void</span> KnownAnswerTest(<a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> &amp;hash, <span class="keyword">const</span> <span class="keywordtype">char</span> *message, <span class="keyword">const</span> <span class="keywordtype">char</span> *digest)
<a name="l00128"></a>00128 {
<a name="l00129"></a>00129         <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a> comparison;
<a name="l00130"></a>00130         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(digest, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;1&quot;</span>)));
<a name="l00131"></a>00131         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(message, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hash_filter.html" title="Filter Wrapper for HashTransformation.">HashFilter</a>(hash, <span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;0&quot;</span>)));
<a name="l00132"></a>00132 
<a name="l00133"></a>00133         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;0&quot;</span>);
<a name="l00134"></a>00134         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;1&quot;</span>);
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 <span class="keyword">template</span> &lt;<span class="keyword">class</span> HASH&gt;
<a name="l00138"></a>00138 <span class="keywordtype">void</span> SecureHashKnownAnswerTest(<span class="keyword">const</span> <span class="keywordtype">char</span> *message, <span class="keyword">const</span> <span class="keywordtype">char</span> *digest, HASH *dummy = NULL)
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140         HASH hash;
<a name="l00141"></a>00141         KnownAnswerTest(hash, message, digest);
<a name="l00142"></a>00142 }
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 <span class="keyword">template</span> &lt;<span class="keyword">class</span> MAC&gt;
<a name="l00145"></a>00145 <span class="keywordtype">void</span> MAC_KnownAnswerTest(<span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *message, <span class="keyword">const</span> <span class="keywordtype">char</span> *digest, MAC *dummy = NULL)
<a name="l00146"></a>00146 {
<a name="l00147"></a>00147         std::string decodedKey;
<a name="l00148"></a>00148         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(key, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(decodedKey)));
<a name="l00149"></a>00149 
<a name="l00150"></a>00150         MAC mac((<span class="keyword">const</span> byte *)decodedKey.data(), decodedKey.size());
<a name="l00151"></a>00151         KnownAnswerTest(mac, message, digest);
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <span class="keyword">template</span> &lt;<span class="keyword">class</span> SCHEME&gt;
<a name="l00155"></a>00155 <span class="keywordtype">void</span> SignatureKnownAnswerTest(<span class="keyword">const</span> <span class="keywordtype">char</span> *key, <span class="keyword">const</span> <span class="keywordtype">char</span> *message, <span class="keyword">const</span> <span class="keywordtype">char</span> *signature, SCHEME *dummy = NULL)
<a name="l00156"></a>00156 {
<a name="l00157"></a>00157         <span class="keyword">typename</span> SCHEME::Signer signer(<a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(key, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>).Ref());
<a name="l00158"></a>00158         <span class="keyword">typename</span> SCHEME::Verifier verifier(signer);
<a name="l00159"></a>00159 
<a name="l00160"></a>00160         <a class="code" href="class_random_pool.html" title="Randomness Pool.">RandomPool</a> rng;
<a name="l00161"></a>00161         <a class="code" href="class_equality_comparison_filter.html" title="A filter that checks messages on two channels for equality.">EqualityComparisonFilter</a> comparison;
<a name="l00162"></a>00162 
<a name="l00163"></a>00163         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(message, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_signer_filter.html" title="Filter Wrapper for PK_Signer.">SignerFilter</a>(rng, signer, <span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;0&quot;</span>)));
<a name="l00164"></a>00164         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(signature, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_channel_switch.html" title="Route input to different and/or multiple channels based on channel ID.">ChannelSwitch</a>(comparison, <span class="stringliteral">&quot;1&quot;</span>)));
<a name="l00165"></a>00165 
<a name="l00166"></a>00166         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;0&quot;</span>);
<a name="l00167"></a>00167         comparison.ChannelMessageSeriesEnd(<span class="stringliteral">&quot;1&quot;</span>);
<a name="l00168"></a>00168 
<a name="l00169"></a>00169         <a class="code" href="class_signature_verification_filter.html" title="Filter Wrapper for PK_Verifier.">VerifierFilter</a> verifierFilter(verifier, NULL, VerifierFilter::SIGNATURE_AT_BEGIN | VerifierFilter::THROW_EXCEPTION);
<a name="l00170"></a>00170         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(signature, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>(<span class="keyword">new</span> <a class="code" href="class_redirector.html" title="Redirect input to another BufferedTransformation without owning it.">Redirector</a>(verifierFilter, Redirector::DATA_ONLY)));
<a name="l00171"></a>00171         <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(message, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_redirector.html" title="Redirect input to another BufferedTransformation without owning it.">Redirector</a>(verifierFilter));
<a name="l00172"></a>00172 }
<a name="l00173"></a>00173 
<a name="l00174"></a>00174 <span class="keywordtype">void</span> EncryptionPairwiseConsistencyTest(<span class="keyword">const</span> <a class="code" href="class_p_k___encryptor.html" title="interface for public-key encryptors">PK_Encryptor</a> &amp;encryptor, <span class="keyword">const</span> <a class="code" href="class_p_k___decryptor.html" title="interface for public-key decryptors">PK_Decryptor</a> &amp;decryptor)
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176         <span class="keywordflow">try</span>
<a name="l00177"></a>00177         {
<a name="l00178"></a>00178                 <a class="code" href="class_random_pool.html" title="Randomness Pool.">RandomPool</a> rng;
<a name="l00179"></a>00179                 <span class="keyword">const</span> <span class="keywordtype">char</span> *testMessage =<span class="stringliteral">&quot;test message&quot;</span>;
<a name="l00180"></a>00180                 std::string ciphertext, decrypted;
<a name="l00181"></a>00181 
<a name="l00182"></a>00182                 <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(
<a name="l00183"></a>00183                         testMessage, 
<a name="l00184"></a>00184                         <span class="keyword">true</span>, 
<a name="l00185"></a>00185                         <span class="keyword">new</span> <a class="code" href="class_p_k___encryptor_filter.html" title="proxy for the filter created by PK_Encryptor::CreateEncryptionFilter">PK_EncryptorFilter</a>(
<a name="l00186"></a>00186                                 rng, 
<a name="l00187"></a>00187                                 encryptor, 
<a name="l00188"></a>00188                                 <span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(ciphertext)));
<a name="l00189"></a>00189 
<a name="l00190"></a>00190                 <span class="keywordflow">if</span> (ciphertext == testMessage)
<a name="l00191"></a>00191                         <span class="keywordflow">throw</span> 0;
<a name="l00192"></a>00192 
<a name="l00193"></a>00193                 <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(
<a name="l00194"></a>00194                         ciphertext, 
<a name="l00195"></a>00195                         <span class="keyword">true</span>, 
<a name="l00196"></a>00196                         <span class="keyword">new</span> <a class="code" href="class_p_k___decryptor_filter.html" title="proxy for the filter created by PK_Decryptor::CreateDecryptionFilter">PK_DecryptorFilter</a>(
<a name="l00197"></a>00197                                 rng, 
<a name="l00198"></a>00198                                 decryptor, 
<a name="l00199"></a>00199                                 <span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(decrypted)));
<a name="l00200"></a>00200 
<a name="l00201"></a>00201                 <span class="keywordflow">if</span> (decrypted != testMessage)
<a name="l00202"></a>00202                         <span class="keywordflow">throw</span> 0;
<a name="l00203"></a>00203         }
<a name="l00204"></a>00204         <span class="keywordflow">catch</span> (...)
<a name="l00205"></a>00205         {
<a name="l00206"></a>00206                 <span class="keywordflow">throw</span> <a class="code" href="class_self_test_failure.html" title="exception thrown when a crypto algorithm is used after a self test fails">SelfTestFailure</a>(encryptor.<a class="code" href="class_algorithm.html#acd21c6715add4884fa043eaf51655039" title="returns name of this algorithm, not universally implemented yet">AlgorithmName</a>() + <span class="stringliteral">&quot;: pairwise consistency test failed&quot;</span>);
<a name="l00207"></a>00207         }
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209 
<a name="l00210"></a>00210 <span class="keywordtype">void</span> SignaturePairwiseConsistencyTest(<span class="keyword">const</span> <a class="code" href="class_p_k___signer.html" title="interface for public-key signers">PK_Signer</a> &amp;signer, <span class="keyword">const</span> <a class="code" href="class_p_k___verifier.html" title="interface for public-key signature verifiers">PK_Verifier</a> &amp;verifier)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212         <span class="keywordflow">try</span>
<a name="l00213"></a>00213         {
<a name="l00214"></a>00214                 <a class="code" href="class_random_pool.html" title="Randomness Pool.">RandomPool</a> rng;
<a name="l00215"></a>00215 
<a name="l00216"></a>00216                 <a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(
<a name="l00217"></a>00217                         <span class="stringliteral">&quot;test message&quot;</span>, 
<a name="l00218"></a>00218                         <span class="keyword">true</span>, 
<a name="l00219"></a>00219                         <span class="keyword">new</span> <a class="code" href="class_signer_filter.html" title="Filter Wrapper for PK_Signer.">SignerFilter</a>(
<a name="l00220"></a>00220                                 rng, 
<a name="l00221"></a>00221                                 signer, 
<a name="l00222"></a>00222                                 <span class="keyword">new</span> <a class="code" href="class_signature_verification_filter.html" title="Filter Wrapper for PK_Verifier.">VerifierFilter</a>(verifier, NULL, VerifierFilter::THROW_EXCEPTION),
<a name="l00223"></a>00223                                 <span class="keyword">true</span>));
<a name="l00224"></a>00224         }
<a name="l00225"></a>00225         <span class="keywordflow">catch</span> (...)
<a name="l00226"></a>00226         {
<a name="l00227"></a>00227                 <span class="keywordflow">throw</span> <a class="code" href="class_self_test_failure.html" title="exception thrown when a crypto algorithm is used after a self test fails">SelfTestFailure</a>(signer.<a class="code" href="class_algorithm.html#acd21c6715add4884fa043eaf51655039" title="returns name of this algorithm, not universally implemented yet">AlgorithmName</a>() + <span class="stringliteral">&quot;: pairwise consistency test failed&quot;</span>);
<a name="l00228"></a>00228         }
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230 
<a name="l00231"></a>00231 <span class="keyword">template</span> &lt;<span class="keyword">class</span> SCHEME&gt;
<a name="l00232"></a>00232 <span class="keywordtype">void</span> SignaturePairwiseConsistencyTest(<span class="keyword">const</span> <span class="keywordtype">char</span> *key, SCHEME *dummy = NULL)
<a name="l00233"></a>00233 {
<a name="l00234"></a>00234         <span class="keyword">typename</span> SCHEME::Signer signer(<a class="code" href="class_string_source.html" title="string-based implementation of Source interface">StringSource</a>(key, <span class="keyword">true</span>, <span class="keyword">new</span> <a class="code" href="class_hex_decoder.html" title="Decode base 16 data back to bytes.">HexDecoder</a>).Ref());
<a name="l00235"></a>00235         <span class="keyword">typename</span> SCHEME::Verifier verifier(signer);
<a name="l00236"></a>00236 
<a name="l00237"></a>00237         SignaturePairwiseConsistencyTest(signer, verifier);
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 <a class="code" href="class_message_authentication_code.html" title="interface for message authentication codes">MessageAuthenticationCode</a> * NewIntegrityCheckingMAC()
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242         byte key[] = {0x47, 0x1E, 0x33, 0x96, 0x65, 0xB1, 0x6A, 0xED, 0x0B, 0xF8, 0x6B, 0xFD, 0x01, 0x65, 0x05, 0xCC};
<a name="l00243"></a>00243         <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_h_m_a_c.html" title="HMAC">HMAC&lt;SHA1&gt;</a>(key, <span class="keyword">sizeof</span>(key));
<a name="l00244"></a>00244 }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 <span class="keywordtype">bool</span> IntegrityCheckModule(<span class="keyword">const</span> <span class="keywordtype">char</span> *moduleFilename, <span class="keyword">const</span> byte *expectedModuleMac, <a class="code" href="class_sec_block.html">SecByteBlock</a> *pActualMac, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> *pMacFileLocation)
<a name="l00247"></a>00247 {
<a name="l00248"></a>00248         std::auto_ptr&lt;MessageAuthenticationCode&gt; mac(NewIntegrityCheckingMAC());
<a name="l00249"></a>00249         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> macSize = mac-&gt;DigestSize();
<a name="l00250"></a>00250 
<a name="l00251"></a>00251         <a class="code" href="class_sec_block.html">SecByteBlock</a> tempMac;
<a name="l00252"></a>00252         <a class="code" href="class_sec_block.html">SecByteBlock</a> &amp;actualMac = pActualMac ? *pActualMac : tempMac;
<a name="l00253"></a>00253         actualMac.<a class="code" href="class_sec_block.html#af9e98d3f4a7af1156fcf3e6e68f4ae5a" title="change size and preserve contents">resize</a>(macSize);
<a name="l00254"></a>00254 
<a name="l00255"></a>00255         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> tempLocation;
<a name="l00256"></a>00256         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> &amp;macFileLocation = pMacFileLocation ? *pMacFileLocation : tempLocation;
<a name="l00257"></a>00257         macFileLocation = 0;
<a name="l00258"></a>00258 
<a name="l00259"></a>00259         <a class="code" href="class_meter_filter.html" title="measure how many byte and messages pass through, also serves as valve">MeterFilter</a> verifier(<span class="keyword">new</span> <a class="code" href="class_hash_filter.html" title="Filter Wrapper for HashTransformation.">HashFilter</a>(*mac, <span class="keyword">new</span> <a class="code" href="class_array_sink.html" title="Copy input to a memory buffer.">ArraySink</a>(actualMac, actualMac.size())));
<a name="l00260"></a>00260 <span class="comment">//      MeterFilter verifier(new FileSink(&quot;c:\\dt.tmp&quot;));</span>
<a name="l00261"></a>00261         std::ifstream moduleStream;
<a name="l00262"></a>00262 
<a name="l00263"></a>00263 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00264"></a>00264 <span class="preprocessor"></span>        HMODULE h;
<a name="l00265"></a>00265         {
<a name="l00266"></a>00266         <span class="keywordtype">char</span> moduleFilenameBuf[MAX_PATH] = <span class="stringliteral">&quot;&quot;</span>;
<a name="l00267"></a>00267         <span class="keywordflow">if</span> (moduleFilename == NULL)
<a name="l00268"></a>00268         {
<a name="l00269"></a>00269 <span class="preprocessor">#if (_MSC_VER &gt;= 1400 &amp;&amp; !defined(_STLPORT_VERSION))    // ifstream doesn&#39;t support wide filename on other compilers</span>
<a name="l00270"></a>00270 <span class="preprocessor"></span>                <span class="keywordtype">wchar_t</span> wideModuleFilename[MAX_PATH];
<a name="l00271"></a>00271                 <span class="keywordflow">if</span> (GetModuleFileNameW(s_hModule, wideModuleFilename, MAX_PATH) &gt; 0)
<a name="l00272"></a>00272                 {
<a name="l00273"></a>00273                         moduleStream.open(wideModuleFilename, std::ios::in | std::ios::binary);
<a name="l00274"></a>00274                         h = GetModuleHandleW(wideModuleFilename);
<a name="l00275"></a>00275                 }
<a name="l00276"></a>00276                 <span class="keywordflow">else</span>
<a name="l00277"></a>00277 <span class="preprocessor">#endif</span>
<a name="l00278"></a>00278 <span class="preprocessor"></span>                {
<a name="l00279"></a>00279                         GetModuleFileNameA(s_hModule, moduleFilenameBuf, MAX_PATH);
<a name="l00280"></a>00280                         moduleFilename = moduleFilenameBuf;
<a name="l00281"></a>00281                 }
<a name="l00282"></a>00282         }
<a name="l00283"></a>00283 <span class="preprocessor">#endif</span>
<a name="l00284"></a>00284 <span class="preprocessor"></span>        <span class="keywordflow">if</span> (moduleFilename != NULL)
<a name="l00285"></a>00285         {
<a name="l00286"></a>00286                         moduleStream.open(moduleFilename, std::ios::in | std::ios::binary);
<a name="l00287"></a>00287 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00288"></a>00288 <span class="preprocessor"></span>                        h = GetModuleHandleA(moduleFilename);
<a name="l00289"></a>00289                         moduleFilename = NULL;
<a name="l00290"></a>00290         }
<a name="l00291"></a>00291 <span class="preprocessor">#endif</span>
<a name="l00292"></a>00292 <span class="preprocessor"></span>        }
<a name="l00293"></a>00293 
<a name="l00294"></a>00294         <span class="keywordflow">if</span> (!moduleStream)
<a name="l00295"></a>00295         {
<a name="l00296"></a>00296 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00297"></a>00297 <span class="preprocessor"></span>                OutputDebugString(<span class="stringliteral">&quot;Crypto++ DLL integrity check failed. Cannot open file for reading.&quot;</span>);
<a name="l00298"></a>00298 <span class="preprocessor">#endif</span>
<a name="l00299"></a>00299 <span class="preprocessor"></span>                <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00300"></a>00300         }
<a name="l00301"></a>00301         <a class="code" href="class_file_store.html" title="file-based implementation of Store interface">FileStore</a> file(moduleStream);
<a name="l00302"></a>00302 
<a name="l00303"></a>00303 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00304"></a>00304 <span class="preprocessor"></span>        <span class="comment">// try to hash from memory first</span>
<a name="l00305"></a>00305         <span class="keyword">const</span> byte *memBase = (<span class="keyword">const</span> byte *)h;
<a name="l00306"></a>00306         <span class="keyword">const</span> IMAGE_DOS_HEADER *ph = (IMAGE_DOS_HEADER *)memBase;
<a name="l00307"></a>00307         <span class="keyword">const</span> IMAGE_NT_HEADERS *phnt = (IMAGE_NT_HEADERS *)(memBase + ph-&gt;e_lfanew);
<a name="l00308"></a>00308         <span class="keyword">const</span> IMAGE_SECTION_HEADER *phs = IMAGE_FIRST_SECTION(phnt);
<a name="l00309"></a>00309         DWORD nSections = phnt-&gt;FileHeader.NumberOfSections;
<a name="l00310"></a>00310         <span class="keywordtype">size_t</span> currentFilePos = 0;
<a name="l00311"></a>00311 
<a name="l00312"></a>00312         <span class="keywordtype">size_t</span> checksumPos = (byte *)&amp;phnt-&gt;OptionalHeader.CheckSum - memBase;
<a name="l00313"></a>00313         <span class="keywordtype">size_t</span> checksumSize = <span class="keyword">sizeof</span>(phnt-&gt;OptionalHeader.CheckSum);
<a name="l00314"></a>00314         <span class="keywordtype">size_t</span> certificateTableDirectoryPos = (byte *)&amp;phnt-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] - memBase;
<a name="l00315"></a>00315         <span class="keywordtype">size_t</span> certificateTableDirectorySize = <span class="keyword">sizeof</span>(phnt-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]);
<a name="l00316"></a>00316         <span class="keywordtype">size_t</span> certificateTablePos = phnt-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress;
<a name="l00317"></a>00317         <span class="keywordtype">size_t</span> certificateTableSize = phnt-&gt;OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size;
<a name="l00318"></a>00318 
<a name="l00319"></a>00319         verifier.AddRangeToSkip(0, checksumPos, checksumSize);
<a name="l00320"></a>00320         verifier.AddRangeToSkip(0, certificateTableDirectoryPos, certificateTableDirectorySize);
<a name="l00321"></a>00321         verifier.AddRangeToSkip(0, certificateTablePos, certificateTableSize);
<a name="l00322"></a>00322 
<a name="l00323"></a>00323         <span class="keywordflow">while</span> (nSections--)
<a name="l00324"></a>00324         {
<a name="l00325"></a>00325                 <span class="keywordflow">switch</span> (phs-&gt;Characteristics)
<a name="l00326"></a>00326                 {
<a name="l00327"></a>00327                 <span class="keywordflow">default</span>:
<a name="l00328"></a>00328                         <span class="keywordflow">break</span>;
<a name="l00329"></a>00329                 <span class="keywordflow">case</span> IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ:
<a name="l00330"></a>00330                 <span class="keywordflow">case</span> IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ:
<a name="l00331"></a>00331                         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sectionSize = STDMIN(phs-&gt;SizeOfRawData, phs-&gt;Misc.VirtualSize);
<a name="l00332"></a>00332                         <span class="keyword">const</span> byte *sectionMemStart = memBase + phs-&gt;VirtualAddress;
<a name="l00333"></a>00333                         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sectionFileStart = phs-&gt;PointerToRawData;
<a name="l00334"></a>00334                         <span class="keywordtype">size_t</span> subSectionStart = 0, nextSubSectionStart;
<a name="l00335"></a>00335 
<a name="l00336"></a>00336                         <span class="keywordflow">do</span>
<a name="l00337"></a>00337                         {
<a name="l00338"></a>00338                                 <span class="keyword">const</span> byte *subSectionMemStart = sectionMemStart + subSectionStart;
<a name="l00339"></a>00339                                 <span class="keywordtype">size_t</span> subSectionFileStart = sectionFileStart + subSectionStart;
<a name="l00340"></a>00340                                 <span class="keywordtype">size_t</span> subSectionSize = sectionSize - subSectionStart;
<a name="l00341"></a>00341                                 nextSubSectionStart = 0;
<a name="l00342"></a>00342 
<a name="l00343"></a>00343                                 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> entriesToReadFromDisk[] = {IMAGE_DIRECTORY_ENTRY_IMPORT, IMAGE_DIRECTORY_ENTRY_IAT};
<a name="l00344"></a>00344                                 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;<span class="keyword">sizeof</span>(entriesToReadFromDisk)/<span class="keyword">sizeof</span>(entriesToReadFromDisk[0]); i++)
<a name="l00345"></a>00345                                 {
<a name="l00346"></a>00346                                         <span class="keyword">const</span> IMAGE_DATA_DIRECTORY &amp;entry = phnt-&gt;OptionalHeader.DataDirectory[entriesToReadFromDisk[i]];
<a name="l00347"></a>00347                                         <span class="keyword">const</span> byte *entryMemStart = memBase + entry.VirtualAddress;
<a name="l00348"></a>00348                                         <span class="keywordflow">if</span> (subSectionMemStart &lt;= entryMemStart &amp;&amp; entryMemStart &lt; subSectionMemStart + subSectionSize)
<a name="l00349"></a>00349                                         {
<a name="l00350"></a>00350                                                 subSectionSize = entryMemStart - subSectionMemStart;
<a name="l00351"></a>00351                                                 nextSubSectionStart = entryMemStart - sectionMemStart + entry.Size;
<a name="l00352"></a>00352                                         }
<a name="l00353"></a>00353                                 }
<a name="l00354"></a>00354 
<a name="l00355"></a>00355 <span class="preprocessor">#if defined(_MSC_VER) &amp;&amp; _MSC_VER &gt;= 1400</span>
<a name="l00356"></a>00356 <span class="preprocessor"></span>                                <span class="comment">// first byte of _CRT_DEBUGGER_HOOK gets modified in memory by the debugger invisibly, so read it from file</span>
<a name="l00357"></a>00357                                 <span class="keywordflow">if</span> (IsDebuggerPresent())
<a name="l00358"></a>00358                                 {
<a name="l00359"></a>00359                                         <span class="keywordflow">if</span> (subSectionMemStart &lt;= (byte *)&amp;_CRT_DEBUGGER_HOOK &amp;&amp; (byte *)&amp;_CRT_DEBUGGER_HOOK &lt; subSectionMemStart + subSectionSize)
<a name="l00360"></a>00360                                         {
<a name="l00361"></a>00361                                                 subSectionSize = (byte *)&amp;_CRT_DEBUGGER_HOOK - subSectionMemStart;
<a name="l00362"></a>00362                                                 nextSubSectionStart = (byte *)&amp;_CRT_DEBUGGER_HOOK - sectionMemStart + 1;
<a name="l00363"></a>00363                                         }
<a name="l00364"></a>00364                                 }
<a name="l00365"></a>00365 <span class="preprocessor">#endif</span>
<a name="l00366"></a>00366 <span class="preprocessor"></span>
<a name="l00367"></a>00367                                 <span class="keywordflow">if</span> (subSectionMemStart &lt;= expectedModuleMac &amp;&amp; expectedModuleMac &lt; subSectionMemStart + subSectionSize)
<a name="l00368"></a>00368                                 {
<a name="l00369"></a>00369                                         <span class="comment">// found stored MAC</span>
<a name="l00370"></a>00370                                         macFileLocation = (<span class="keywordtype">unsigned</span> long)(subSectionFileStart + (expectedModuleMac - subSectionMemStart));
<a name="l00371"></a>00371                                         verifier.AddRangeToSkip(0, macFileLocation, macSize);
<a name="l00372"></a>00372                                 }
<a name="l00373"></a>00373 
<a name="l00374"></a>00374                                 file.TransferTo(verifier, subSectionFileStart - currentFilePos);
<a name="l00375"></a>00375                                 verifier.Put(subSectionMemStart, subSectionSize);
<a name="l00376"></a>00376                                 file.Skip(subSectionSize);
<a name="l00377"></a>00377                                 currentFilePos = subSectionFileStart + subSectionSize;
<a name="l00378"></a>00378                                 subSectionStart = nextSubSectionStart;
<a name="l00379"></a>00379                         } <span class="keywordflow">while</span> (nextSubSectionStart != 0);
<a name="l00380"></a>00380                 }
<a name="l00381"></a>00381                 phs++;
<a name="l00382"></a>00382         }
<a name="l00383"></a>00383 <span class="preprocessor">#endif</span>
<a name="l00384"></a>00384 <span class="preprocessor"></span>        file.TransferAllTo(verifier);
<a name="l00385"></a>00385 
<a name="l00386"></a>00386 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00387"></a>00387 <span class="preprocessor"></span>        <span class="comment">// if that fails (could be caused by debug breakpoints or DLL base relocation modifying image in memory),</span>
<a name="l00388"></a>00388         <span class="comment">// hash from disk instead</span>
<a name="l00389"></a>00389         <span class="keywordflow">if</span> (!VerifyBufsEqual(expectedModuleMac, actualMac, macSize))
<a name="l00390"></a>00390         {
<a name="l00391"></a>00391                 OutputDebugString(<span class="stringliteral">&quot;In memory integrity check failed. This may be caused by debug breakpoints or DLL relocation.\n&quot;</span>);
<a name="l00392"></a>00392                 moduleStream.clear();
<a name="l00393"></a>00393                 moduleStream.seekg(0);
<a name="l00394"></a>00394                 verifier.Initialize(MakeParameters(<a class="code" href="namespace_name.html#a54b71c75bd8b50e8bddfacf1f7b7b338" title="ByteArrayParameter.">Name::OutputBuffer</a>(), <a class="code" href="class_byte_array_parameter.html">ByteArrayParameter</a>(actualMac, (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)actualMac.size())));
<a name="l00395"></a>00395 <span class="comment">//              verifier.Initialize(MakeParameters(Name::OutputFileName(), (const char *)&quot;c:\\dt2.tmp&quot;));</span>
<a name="l00396"></a>00396                 verifier.AddRangeToSkip(0, checksumPos, checksumSize);
<a name="l00397"></a>00397                 verifier.AddRangeToSkip(0, certificateTableDirectoryPos, certificateTableDirectorySize);
<a name="l00398"></a>00398                 verifier.AddRangeToSkip(0, certificateTablePos, certificateTableSize);
<a name="l00399"></a>00399                 verifier.AddRangeToSkip(0, macFileLocation, macSize);
<a name="l00400"></a>00400                 <a class="code" href="class_file_store.html" title="file-based implementation of Store interface">FileStore</a>(moduleStream).TransferAllTo(verifier);
<a name="l00401"></a>00401         }
<a name="l00402"></a>00402 <span class="preprocessor">#endif</span>
<a name="l00403"></a>00403 <span class="preprocessor"></span>
<a name="l00404"></a>00404         <span class="keywordflow">if</span> (VerifyBufsEqual(expectedModuleMac, actualMac, macSize))
<a name="l00405"></a>00405                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00406"></a>00406 
<a name="l00407"></a>00407 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00408"></a>00408 <span class="preprocessor"></span>        std::string hexMac;
<a name="l00409"></a>00409         <a class="code" href="class_hex_encoder.html" title="Converts given data to base 16.">HexEncoder</a>(<span class="keyword">new</span> <a class="code" href="class_string_sink_template.html" title="Append input to a string object.">StringSink</a>(hexMac)).PutMessageEnd(actualMac, actualMac.size());
<a name="l00410"></a>00410         OutputDebugString(((<span class="stringliteral">&quot;Crypto++ DLL integrity check failed. Actual MAC is: &quot;</span> + hexMac) + <span class="stringliteral">&quot;\n&quot;</span>).c_str());
<a name="l00411"></a>00411 <span class="preprocessor">#endif</span>
<a name="l00412"></a>00412 <span class="preprocessor"></span>        <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00413"></a>00413 }
<a name="l00414"></a>00414 
<a name="l00415"></a><a class="code" href="fips140_8h.html#ac4890bf392b8a421fb9288327a885a47">00415</a> <span class="keywordtype">void</span> <a class="code" href="fips140_8h.html#ac4890bf392b8a421fb9288327a885a47" title="perform the power-up self test, and set the self test status">DoPowerUpSelfTest</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *moduleFilename, <span class="keyword">const</span> byte *expectedModuleMac)
<a name="l00416"></a>00416 {
<a name="l00417"></a>00417         g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_NOT_DONE;
<a name="l00418"></a>00418         SetPowerUpSelfTestInProgressOnThisThread(<span class="keyword">true</span>);
<a name="l00419"></a>00419 
<a name="l00420"></a>00420         <span class="keywordflow">try</span>
<a name="l00421"></a>00421         {
<a name="l00422"></a>00422                 <span class="keywordflow">if</span> (FIPS_140_2_ComplianceEnabled() || expectedModuleMac != NULL)
<a name="l00423"></a>00423                 {
<a name="l00424"></a>00424                         <span class="keywordflow">if</span> (!IntegrityCheckModule(moduleFilename, expectedModuleMac, &amp;g_actualMac, &amp;g_macFileLocation))
<a name="l00425"></a>00425                                 <span class="keywordflow">throw</span> 0;        <span class="comment">// throw here so we break in the debugger, this will be caught right away</span>
<a name="l00426"></a>00426                 }
<a name="l00427"></a>00427 
<a name="l00428"></a>00428                 <span class="comment">// algorithm tests</span>
<a name="l00429"></a>00429 
<a name="l00430"></a>00430                 X917RNG_KnownAnswerTest&lt;AES&gt;(
<a name="l00431"></a>00431                         <span class="stringliteral">&quot;2b7e151628aed2a6abf7158809cf4f3c&quot;</span>,                                                                             <span class="comment">// key</span>
<a name="l00432"></a>00432                         <span class="stringliteral">&quot;000102030405060708090a0b0c0d0e0f&quot;</span>,                                                                             <span class="comment">// seed</span>
<a name="l00433"></a>00433                         <span class="stringliteral">&quot;00000000000000000000000000000001&quot;</span>,                                                                             <span class="comment">// time vector</span>
<a name="l00434"></a>00434                         <span class="stringliteral">&quot;D176EDD27493B0395F4D10546232B0693DC7061C03C3A554F09CECF6F6B46D945A&quot;</span>);  <span class="comment">// output</span>
<a name="l00435"></a>00435 
<a name="l00436"></a>00436                 SymmetricEncryptionKnownAnswerTest&lt;DES_EDE3&gt;(
<a name="l00437"></a>00437                         <span class="stringliteral">&quot;385D7189A5C3D485E1370AA5D408082B5CCCCB5E19F2D90E&quot;</span>,
<a name="l00438"></a>00438                         <span class="stringliteral">&quot;C141B5FCCD28DC8A&quot;</span>,
<a name="l00439"></a>00439                         <span class="stringliteral">&quot;6E1BD7C6120947A464A6AAB293A0F89A563D8D40D3461B68&quot;</span>,
<a name="l00440"></a>00440                         <span class="stringliteral">&quot;64EAAD4ACBB9CEAD6C7615E7C7E4792FE587D91F20C7D2F4&quot;</span>,
<a name="l00441"></a>00441                         <span class="stringliteral">&quot;6235A461AFD312973E3B4F7AA7D23E34E03371F8E8C376C9&quot;</span>,
<a name="l00442"></a>00442                         <span class="stringliteral">&quot;E26BA806A59B0330DE40CA38E77A3E494BE2B212F6DD624B&quot;</span>,
<a name="l00443"></a>00443                         <span class="stringliteral">&quot;E26BA806A59B03307DE2BCC25A08BA40A8BA335F5D604C62&quot;</span>,
<a name="l00444"></a>00444                         <span class="stringliteral">&quot;E26BA806A59B03303C62C2EFF32D3ACDD5D5F35EBCC53371&quot;</span>);
<a name="l00445"></a>00445 
<a name="l00446"></a>00446                 SymmetricEncryptionKnownAnswerTest&lt;SKIPJACK&gt;(
<a name="l00447"></a>00447                         <span class="stringliteral">&quot;1555E5531C3A169B2D65&quot;</span>,
<a name="l00448"></a>00448                         <span class="stringliteral">&quot;6EC9795701F49864&quot;</span>,
<a name="l00449"></a>00449                         <span class="stringliteral">&quot;00AFA48E9621E52E8CBDA312660184EDDB1F33D9DACDA8DA&quot;</span>,
<a name="l00450"></a>00450                         <span class="stringliteral">&quot;DBEC73562EFCAEB56204EB8AE9557EBF77473FBB52D17CD1&quot;</span>,
<a name="l00451"></a>00451                         <span class="stringliteral">&quot;0C7B0B74E21F99B8F2C8DF37879F6C044967F42A796DCA8B&quot;</span>,
<a name="l00452"></a>00452                         <span class="stringliteral">&quot;79FDDA9724E36CC2E023E9A5C717A8A8A7FDA465CADCBF63&quot;</span>,
<a name="l00453"></a>00453                         <span class="stringliteral">&quot;79FDDA9724E36CC26CACBD83C1ABC06EAF5B249BE5B1E040&quot;</span>,
<a name="l00454"></a>00454                         <span class="stringliteral">&quot;79FDDA9724E36CC211B0AEC607B95A96BCDA318440B82F49&quot;</span>);
<a name="l00455"></a>00455 
<a name="l00456"></a>00456                 SymmetricEncryptionKnownAnswerTest&lt;AES&gt;(
<a name="l00457"></a>00457                         <span class="stringliteral">&quot;2b7e151628aed2a6abf7158809cf4f3c&quot;</span>,
<a name="l00458"></a>00458                         <span class="stringliteral">&quot;000102030405060708090a0b0c0d0e0f&quot;</span>,
<a name="l00459"></a>00459                         <span class="stringliteral">&quot;6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710&quot;</span>,     <span class="comment">// plaintext</span>
<a name="l00460"></a>00460                         <span class="stringliteral">&quot;3ad77bb40d7a3660a89ecaf32466ef97f5d3d58503b9699de785895a96fdbaaf43b1cd7f598ece23881b00e3ed0306887b0c785e27e8ad3f8223207104725dd4&quot;</span>, <span class="comment">// ecb</span>
<a name="l00461"></a>00461                         <span class="stringliteral">&quot;7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a7&quot;</span>,     <span class="comment">// cbc</span>
<a name="l00462"></a>00462                         <span class="stringliteral">&quot;3b3fd92eb72dad20333449f8e83cfb4ac8a64537a0b3a93fcde3cdad9f1ce58b26751f67a3cbb140b1808cf187a4f4dfc04b05357c5d1c0eeac4c66f9ff7f2e6&quot;</span>, <span class="comment">// cfb</span>
<a name="l00463"></a>00463                         <span class="stringliteral">&quot;3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e&quot;</span>, <span class="comment">// ofb</span>
<a name="l00464"></a>00464                         NULL);
<a name="l00465"></a>00465 
<a name="l00466"></a>00466                 SymmetricEncryptionKnownAnswerTest&lt;AES&gt;(
<a name="l00467"></a>00467                         <span class="stringliteral">&quot;2b7e151628aed2a6abf7158809cf4f3c&quot;</span>,
<a name="l00468"></a>00468                         <span class="stringliteral">&quot;f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff&quot;</span>,
<a name="l00469"></a>00469                         <span class="stringliteral">&quot;6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710&quot;</span>,
<a name="l00470"></a>00470                         NULL,
<a name="l00471"></a>00471                         NULL,
<a name="l00472"></a>00472                         NULL,
<a name="l00473"></a>00473                         NULL,
<a name="l00474"></a>00474                         <span class="stringliteral">&quot;874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee&quot;</span>); <span class="comment">// ctr</span>
<a name="l00475"></a>00475 
<a name="l00476"></a>00476 
<a name="l00477"></a>00477                 SecureHashKnownAnswerTest&lt;SHA1&gt;(
<a name="l00478"></a>00478                         <span class="stringliteral">&quot;abc&quot;</span>,
<a name="l00479"></a>00479                         <span class="stringliteral">&quot;A9993E364706816ABA3E25717850C26C9CD0D89D&quot;</span>);
<a name="l00480"></a>00480 
<a name="l00481"></a>00481                 SecureHashKnownAnswerTest&lt;SHA224&gt;(
<a name="l00482"></a>00482                         <span class="stringliteral">&quot;abc&quot;</span>,
<a name="l00483"></a>00483                         <span class="stringliteral">&quot;23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7&quot;</span>);
<a name="l00484"></a>00484 
<a name="l00485"></a>00485                 SecureHashKnownAnswerTest&lt;SHA256&gt;(
<a name="l00486"></a>00486                         <span class="stringliteral">&quot;abc&quot;</span>,
<a name="l00487"></a>00487                         <span class="stringliteral">&quot;ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad&quot;</span>);
<a name="l00488"></a>00488 
<a name="l00489"></a>00489                 SecureHashKnownAnswerTest&lt;SHA384&gt;(
<a name="l00490"></a>00490                         <span class="stringliteral">&quot;abc&quot;</span>,
<a name="l00491"></a>00491                         <span class="stringliteral">&quot;cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7&quot;</span>);
<a name="l00492"></a>00492 
<a name="l00493"></a>00493                 SecureHashKnownAnswerTest&lt;SHA512&gt;(
<a name="l00494"></a>00494                         <span class="stringliteral">&quot;abc&quot;</span>,
<a name="l00495"></a>00495                         <span class="stringliteral">&quot;ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f&quot;</span>);
<a name="l00496"></a>00496 
<a name="l00497"></a>00497                 MAC_KnownAnswerTest&lt;HMAC&lt;SHA1&gt; &gt;(
<a name="l00498"></a>00498                         <span class="stringliteral">&quot;303132333435363738393a3b3c3d3e3f40414243&quot;</span>,
<a name="l00499"></a>00499                         <span class="stringliteral">&quot;Sample #2&quot;</span>,
<a name="l00500"></a>00500                         <span class="stringliteral">&quot;0922d3405faa3d194f82a45830737d5cc6c75d24&quot;</span>);
<a name="l00501"></a>00501 
<a name="l00502"></a>00502                 <span class="keyword">const</span> <span class="keywordtype">char</span> *keyRSA1 = 
<a name="l00503"></a>00503                         <span class="stringliteral">&quot;30820150020100300d06092a864886f70d01010105000482013a3082013602010002400a66791dc6988168de7ab77419bb7fb0&quot;</span>
<a name="l00504"></a>00504                         <span class="stringliteral">&quot;c001c62710270075142942e19a8d8c51d053b3e3782a1de5dc5af4ebe99468170114a1dfe67cdc9a9af55d655620bbab0203010001&quot;</span>
<a name="l00505"></a>00505                         <span class="stringliteral">&quot;02400123c5b61ba36edb1d3679904199a89ea80c09b9122e1400c09adcf7784676d01d23356a7d44d6bd8bd50e94bfc723fa&quot;</span>
<a name="l00506"></a>00506                         <span class="stringliteral">&quot;87d8862b75177691c11d757692df8881022033d48445c859e52340de704bcdda065fbb4058d740bd1d67d29e9c146c11cf61&quot;</span>
<a name="l00507"></a>00507                         <span class="stringliteral">&quot;0220335e8408866b0fd38dc7002d3f972c67389a65d5d8306566d5c4f2a5aa52628b0220045ec90071525325d3d46db79695e9af&quot;</span>
<a name="l00508"></a>00508                         <span class="stringliteral">&quot;acc4523964360e02b119baa366316241022015eb327360c7b60d12e5e2d16bdcd97981d17fba6b70db13b20b436e24eada590220&quot;</span>
<a name="l00509"></a>00509                         <span class="stringliteral">&quot;2ca6366d72781dfa24d34a9a24cbc2ae927a9958af426563ff63fb11658a461d&quot;</span>;
<a name="l00510"></a>00510 
<a name="l00511"></a>00511                 <span class="keyword">const</span> <span class="keywordtype">char</span> *keyRSA2 =
<a name="l00512"></a>00512                         <span class="stringliteral">&quot;30820273020100300D06092A864886F70D01010105000482025D3082025902010002818100D40AF9&quot;</span>
<a name="l00513"></a>00513                         <span class="stringliteral">&quot;A2B713034249E5780056D70FC7DE75D76E44565AA6A6B8ED9646F3C19F9E254D72D7DE6E49DB2264&quot;</span>
<a name="l00514"></a>00514                         <span class="stringliteral">&quot;0C1D05AB9E2A5F901D8F3FE1F7AE02CEE2ECCE54A40ABAE55A004692752E70725AEEE7CDEA67628A&quot;</span>
<a name="l00515"></a>00515                         <span class="stringliteral">&quot;82A9239B4AB660C2BC56D9F01E90CBAAB9BF0FC8E17173CEFC5709A29391A7DDF3E0B758691AAF30&quot;</span>
<a name="l00516"></a>00516                         <span class="stringliteral">&quot;725B292F4F020111027F18C0BA087D082C45D75D3594E0767E4820818EB35612B80CEAB8C880ACA5&quot;</span>
<a name="l00517"></a>00517                         <span class="stringliteral">&quot;44B6876DFFEF85A576C0D45B551AFAA1FD63209CD745DF75C5A0F0B580296EA466CD0338207E4752&quot;</span>
<a name="l00518"></a>00518                         <span class="stringliteral">&quot;FF4E7DB724D8AE18CE5CF4153BB94C27869FBB50E64F02546E4B02997A0B8623E64017CC770759C6&quot;</span>
<a name="l00519"></a>00519                         <span class="stringliteral">&quot;695DB649EEFD829D688D441BCC4E7348F1024100EF86DD7AF3F32CDE8A9F6564E43A559A0C9F8BAD&quot;</span>
<a name="l00520"></a>00520                         <span class="stringliteral">&quot;36CC25330548B347AC158A345631FA90F7B873C36EFFAE2F7823227A3F580B5DD18304D5932751E7&quot;</span>
<a name="l00521"></a>00521                         <span class="stringliteral">&quot;43E9234F024100E2A039854B55688740E32A51DF4AF88613D91A371CF8DDD95D780A89D7CF2119A9&quot;</span>
<a name="l00522"></a>00522                         <span class="stringliteral">&quot;54F1AC0F3DCDB2F6959926E6D9D37D8BC07A4C634DE6F16315BD5F0DAC340102407ECEEDB9903572&quot;</span>
<a name="l00523"></a>00523                         <span class="stringliteral">&quot;1B76909F174BA6698DCA72953D957B22C0A871C8531EDE3A1BB52984A719BC010D1CA57A555DB83F&quot;</span>
<a name="l00524"></a>00524                         <span class="stringliteral">&quot;6DE54CBAB932AEC652F38D497A6F3F30CF024100854F30E4FF232E6DADB2CD99926855F484255AB7&quot;</span>
<a name="l00525"></a>00525                         <span class="stringliteral">&quot;01FBCDCB27EC426F33A7046972AA700ADBCA008763DF87440F52F4E070531AC385B55AAC1C2AE7DD&quot;</span>
<a name="l00526"></a>00526                         <span class="stringliteral">&quot;8F9278F1024100C313F4AF9E4A9DE1253C21080CE524251560C111550772FD08690F13FBE658342E&quot;</span>
<a name="l00527"></a>00527                         <span class="stringliteral">&quot;BD2D41C9DCB12374E871B1839E26CAE252E1AE3DAAD5F1EE1F42B4D0EE7581&quot;</span>;
<a name="l00528"></a>00528 
<a name="l00529"></a>00529                 SignatureKnownAnswerTest&lt;RSASS&lt;PKCS1v15, SHA1&gt; &gt;(
<a name="l00530"></a>00530                         keyRSA1,
<a name="l00531"></a>00531                         <span class="stringliteral">&quot;Everyone gets Friday off.&quot;</span>,
<a name="l00532"></a>00532                         <span class="stringliteral">&quot;0610761F95FFD1B8F29DA34212947EC2AA0E358866A722F03CC3C41487ADC604A48FF54F5C6BEDB9FB7BD59F82D6E55D8F3174BA361B2214B2D74E8825E04E81&quot;</span>);
<a name="l00533"></a>00533 
<a name="l00534"></a>00534                 SignatureKnownAnswerTest&lt;RSASS_ISO&lt;SHA1&gt; &gt;(
<a name="l00535"></a>00535                         keyRSA2,
<a name="l00536"></a>00536                         <span class="stringliteral">&quot;test&quot;</span>,
<a name="l00537"></a>00537                         <span class="stringliteral">&quot;32F6BA41C8930DE71EE67F2627172CC539EDE04267FDE03AC295E3C50311F26C3B275D3AF513AC96&quot;</span>
<a name="l00538"></a>00538                         <span class="stringliteral">&quot;8EE493BAB7DA3A754661D1A7C4A0D1A2B7EE8B313AACD8CB8BFBC5C15EFB0EF15C86A9334A1E87AD&quot;</span>
<a name="l00539"></a>00539                         <span class="stringliteral">&quot;291EB961B5CA0E84930429B28780816AA94F96FC2367B71E2D2E4866FA966795B147F00600E5207E&quot;</span>
<a name="l00540"></a>00540                         <span class="stringliteral">&quot;2F189C883B37477C&quot;</span>);
<a name="l00541"></a>00541 
<a name="l00542"></a>00542                 SignaturePairwiseConsistencyTest&lt;DSA&gt;(
<a name="l00543"></a>00543                         <span class="stringliteral">&quot;3082014A0201003082012B06072A8648CE3804013082011E02818100F468699A6F6EBCC0120D3B34C8E007F125EC7D81F763B8D0F33869AE3BD6B9F2ECCC7DF34DF84C0307449E9B85D30D57194BCCEB310F48141914DD13A077AAF9B624A6CBE666BBA1D7EBEA95B5BA6F54417FD5D4E4220C601E071D316A24EA814E8B0122DBF47EE8AEEFD319EBB01DD95683F10DBB4FEB023F8262A07EAEB7FD02150082AD4E034DA6EEACDFDAE68C36F2BAD614F9E53B02818071AAF73361A26081529F7D84078ADAFCA48E031DB54AD57FB1A833ADBD8672328AABAA0C756247998D7A5B10DACA359D231332CE8120B483A784FE07D46EEBFF0D7D374A10691F78653E6DC29E27CCB1B174923960DFE5B959B919B2C3816C19251832AFD8E35D810E598F82877ABF7D40A041565168BD7F0E21E3FE2A8D8C1C0416021426EBA66E846E755169F84A1DA981D86502405DDF&quot;</span>);
<a name="l00544"></a>00544 
<a name="l00545"></a>00545                 SignaturePairwiseConsistencyTest&lt;ECDSA&lt;EC2N, SHA1&gt; &gt;(
<a name="l00546"></a>00546                         <span class="stringliteral">&quot;302D020100301006072A8648CE3D020106052B8104000404163014020101040F0070337065E1E196980A9D00E37211&quot;</span>);
<a name="l00547"></a>00547 
<a name="l00548"></a>00548                 SignaturePairwiseConsistencyTest&lt;ECDSA&lt;ECP, SHA1&gt; &gt;(
<a name="l00549"></a>00549                         <span class="stringliteral">&quot;3039020100301306072A8648CE3D020106082A8648CE3D030101041F301D02010104182BB8A13C8B867010BD9471D9E81FDB01ABD0538C64D6249A&quot;</span>);
<a name="l00550"></a>00550 
<a name="l00551"></a>00551                 SignaturePairwiseConsistencyTest&lt;RSASS&lt;PSS, SHA1&gt; &gt;(keyRSA1);
<a name="l00552"></a>00552         }
<a name="l00553"></a>00553         <span class="keywordflow">catch</span> (...)
<a name="l00554"></a>00554         {
<a name="l00555"></a>00555                 g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_FAILED;
<a name="l00556"></a>00556                 <span class="keywordflow">goto</span> done;
<a name="l00557"></a>00557         }
<a name="l00558"></a>00558 
<a name="l00559"></a>00559         g_powerUpSelfTestStatus = POWER_UP_SELF_TEST_PASSED;
<a name="l00560"></a>00560 
<a name="l00561"></a>00561 done:
<a name="l00562"></a>00562         SetPowerUpSelfTestInProgressOnThisThread(<span class="keyword">false</span>);
<a name="l00563"></a>00563         <span class="keywordflow">return</span>;
<a name="l00564"></a>00564 }
<a name="l00565"></a>00565 
<a name="l00566"></a>00566 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00567"></a>00567 <span class="preprocessor"></span>
<a name="l00568"></a><a class="code" href="fips140_8h.html#a8daad2060ff39aa61384c1d81af8a3c2">00568</a> <span class="keywordtype">void</span> <a class="code" href="fips140_8h.html#a8daad2060ff39aa61384c1d81af8a3c2" title="perform the power-up self test using the filename of this DLL and the embedded module MAC...">DoDllPowerUpSelfTest</a>()
<a name="l00569"></a>00569 {
<a name="l00570"></a>00570         CryptoPP::DoPowerUpSelfTest(NULL, s_moduleMac);
<a name="l00571"></a>00571 }
<a name="l00572"></a>00572 
<a name="l00573"></a>00573 <span class="preprocessor">#else</span>
<a name="l00574"></a>00574 <span class="preprocessor"></span>
<a name="l00575"></a>00575 <span class="keywordtype">void</span> <a class="code" href="fips140_8h.html#a8daad2060ff39aa61384c1d81af8a3c2" title="perform the power-up self test using the filename of this DLL and the embedded module MAC...">DoDllPowerUpSelfTest</a>()
<a name="l00576"></a>00576 {
<a name="l00577"></a>00577         <span class="keywordflow">throw</span> <a class="code" href="class_not_implemented.html" title="exception thrown by a class if a non-implemented method is called">NotImplemented</a>(<span class="stringliteral">&quot;DoDllPowerUpSelfTest() only available on Windows&quot;</span>);
<a name="l00578"></a>00578 }
<a name="l00579"></a>00579 
<a name="l00580"></a>00580 <span class="preprocessor">#endif  // #ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00581"></a>00581 <span class="preprocessor"></span>
<a name="l00582"></a>00582 NAMESPACE_END
<a name="l00583"></a>00583 
<a name="l00584"></a>00584 <span class="preprocessor">#ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00585"></a>00585 <span class="preprocessor"></span>
<a name="l00586"></a>00586 <span class="comment">// DllMain needs to be in the global namespace</span>
<a name="l00587"></a>00587 BOOL APIENTRY DllMain(HANDLE hModule, 
<a name="l00588"></a>00588                       DWORD  ul_reason_for_call, 
<a name="l00589"></a>00589                       LPVOID lpReserved)
<a name="l00590"></a>00590 {
<a name="l00591"></a>00591         <span class="keywordflow">if</span> (ul_reason_for_call == DLL_PROCESS_ATTACH)
<a name="l00592"></a>00592         {
<a name="l00593"></a>00593                 CryptoPP::s_hModule = (HMODULE)hModule;
<a name="l00594"></a>00594                 CryptoPP::DoDllPowerUpSelfTest();
<a name="l00595"></a>00595         }
<a name="l00596"></a>00596     <span class="keywordflow">return</span> TRUE;
<a name="l00597"></a>00597 }
<a name="l00598"></a>00598 
<a name="l00599"></a>00599 <span class="preprocessor">#endif  // #ifdef CRYPTOPP_WIN32_AVAILABLE</span>
<a name="l00600"></a>00600 <span class="preprocessor"></span>
<a name="l00601"></a>00601 <span class="preprocessor">#endif  // #ifndef CRYPTOPP_IMPORTS</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sun Oct 16 2011 for Crypto++ by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>