<!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++: trunhash.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.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main 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 class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>trunhash.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_TRUNHASH_H</span> <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_TRUNHASH_H</span> <a name="l00003"></a>00003 <span class="preprocessor"></span> <a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="cryptlib_8h.html">cryptlib.h</a>"</span> <a name="l00005"></a>00005 <a name="l00006"></a>00006 NAMESPACE_BEGIN(CryptoPP) <a name="l00007"></a>00007 <a name="l00008"></a><a class="code" href="class_null_hash.html">00008</a> class <a class="code" href="class_null_hash.html">NullHash</a> : public <a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> <a name="l00009"></a>00009 { <a name="l00010"></a>00010 <span class="keyword">public</span>: <a name="l00011"></a><a class="code" href="class_null_hash.html#ac18fc7f331dd116f1a38aea97c0ea100">00011</a> <span class="keywordtype">void</span> <a class="code" href="class_null_hash.html#ac18fc7f331dd116f1a38aea97c0ea100" title="process more input">Update</a>(<span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> length) {} <a name="l00012"></a><a class="code" href="class_null_hash.html#aa50992c3e69f61df9cdd7c7778fae221">00012</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_null_hash.html#aa50992c3e69f61df9cdd7c7778fae221" title="size of the hash/digest/MAC returned by Final()">DigestSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 0;} <a name="l00013"></a><a class="code" href="class_null_hash.html#aba7565b459a86274e0958230e72ddee2">00013</a> <span class="keywordtype">void</span> <a class="code" href="class_null_hash.html#aba7565b459a86274e0958230e72ddee2" title="truncated version of Final()">TruncatedFinal</a>(byte *digest, <span class="keywordtype">size_t</span> digestSize) {} <a name="l00014"></a><a class="code" href="class_null_hash.html#ab18ad3278ce23ea6b1d4f6394d31ae19">00014</a> <span class="keywordtype">bool</span> <a class="code" href="class_null_hash.html#ab18ad3278ce23ea6b1d4f6394d31ae19" title="truncated version of Verify()">TruncatedVerify</a>(<span class="keyword">const</span> byte *digest, <span class="keywordtype">size_t</span> digestLength) {<span class="keywordflow">return</span> <span class="keyword">true</span>;} <a name="l00015"></a>00015 }; <a name="l00016"></a>00016 <span class="comment"></span> <a name="l00017"></a>00017 <span class="comment">//! construct new HashModule with smaller DigestSize() from existing one</span> <a name="l00018"></a>00018 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> T> <a name="l00019"></a><a class="code" href="class_truncated_hash_template.html">00019</a> <span class="keyword">class </span><a class="code" href="class_truncated_hash_template.html" title="construct new HashModule with smaller DigestSize() from existing one">TruncatedHashTemplate</a> : <span class="keyword">public</span> <a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> <a name="l00020"></a>00020 { <a name="l00021"></a>00021 <span class="keyword">public</span>: <a name="l00022"></a>00022 <a class="code" href="class_truncated_hash_template.html" title="construct new HashModule with smaller DigestSize() from existing one">TruncatedHashTemplate</a>(T hm, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> digestSize) <a name="l00023"></a>00023 : m_hm(hm), m_digestSize(digestSize) {} <a name="l00024"></a>00024 <a class="code" href="class_truncated_hash_template.html" title="construct new HashModule with smaller DigestSize() from existing one">TruncatedHashTemplate</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">size_t</span> keyLength, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> digestSize) <a name="l00025"></a>00025 : m_hm(key, keyLength), m_digestSize(digestSize) {} <a name="l00026"></a>00026 <a class="code" href="class_truncated_hash_template.html" title="construct new HashModule with smaller DigestSize() from existing one">TruncatedHashTemplate</a>(<span class="keywordtype">size_t</span> digestSize) <a name="l00027"></a>00027 : m_digestSize(digestSize) {} <a name="l00028"></a>00028 <a name="l00029"></a><a class="code" href="class_truncated_hash_template.html#a01af99665c10d2980a4e23555067cb5d">00029</a> <span class="keywordtype">void</span> <a class="code" href="class_truncated_hash_template.html#a01af99665c10d2980a4e23555067cb5d" title="discard the current state, and restart with a new message">Restart</a>() <a name="l00030"></a>00030 {m_hm.Restart();} <a name="l00031"></a><a class="code" href="class_truncated_hash_template.html#a3261842338107f4f641e493b0ceb037f">00031</a> <span class="keywordtype">void</span> <a class="code" href="class_truncated_hash_template.html#a3261842338107f4f641e493b0ceb037f" title="process more input">Update</a>(<span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> length) <a name="l00032"></a>00032 {m_hm.Update(input, length);} <a name="l00033"></a><a class="code" href="class_truncated_hash_template.html#a031c1782432ae1e0f7bff2bb2ae382a5">00033</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_truncated_hash_template.html#a031c1782432ae1e0f7bff2bb2ae382a5" title="size of the hash/digest/MAC returned by Final()">DigestSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_digestSize;} <a name="l00034"></a><a class="code" href="class_truncated_hash_template.html#a8d35821fad737aaa41c6ad0a01e56510">00034</a> <span class="keywordtype">void</span> <a class="code" href="class_truncated_hash_template.html#a8d35821fad737aaa41c6ad0a01e56510" title="truncated version of Final()">TruncatedFinal</a>(byte *digest, <span class="keywordtype">size_t</span> digestSize) <a name="l00035"></a>00035 {m_hm.TruncatedFinal(digest, digestSize);} <a name="l00036"></a><a class="code" href="class_truncated_hash_template.html#aeeae8ba7cae1d365551f156a5ff87c6d">00036</a> <span class="keywordtype">bool</span> <a class="code" href="class_truncated_hash_template.html#aeeae8ba7cae1d365551f156a5ff87c6d" title="truncated version of Verify()">TruncatedVerify</a>(<span class="keyword">const</span> byte *digest, <span class="keywordtype">size_t</span> digestLength) <a name="l00037"></a>00037 {<span class="keywordflow">return</span> m_hm.TruncatedVerify(digest, digestLength);} <a name="l00038"></a>00038 <a name="l00039"></a>00039 <span class="keyword">private</span>: <a name="l00040"></a>00040 T m_hm; <a name="l00041"></a>00041 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_digestSize; <a name="l00042"></a>00042 }; <a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="keyword">typedef</span> <a class="code" href="class_truncated_hash_template.html" title="construct new HashModule with smaller DigestSize() from existing one">TruncatedHashTemplate<HashTransformation &></a> <a class="code" href="class_truncated_hash_template.html" title="construct new HashModule with smaller DigestSize() from existing one">TruncatedHashModule</a>; <a name="l00045"></a>00045 <a name="l00046"></a>00046 NAMESPACE_END <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="preprocessor">#endif</span> </pre></div></div> <hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> </body> </html>