📄 cbcmac_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: cbcmac.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><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="classes.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>cbcmac.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_CBCMAC_H</span><a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_CBCMAC_H</span><a name="l00003"></a>00003 <span class="preprocessor"></span><a name="l00004"></a>00004 <span class="preprocessor">#include "seckey.h"</span><a name="l00005"></a>00005 <span class="preprocessor">#include "secblock.h"</span><a name="l00006"></a>00006 <a name="l00007"></a>00007 NAMESPACE_BEGIN(CryptoPP)<a name="l00008"></a>00008 <a name="l00009"></a>00009 <span class="comment">//! _</span><a name="l00010"></a><a class="code" href="class_c_b_c___m_a_c___base.html">00010</a> <span class="comment"></span>class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE <a class="code" href="class_c_b_c___m_a_c___base.html" title="_">CBC_MAC_Base</a> : public <a class="code" href="class_message_authentication_code.html" title="interface for message authentication codes">MessageAuthenticationCode</a><a name="l00011"></a>00011 {<a name="l00012"></a>00012 <span class="keyword">public</span>:<a name="l00013"></a><a class="code" href="class_c_b_c___m_a_c___base.html#409efc34db36b2365b94ff722e0ae102">00013</a> <a class="code" href="class_c_b_c___m_a_c___base.html" title="_">CBC_MAC_Base</a>() {}<a name="l00014"></a>00014 <a name="l00015"></a>00015 <span class="keywordtype">void</span> UncheckedSetKey(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length, <span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &params);<a name="l00016"></a>00016 <span class="keywordtype">void</span> Update(<span class="keyword">const</span> byte *input, <span class="keywordtype">size_t</span> length);<a name="l00017"></a>00017 <span class="keywordtype">void</span> TruncatedFinal(byte *mac, <span class="keywordtype">size_t</span> size);<a name="l00018"></a><a class="code" href="class_c_b_c___m_a_c___base.html#0fec943dfb5a946b490347da855cfc89">00018</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> DigestSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="keyword">const_cast<</span><a class="code" href="class_c_b_c___m_a_c___base.html" title="_">CBC_MAC_Base</a>*<span class="keyword">></span>(<span class="keyword">this</span>)->AccessCipher().BlockSize();}<a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="keyword">protected</span>:<a name="l00021"></a>00021 <span class="keyword">virtual</span> <a class="code" href="class_block_cipher.html" title="interface for one direction (encryption or decryption) of a block cipher">BlockCipher</a> & AccessCipher() =0;<a name="l00022"></a>00022 <a name="l00023"></a>00023 <span class="keyword">private</span>:<a name="l00024"></a>00024 <span class="keywordtype">void</span> ProcessBuf();<a name="l00025"></a>00025 <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> m_reg;<a name="l00026"></a>00026 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_counter;<a name="l00027"></a>00027 };<a name="l00028"></a>00028 <span class="comment"></span><a name="l00029"></a>00029 <span class="comment">//! <a href="http://www.weidai.com/scan-mirror/mac.html#CBC-MAC">CBC-MAC</a></span><a name="l00030"></a>00030 <span class="comment"></span><span class="comment">/*! Compatible with FIPS 113. T should be a class derived from BlockCipherDocumentation.</span><a name="l00031"></a>00031 <span class="comment"> Secure only for fixed length messages. For variable length</span><a name="l00032"></a>00032 <span class="comment"> messages use DMAC.</span><a name="l00033"></a>00033 <span class="comment">*/</span><a name="l00034"></a>00034 <span class="keyword">template</span> <<span class="keyword">class</span> T><a name="l00035"></a><a class="code" href="class_c_b_c___m_a_c.html">00035</a> <span class="keyword">class </span><a class="code" href="class_c_b_c___m_a_c.html" title="CBC-MAC">CBC_MAC</a> : <span class="keyword">public</span> <a class="code" href="class_message_authentication_code_impl.html" title="_">MessageAuthenticationCodeImpl</a><CBC_MAC_Base, CBC_MAC<T> >, <span class="keyword">public</span> <a class="code" href="class_same_key_length_as.html" title="support query of key length that's the same as another class">SameKeyLengthAs</a><T><a name="l00036"></a>00036 {<a name="l00037"></a>00037 <span class="keyword">public</span>:<a name="l00038"></a><a class="code" href="class_c_b_c___m_a_c.html#b7b7366b58036a0af717b9bcd48dd10b">00038</a> <a class="code" href="class_c_b_c___m_a_c.html#b7b7366b58036a0af717b9bcd48dd10b">CBC_MAC</a>() {}<a name="l00039"></a><a class="code" href="class_c_b_c___m_a_c.html#f6b2e38e87f5146cbd5ec54c3d4f6352">00039</a> <a class="code" href="class_c_b_c___m_a_c.html#b7b7366b58036a0af717b9bcd48dd10b">CBC_MAC</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">size_t</span> length=<a class="code" href="class_same_key_length_as.html" title="support query of key length that's the same as another class">SameKeyLengthAs<T>::DEFAULT_KEYLENGTH</a>)<a name="l00040"></a>00040 {this-><a class="code" href="class_simple_keying_interface.html#df3c29b3ef3af74788a58c7c49887fd7" title="set or reset the key of this object">SetKey</a>(key, length);}<a name="l00041"></a>00041 <a name="l00042"></a><a class="code" href="class_c_b_c___m_a_c.html#0f55085f835ad9d5303d88f2ff52257d">00042</a> <span class="keyword">static</span> std::string <a class="code" href="class_c_b_c___m_a_c.html#0f55085f835ad9d5303d88f2ff52257d">StaticAlgorithmName</a>() {<span class="keywordflow">return</span> std::string(<span class="stringliteral">"CBC-MAC("</span>) + T::StaticAlgorithmName() + <span class="stringliteral">")"</span>;}<a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="keyword">private</span>:<a name="l00045"></a>00045 <a class="code" href="class_block_cipher.html" title="interface for one direction (encryption or decryption) of a block cipher">BlockCipher</a> & AccessCipher() {<span class="keywordflow">return</span> m_cipher;}<a name="l00046"></a>00046 <span class="keyword">typename</span> T::Encryption m_cipher;<a name="l00047"></a>00047 };<a name="l00048"></a>00048 <a name="l00049"></a>00049 NAMESPACE_END<a name="l00050"></a>00050 <a name="l00051"></a>00051 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jun 1 11:11:20 2007 for Crypto++ by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -