⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdc_8h-source.html

📁 Crypto++是一个非常强大的密码学库,主要是功能全
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Crypto++: mdc.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.2 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div><h1>mdc.h</h1><a href="mdc_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001  <span class="comment">// mdc.h - written and placed in the public domain by Wei Dai</span>00002 00003 <span class="preprocessor">#ifndef CRYPTOPP_MDC_H</span>00004 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_MDC_H</span>00005 <span class="preprocessor"></span><span class="comment"></span>00006 <span class="comment">/** \file</span>00007 <span class="comment">*/</span>00008 00009 <span class="preprocessor">#include "seckey.h"</span>00010 <span class="preprocessor">#include "misc.h"</span>00011 00012 NAMESPACE_BEGIN(CryptoPP)00013 00014 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;00015 <span class="keyword">struct </span>MDC_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a>&lt;T::DIGESTSIZE&gt;, <span class="keyword">public</span> <a class="code" href="class_fixed_key_length.html">FixedKeyLength</a>&lt;T::BLOCKSIZE&gt;00016 {00017         <span class="keyword">static</span> std::string StaticAlgorithmName() {<span class="keywordflow">return</span> std::string(<span class="stringliteral">"MDC/"</span>)+T::StaticAlgorithmName();}00018 };00019 <span class="comment"></span>00020 <span class="comment">//! &lt;a href="http://www.weidai.com/scan-mirror/cs.html#MDC"&gt;MDC&lt;/a&gt;</span>00021 <span class="comment"></span><span class="comment">/*! a construction by Peter Gutmann to turn an iterated hash function into a PRF */</span>00022 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;<a name="l00023"></a><a class="code" href="class_m_d_c.html">00023</a> <span class="keyword">class </span><a class="code" href="class_m_d_c.html">MDC</a> : <span class="keyword">public</span> MDC_Info&lt;T&gt;00024 {00025         <span class="keyword">class </span>Enc : <span class="keyword">public</span> BlockCipherBaseTemplate&lt;MDC_Info&lt;T&gt; &gt;00026         {00027                 <span class="keyword">typedef</span> <span class="keyword">typename</span> T::HashWordType HashWordType;00028 00029         <span class="keyword">public</span>:00030                 <span class="keywordtype">void</span> UncheckedSetKey(<a class="code" href="cryptlib_8h.html#a11">CipherDir</a> direction, <span class="keyword">const</span> byte *userKey, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length)00031                 {00032                         assert(direction == ENCRYPTION);00033                         AssertValidKeyLength(length);00034                         memcpy(<a class="code" href="namespace_name.html#a3">Key</a>(), userKey, KEYLENGTH);00035                         T::CorrectEndianess(<a class="code" href="namespace_name.html#a3">Key</a>(), <a class="code" href="namespace_name.html#a3">Key</a>(), KEYLENGTH);00036                 }00037 00038                 <span class="keywordtype">void</span> ProcessAndXorBlock(<span class="keyword">const</span> byte *inBlock, <span class="keyword">const</span> byte *xorBlock, byte *outBlock)<span class="keyword"> const</span>00039 <span class="keyword">                </span>{00040                         T::CorrectEndianess(Buffer(), (HashWordType *)inBlock, BLOCKSIZE);00041                         T::Transform(Buffer(), <a class="code" href="namespace_name.html#a3">Key</a>());00042                         <span class="keywordflow">if</span> (xorBlock)00043                         {00044                                 T::CorrectEndianess(Buffer(), Buffer(), BLOCKSIZE);00045                                 xorbuf(outBlock, xorBlock, m_buffer, BLOCKSIZE);00046                         }00047                         <span class="keywordflow">else</span>00048                                 T::CorrectEndianess((HashWordType *)outBlock, Buffer(), BLOCKSIZE);00049                 }00050 00051                 <span class="keywordtype">bool</span> IsPermutation()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">false</span>;}00052 00053                 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetAlignment()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">sizeof</span>(HashWordType);}00054 00055         <span class="keyword">private</span>:00056                 HashWordType *<a class="code" href="namespace_name.html#a3">Key</a>() {<span class="keywordflow">return</span> (HashWordType *)m_key.data();}00057                 <span class="keyword">const</span> HashWordType *<a class="code" href="namespace_name.html#a3">Key</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<span class="keyword">const</span> HashWordType *)m_key.data();}00058                 HashWordType *Buffer()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (HashWordType *)m_buffer.data();}00059 00060                 <span class="comment">// VC60 workaround: bug triggered if using FixedSizeAllocatorWithCleanup</span>00061                 FixedSizeSecBlock&lt;byte, MDC_Info&lt;T&gt;::KEYLENGTH, AllocatorWithCleanup&lt;byte&gt; &gt; m_key;00062                 <span class="keyword">mutable</span> FixedSizeSecBlock&lt;byte, MDC_Info&lt;T&gt;::BLOCKSIZE, AllocatorWithCleanup&lt;byte&gt; &gt; m_buffer;00063         };00064 00065 <span class="keyword">public</span>:<span class="comment"></span>00066 <span class="comment">        //! use BlockCipher interface</span><a name="l00067"></a><a class="code" href="class_m_d_c.html#_m_d_cw0">00067</a> <span class="comment"></span>        <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate&lt;ENCRYPTION, Enc&gt;</a> <a class="code" href="class_block_cipher_template.html">Encryption</a>;00068 };00069 00070 NAMESPACE_END00071 00072 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:20 2003 for Crypto++ by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.2 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -