📄 cbcmac_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++: cbcmac.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>cbcmac.h</h1><div class="fragment"><pre>00001 <span class="preprocessor">#ifndef CRYPTOPP_CBCMAC_H</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_CBCMAC_H</span>00003 <span class="preprocessor"></span>00004 <span class="preprocessor">#include "seckey.h"</span>00005 <span class="preprocessor">#include "secblock.h"</span>00006 00007 NAMESPACE_BEGIN(CryptoPP)00008 00009 <span class="keyword">class </span>CRYPTOPP_DLL CBC_MAC_Base : <span class="keyword">public</span> <a class="code" href="class_message_authentication_code.html">MessageAuthenticationCode</a>00010 {00011 <span class="keyword">public</span>:00012 CBC_MAC_Base() {}00013 00014 <span class="keywordtype">void</span> CheckedSetKey(<span class="keywordtype">void</span> *, Empty empty, <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">NameValuePairs</a> &params);00015 <span class="keywordtype">void</span> <a class="code" href="class_hash_transformation.html#_x_m_a_c_ca5">Update</a>(<span class="keyword">const</span> byte *input, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length);00016 <span class="keywordtype">void</span> <a class="code" href="class_hash_transformation.html#_x_m_a_c_ca15">TruncatedFinal</a>(byte *mac, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size);00017 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_hash_transformation.html#_x_m_a_c_ca9">DigestSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> const_cast<CBC_MAC_Base*>(<span class="keyword">this</span>)->AccessCipher().BlockSize();}00018 00019 <span class="keyword">protected</span>:00020 <span class="keyword">virtual</span> <a class="code" href="class_block_cipher.html">BlockCipher</a> & AccessCipher() =0;00021 00022 <span class="keyword">private</span>:00023 <span class="keywordtype">void</span> ProcessBuf();00024 <a class="code" href="class_sec_block.html">SecByteBlock</a> m_reg;00025 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> m_counter;00026 };00027 <span class="comment"></span>00028 <span class="comment">//! <a href="http://www.weidai.com/scan-mirror/mac.html#CBC-MAC">CBC-MAC</a></span>00029 <span class="comment"></span><span class="comment">/*! Compatible with FIPS 113. T should be an encryption class.</span>00030 <span class="comment"> Secure only for fixed length messages. For variable length</span>00031 <span class="comment"> messages use DMAC.</span>00032 <span class="comment">*/</span>00033 <span class="keyword">template</span> <<span class="keyword">class</span> T><a name="l00034"></a><a class="code" href="class_c_b_c___m_a_c.html">00034</a> <span class="keyword">class </span><a class="code" href="class_c_b_c___m_a_c.html">CBC_MAC</a> : <span class="keyword">public</span> <a class="code" href="class_message_authentication_code_final_template.html">MessageAuthenticationCodeFinalTemplate</a><CBC_MAC_Base, CBC_MAC<T> >, <span class="keyword">public</span> <a class="code" href="class_same_key_length_as.html">SameKeyLengthAs</a><T>00035 {00036 <span class="keyword">public</span>:00037 <a class="code" href="class_c_b_c___m_a_c.html">CBC_MAC</a>() {}00038 <a class="code" href="class_c_b_c___m_a_c.html">CBC_MAC</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length=DEFAULT_KEYLENGTH)00039 {<a class="code" href="class_message_authentication_code_final_template.html#_message_authentication_code_final_templatea3">SetKey</a>(key, length);}00040 00041 <span class="keyword">static</span> std::string StaticAlgorithmName() {<span class="keywordflow">return</span> std::string(<span class="stringliteral">"CBC-MAC("</span>) + T::StaticAlgorithmName() + <span class="stringliteral">")"</span>;}00042 00043 <span class="keyword">private</span>:00044 <a class="code" href="class_block_cipher.html">BlockCipher</a> & AccessCipher() {<span class="keywordflow">return</span> m_cipher;}00045 <span class="keyword">typename</span> T::Encryption m_cipher;00046 };00047 00048 NAMESPACE_END00049 00050 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:10 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 + -