📄 mdc_8h-source.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 Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Compound List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Compound Members</a> | <a class="qindex" href="globals.html">File 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> <<span class="keyword">class</span> T>00015 <span class="keyword">struct </span>MDC_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a><T::DIGESTSIZE>, <span class="keyword">public</span> <a class="code" href="class_fixed_key_length.html">FixedKeyLength</a><T::BLOCKSIZE>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">//! <a href="http://www.weidai.com/scan-mirror/cs.html#MDC">MDC</a></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> <<span class="keyword">class</span> T><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<T>00024 {00025 <span class="keyword">class </span>Enc : <span class="keyword">public</span> BlockCipherBaseTemplate<MDC_Info<T> >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<byte, MDC_Info<T>::KEYLENGTH, AllocatorWithCleanup<byte> > m_key;00062 <span class="keyword">mutable</span> FixedSizeSecBlock<byte, MDC_Info<T>::BLOCKSIZE, AllocatorWithCleanup<byte> > 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<ENCRYPTION, Enc></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 + -