📄 cbcmac_8cpp-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.cpp 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.cpp</h1><div class="fragment"><pre>00001 <span class="preprocessor">#include "pch.h"</span>00002 00003 <span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span>00004 <span class="preprocessor"></span>00005 <span class="preprocessor">#include "cbcmac.h"</span>00006 00007 NAMESPACE_BEGIN(CryptoPP)00008 00009 <span class="keywordtype">void</span> CBC_MAC_Base::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)00010 {00011 AccessCipher().SetKey(key, length, params);00012 m_reg.CleanNew(AccessCipher().<a class="code" href="class_hash_transformation.html#_x_m_a_c_ca10">BlockSize</a>());00013 m_counter = 0;00014 }00015 00016 <span class="keywordtype">void</span> CBC_MAC_Base::Update(<span class="keyword">const</span> byte *input, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length)00017 {00018 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> blockSize = AccessCipher().BlockSize();00019 00020 <span class="keywordflow">while</span> (m_counter && length)00021 {00022 m_reg[m_counter++] ^= *input++;00023 <span class="keywordflow">if</span> (m_counter == blockSize)00024 ProcessBuf();00025 length--;00026 }00027 00028 <span class="keywordflow">while</span> (length >= blockSize)00029 {00030 xorbuf(m_reg, input, blockSize);00031 ProcessBuf();00032 input += blockSize;00033 length -= blockSize;00034 }00035 00036 <span class="keywordflow">while</span> (length--)00037 {00038 m_reg[m_counter++] ^= *input++;00039 <span class="keywordflow">if</span> (m_counter == blockSize)00040 ProcessBuf();00041 }00042 }00043 00044 <span class="keywordtype">void</span> CBC_MAC_Base::TruncatedFinal(byte *mac, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size)00045 {00046 ThrowIfInvalidTruncatedSize(size);00047 00048 <span class="keywordflow">if</span> (m_counter)00049 ProcessBuf();00050 00051 memcpy(mac, m_reg, size);00052 memset(m_reg, 0, AccessCipher().<a class="code" href="class_hash_transformation.html#_x_m_a_c_ca10">BlockSize</a>());00053 }00054 00055 <span class="keywordtype">void</span> CBC_MAC_Base::ProcessBuf()00056 {00057 AccessCipher().ProcessBlock(m_reg);00058 m_counter = 0;00059 }00060 00061 NAMESPACE_END00062 00063 <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 + -