📄 modes_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++: modes.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>modes.h</h1><a href="modes_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CRYPTOPP_MODES_H</span><a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_MODES_H</span><a name="l00003"></a>00003 <span class="preprocessor"></span><span class="comment"></span><a name="l00004"></a>00004 <span class="comment">/*! \file</span><a name="l00005"></a>00005 <span class="comment">*/</span><a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="preprocessor">#include "<a class="code" href="cryptlib_8h.html">cryptlib.h</a>"</span><a name="l00008"></a>00008 <span class="preprocessor">#include "secblock.h"</span><a name="l00009"></a>00009 <span class="preprocessor">#include "misc.h"</span><a name="l00010"></a>00010 <span class="preprocessor">#include "<a class="code" href="strciphr_8h.html">strciphr.h</a>"</span><a name="l00011"></a>00011 <span class="preprocessor">#include "argnames.h"</span><a name="l00012"></a>00012 <span class="preprocessor">#include "algparam.h"</span><a name="l00013"></a>00013 <a name="l00014"></a>00014 NAMESPACE_BEGIN(CryptoPP)<a name="l00015"></a>00015 <a name="l00016"></a>00016 <span class="comment">//! Cipher mode documentation. See NIST SP 800-38A for definitions of these modes.</span><a name="l00017"></a>00017 <span class="comment"></span><span class="comment"></span><a name="l00018"></a>00018 <span class="comment">/*! Each class derived from this one defines two types, Encryption and Decryption, </span><a name="l00019"></a>00019 <span class="comment"> both of which implement the SymmetricCipher interface.</span><a name="l00020"></a>00020 <span class="comment"> For each mode there are two classes, one of which is a template class,</span><a name="l00021"></a>00021 <span class="comment"> and the other one has a name that ends in "_ExternalCipher".</span><a name="l00022"></a>00022 <span class="comment"> The "external cipher" mode objects hold a reference to the underlying block cipher,</span><a name="l00023"></a>00023 <span class="comment"> instead of holding an instance of it. The reference must be passed in to the constructor.</span><a name="l00024"></a>00024 <span class="comment"> For the "cipher holder" classes, the CIPHER template parameter should be a class</span><a name="l00025"></a>00025 <span class="comment"> derived from BlockCipherDocumentation, for example DES or AES.</span><a name="l00026"></a>00026 <span class="comment">*/</span><a name="l00027"></a><a class="code" href="struct_cipher_mode_documentation.html">00027</a> struct <a class="code" href="struct_cipher_mode_documentation.html" title="Cipher mode documentation. See NIST SP 800-38A for definitions of these modes.">CipherModeDocumentation</a> : public <a class="code" href="struct_symmetric_cipher_documentation.html" title="Each class derived from this one defines two types, Encryption and Decryption, both...">SymmetricCipherDocumentation</a><a name="l00028"></a>00028 {<a name="l00029"></a>00029 };<a name="l00030"></a>00030 <a name="l00031"></a><a class="code" href="class_cipher_mode_base.html">00031</a> <span class="keyword">class </span>CRYPTOPP_DLL CRYPTOPP_NO_VTABLE <a class="code" href="class_cipher_mode_base.html">CipherModeBase</a> : <span class="keyword">public</span> <a class="code" href="class_symmetric_cipher.html" title="interface for one direction (encryption or decryption) of a stream cipher or cipher...">SymmetricCipher</a><a name="l00032"></a>00032 {<a name="l00033"></a>00033 <span class="keyword">public</span>:<a name="l00034"></a><a class="code" href="class_cipher_mode_base.html#ca95bcde5d8f5be6f45c216c1d7b21f6">00034</a> <span class="keywordtype">size_t</span> <a class="code" href="class_simple_keying_interface.html#b9e027a141d40929fef51343064d1a69" title="returns smallest valid key length in bytes */">MinKeyLength</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_cipher->MinKeyLength();}<a name="l00035"></a><a class="code" href="class_cipher_mode_base.html#8e801b0482663c7feae7db35e31d2508">00035</a> <span class="keywordtype">size_t</span> <a class="code" href="class_simple_keying_interface.html#99ebc91e778d51d8481c4c4e8403508b" title="returns largest valid key length in bytes */">MaxKeyLength</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_cipher->MaxKeyLength();}<a name="l00036"></a><a class="code" href="class_cipher_mode_base.html#9b16d528a9a2657a7efbd85e45a80571">00036</a> <span class="keywordtype">size_t</span> <a class="code" href="class_simple_keying_interface.html#f900bd0bce7f925cfe8c6002b828d810" title="returns default (recommended) key length in bytes */">DefaultKeyLength</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_cipher->DefaultKeyLength();}<a name="l00037"></a><a class="code" href="class_cipher_mode_base.html#0d81c8b9da00b08f0696603e4992c57a">00037</a> <span class="keywordtype">size_t</span> <a class="code" href="class_simple_keying_interface.html#d4fb24fe36b6396c361d83dcc8c647f0" title="returns the smallest valid key length in bytes that is >= min(n, GetMaxKeyLength())...">GetValidKeyLength</a>(<span class="keywordtype">size_t</span> n)<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_cipher->GetValidKeyLength(n);}<a name="l00038"></a><a class="code" href="class_cipher_mode_base.html#47431eef8c1e41afd62b99a9e9202b58">00038</a> <span class="keywordtype">bool</span> <a class="code" href="class_simple_keying_interface.html#2229cdb9d7ac7e2cf3b02b39ae59ad77" title="returns whether n is a valid key length">IsValidKeyLength</a>(<span class="keywordtype">size_t</span> n)<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_cipher->IsValidKeyLength(n);}<a name="l00039"></a>00039 <a name="l00040"></a><a class="code" href="class_cipher_mode_base.html#c534eff2d4e72b61cc848af0f94805de">00040</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_stream_transformation.html#b9e603c24d02c4538b77b9d59f36310e" title="returns how input should be aligned for optimal performance">OptimalDataAlignment</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> BlockSize();}<a name="l00041"></a>00041 <a name="l00042"></a><a class="code" href="class_cipher_mode_base.html#07313a860fd63d27f9b7aeeb8c2b36c2">00042</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_simple_keying_interface.html#c6da9a8d3c783014ab54a2a3ee9e676a" title="returns size of IVs used by this object">IVSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> BlockSize();}<a name="l00043"></a>00043 <span class="keyword">virtual</span> IV_Requirement <a class="code" href="class_simple_keying_interface.html#22087180aa396209403b0852e9efc431" title="returns the minimal requirement for secure IVs">IVRequirement</a>() <span class="keyword">const</span> =0;<a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="keyword">protected</span>:<a name="l00046"></a><a class="code" href="class_cipher_mode_base.html#6d0a5b8deef965aa690441541c5a7aa7">00046</a> <span class="keyword">inline</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> BlockSize()<span class="keyword"> const </span>{assert(m_register.size() > 0); <span class="keywordflow">return</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)m_register.size();}<a name="l00047"></a><a class="code" href="class_cipher_mode_base.html#687cdab140bc5c733bc43299a97c2a17">00047</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> SetFeedbackSize(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> feedbackSize)<a name="l00048"></a>00048 {<a name="l00049"></a>00049 <span class="keywordflow">if</span> (!(feedbackSize == 0 || feedbackSize == BlockSize()))<a name="l00050"></a>00050 <span class="keywordflow">throw</span> <a class="code" href="class_invalid_argument.html" title="exception thrown when an invalid argument is detected">InvalidArgument</a>(<span class="stringliteral">"CipherModeBase: feedback size cannot be specified for this cipher mode"</span>);<a name="l00051"></a>00051 }<a name="l00052"></a><a class="code" href="class_cipher_mode_base.html#8c864c16ce0eb014699c0a61adcc6836">00052</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> ResizeBuffers()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -