Sophie

Sophie

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

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++: iterhash.h 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">iterhash.h</div>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_ITERHASH_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_ITERHASH_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;<a class="code" href="cryptlib_8h.html">cryptlib.h</a>&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;secblock.h&quot;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;misc.h&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;<a class="code" href="simple_8h.html">simple.h</a>&quot;</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 NAMESPACE_BEGIN(CryptoPP)
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">//! exception thrown when trying to hash more data than is allowed by a hash function</span>
<a name="l00012"></a><a class="code" href="class_hash_input_too_long.html">00012</a> <span class="comment"></span>class CRYPTOPP_DLL <a class="code" href="class_hash_input_too_long.html" title="exception thrown when trying to hash more data than is allowed by a hash function">HashInputTooLong</a> : public <a class="code" href="class_invalid_data_format.html" title="exception thrown when input data is received that doesn&#39;t conform to expected format">InvalidDataFormat</a>
<a name="l00013"></a>00013 {
<a name="l00014"></a>00014 <span class="keyword">public</span>:
<a name="l00015"></a>00015         <span class="keyword">explicit</span> <a class="code" href="class_hash_input_too_long.html" title="exception thrown when trying to hash more data than is allowed by a hash function">HashInputTooLong</a>(<span class="keyword">const</span> std::string &amp;alg)
<a name="l00016"></a>00016                 : InvalidDataFormat(<span class="stringliteral">&quot;IteratedHashBase: input data exceeds maximum allowed by hash function &quot;</span> + alg) {}
<a name="l00017"></a>00017 };
<a name="l00018"></a>00018 <span class="comment"></span>
<a name="l00019"></a>00019 <span class="comment">//! _</span>
<a name="l00020"></a>00020 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keyword">class</span> T, <span class="keyword">class</span> BASE&gt;
<a name="l00021"></a><a class="code" href="class_iterated_hash_base.html">00021</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_iterated_hash_base.html" title="_">IteratedHashBase</a> : <span class="keyword">public</span> <a class="code" href="class_b_a_s_e.html">BASE</a>
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023 <span class="keyword">public</span>:
<a name="l00024"></a>00024         <span class="keyword">typedef</span> T HashWordType;
<a name="l00025"></a>00025 
<a name="l00026"></a>00026         <a class="code" href="class_iterated_hash_base.html" title="_">IteratedHashBase</a>() : m_countLo(0), m_countHi(0) {}
<a name="l00027"></a>00027         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> OptimalBlockSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> this-&gt;BlockSize();}
<a name="l00028"></a>00028         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> OptimalDataAlignment()<span class="keyword"> const </span>{<span class="keywordflow">return</span> GetAlignmentOf&lt;T&gt;();}
<a name="l00029"></a>00029         <span class="keywordtype">void</span> Update(<span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> length);
<a name="l00030"></a>00030         byte * CreateUpdateSpace(<span class="keywordtype">size_t</span> &amp;size);
<a name="l00031"></a>00031         <span class="keywordtype">void</span> Restart();
<a name="l00032"></a>00032         <span class="keywordtype">void</span> TruncatedFinal(byte *digest, <span class="keywordtype">size_t</span> size);
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="keyword">protected</span>:
<a name="l00035"></a>00035         <span class="keyword">inline</span> T GetBitCountHi()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (m_countLo &gt;&gt; (8*<span class="keyword">sizeof</span>(T)-3)) + (m_countHi &lt;&lt; 3);}
<a name="l00036"></a>00036         <span class="keyword">inline</span> T GetBitCountLo()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_countLo &lt;&lt; 3;}
<a name="l00037"></a>00037 
<a name="l00038"></a>00038         <span class="keywordtype">void</span> PadLastBlock(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> lastBlockSize, byte padFirst=0x80);
<a name="l00039"></a>00039         <span class="keyword">virtual</span> <span class="keywordtype">void</span> Init() =0;
<a name="l00040"></a>00040 
<a name="l00041"></a>00041         <span class="keyword">virtual</span> ByteOrder GetByteOrder() <span class="keyword">const</span> =0;
<a name="l00042"></a>00042         <span class="keyword">virtual</span> <span class="keywordtype">void</span> HashEndianCorrectedBlock(<span class="keyword">const</span> HashWordType *data) =0;
<a name="l00043"></a>00043         <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> HashMultipleBlocks(<span class="keyword">const</span> T *input, <span class="keywordtype">size_t</span> length);
<a name="l00044"></a>00044         <span class="keywordtype">void</span> HashBlock(<span class="keyword">const</span> HashWordType *input) {HashMultipleBlocks(input, this-&gt;BlockSize());}
<a name="l00045"></a>00045 
<a name="l00046"></a>00046         <span class="keyword">virtual</span> T* DataBuf() =0;
<a name="l00047"></a>00047         <span class="keyword">virtual</span> T* StateBuf() =0;
<a name="l00048"></a>00048 
<a name="l00049"></a>00049 <span class="keyword">private</span>:
<a name="l00050"></a>00050         T m_countLo, m_countHi;
<a name="l00051"></a>00051 };
<a name="l00052"></a>00052 <span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">//! _</span>
<a name="l00054"></a>00054 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keyword">class</span> T_HashWordType, <span class="keyword">class</span> T_Endianness, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_BlockSize, <span class="keyword">class</span> T_Base = HashTransformation&gt;
<a name="l00055"></a><a class="code" href="class_iterated_hash.html">00055</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_iterated_hash.html" title="_">IteratedHash</a> : <span class="keyword">public</span> <a class="code" href="class_iterated_hash_base.html" title="_">IteratedHashBase</a>&lt;T_HashWordType, T_Base&gt;
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 <span class="keyword">public</span>:
<a name="l00058"></a>00058         <span class="keyword">typedef</span> T_Endianness ByteOrderClass;
<a name="l00059"></a>00059         <span class="keyword">typedef</span> T_HashWordType HashWordType;
<a name="l00060"></a>00060 
<a name="l00061"></a>00061         CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize)
<a name="l00062"></a>00062         <span class="comment">// BCB2006 workaround: can&#39;t use BLOCKSIZE here</span>
<a name="l00063"></a>00063         CRYPTOPP_COMPILE_ASSERT((T_BlockSize &amp; (T_BlockSize - 1)) == 0);        <span class="comment">// blockSize is a power of 2</span>
<a name="l00064"></a>00064         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> BlockSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> T_BlockSize;}
<a name="l00065"></a>00065 
<a name="l00066"></a>00066         ByteOrder GetByteOrder()<span class="keyword"> const </span>{<span class="keywordflow">return</span> T_Endianness::ToEnum();}
<a name="l00067"></a>00067 
<a name="l00068"></a>00068         <span class="keyword">inline</span> <span class="keyword">static</span> <span class="keywordtype">void</span> CorrectEndianess(HashWordType *out, <span class="keyword">const</span> HashWordType *in, <span class="keywordtype">size_t</span> byteCount)
<a name="l00069"></a>00069         {
<a name="l00070"></a>00070                 ConditionalByteReverse(T_Endianness::ToEnum(), out, in, byteCount);
<a name="l00071"></a>00071         }
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 <span class="keyword">protected</span>:
<a name="l00074"></a>00074         T_HashWordType* DataBuf() {<span class="keywordflow">return</span> this-&gt;m_data;}
<a name="l00075"></a>00075         <a class="code" href="class_fixed_size_sec_block.html" title="a SecBlock with fixed size, allocated statically">FixedSizeSecBlock</a>&lt;T_HashWordType, T_BlockSize/<span class="keyword">sizeof</span>(T_HashWordType)&gt; m_data;
<a name="l00076"></a>00076 };
<a name="l00077"></a>00077 <span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">//! _</span>
<a name="l00079"></a>00079 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keyword">class</span> T_HashWordType, <span class="keyword">class</span> T_Endianness, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_BlockSize, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_StateSize, <span class="keyword">class</span> T_Transform, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_DigestSize = 0, <span class="keywordtype">bool</span> T_StateAligned = false&gt;
<a name="l00080"></a><a class="code" href="class_iterated_hash_with_static_transform.html">00080</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE <a class="code" href="class_iterated_hash_with_static_transform.html" title="_">IteratedHashWithStaticTransform</a>
<a name="l00081"></a>00081         : <span class="keyword">public</span> <a class="code" href="class_clonable_impl.html" title="_">ClonableImpl</a>&lt;T_Transform, AlgorithmImpl&lt;IteratedHash&lt;T_HashWordType, T_Endianness, T_BlockSize&gt;, T_Transform&gt; &gt;
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 <span class="keyword">public</span>:
<a name="l00084"></a>00084         CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize)
<a name="l00085"></a><a class="code" href="class_iterated_hash_with_static_transform.html#a176f8dcb7ea9818cd54e8f6df8bca50a">00085</a>         unsigned <span class="keywordtype">int</span> DigestSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> DIGESTSIZE;};
<a name="l00086"></a>00086 
<a name="l00087"></a>00087 <span class="keyword">protected</span>:
<a name="l00088"></a>00088         <a class="code" href="class_iterated_hash_with_static_transform.html" title="_">IteratedHashWithStaticTransform</a>() {this-&gt;Init();}
<a name="l00089"></a>00089         <span class="keywordtype">void</span> HashEndianCorrectedBlock(<span class="keyword">const</span> T_HashWordType *data) {T_Transform::Transform(this-&gt;m_state, data);}
<a name="l00090"></a>00090         <span class="keywordtype">void</span> Init() {T_Transform::InitState(this-&gt;m_state);}
<a name="l00091"></a>00091 
<a name="l00092"></a>00092         T_HashWordType* StateBuf() {<span class="keywordflow">return</span> this-&gt;m_state;}
<a name="l00093"></a>00093         <a class="code" href="class_fixed_size_aligned_sec_block.html">FixedSizeAlignedSecBlock</a>&lt;T_HashWordType, T_BlockSize/<span class="keyword">sizeof</span>(T_HashWordType), T_StateAligned&gt; m_state;
<a name="l00094"></a>00094 };
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 <span class="preprocessor">#ifndef __GNUC__</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span>        CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_iterated_hash_base.html">IteratedHashBase&lt;word64, HashTransformation&gt;</a>;
<a name="l00098"></a>00098         CRYPTOPP_STATIC_TEMPLATE_CLASS <a class="code" href="class_iterated_hash_base.html">IteratedHashBase&lt;word64, MessageAuthenticationCode&gt;</a>;
<a name="l00099"></a>00099 
<a name="l00100"></a>00100         CRYPTOPP_DLL_TEMPLATE_CLASS <a class="code" href="class_iterated_hash_base.html">IteratedHashBase&lt;word32, HashTransformation&gt;</a>;
<a name="l00101"></a>00101         CRYPTOPP_STATIC_TEMPLATE_CLASS <a class="code" href="class_iterated_hash_base.html">IteratedHashBase&lt;word32, MessageAuthenticationCode&gt;</a>;
<a name="l00102"></a>00102 <span class="preprocessor">#endif</span>
<a name="l00103"></a>00103 <span class="preprocessor"></span>
<a name="l00104"></a>00104 NAMESPACE_END
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 <span class="preprocessor">#endif</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>