⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 seckey_8h-source.html

📁 Crypto++是一个非常强大的密码学库,主要是功能全
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00123 00124 <span class="comment">// ************** implementation helper for SimpledKeyed ***************</span>00125 00126 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;00127 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> CheckedSetKey(T *obj, 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> &amp;param)00128 {00129         obj-&gt;ThrowIfInvalidKeyLength(length);00130         obj-&gt;UncheckedSetKey(key, length);00131 }00132 00133 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;00134 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> CheckedSetKey(T *obj, CipherDir dir, <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> &amp;param)00135 {00136         obj-&gt;ThrowIfInvalidKeyLength(length);00137         obj-&gt;UncheckedSetKey(dir, key, length);00138 }00139 <span class="comment"></span>00140 <span class="comment">//! .</span>00141 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keyword">class</span> BASE, <span class="keyword">class</span> INFO = BASE&gt;<a name="l00142"></a><a class="code" href="class_simple_keying_interface_impl.html">00142</a> <span class="keyword">class </span><a class="code" href="class_simple_keying_interface_impl.html">SimpleKeyingInterfaceImpl</a> : <span class="keyword">public</span> BASE00143 {00144 <span class="keyword">public</span>:00145         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MinKeyLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::MIN_KEYLENGTH;}00146         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MaxKeyLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::MAX_KEYLENGTH;}00147         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> DefaultKeyLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::DEFAULT_KEYLENGTH;}00148         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetValidKeyLength(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n)<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::StaticGetValidKeyLength(n);}00149         <span class="keyword">typename</span> BASE::IV_Requirement IVRequirement()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<span class="keyword">typename</span> BASE::IV_Requirement)INFO::IV_REQUIREMENT;}00150 00151 <span class="keyword">protected</span>:00152         <span class="keywordtype">void</span> AssertValidKeyLength(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length) {assert(GetValidKeyLength(length) == length);}00153 };00154 00155 <span class="keyword">template</span> &lt;<span class="keyword">class</span> INFO, <span class="keyword">class</span> BASE = BlockCipher&gt;00156 <span class="keyword">class </span>BlockCipherBaseTemplate : <span class="keyword">public</span> AlgorithmImpl&lt;SimpleKeyingInterfaceImpl&lt;BASE, INFO&gt;, INFO&gt;, <span class="keyword">public</span> INFO00157 {00158 <span class="keyword">public</span>:00159         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="namespace_name.html#a9">BlockSize</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> BLOCKSIZE;}00160 };00161 00162 <span class="comment">/*</span>00163 <span class="comment">#define CRYPTOPP_DLL_TEMPLATE_CLASS_BlockCipherBaseTemplate(Info)       \</span>00164 <span class="comment">CRYPTOPP_DLL_TEMPLATE_CLASS TwoBases&lt;Info, BlockCipher&gt;;        \</span>00165 <span class="comment">CRYPTOPP_DLL_TEMPLATE_CLASS SimpleKeyingInterfaceImpl&lt;TwoBases&lt;Info, BlockCipher&gt; &gt;;    \</span>00166 <span class="comment">CRYPTOPP_DLL_TEMPLATE_CLASS AlgorithmImpl&lt;SimpleKeyingInterfaceImpl&lt;TwoBases&lt;Info, BlockCipher&gt; &gt; &gt;;    \</span>00167 <span class="comment">CRYPTOPP_DLL_TEMPLATE_CLASS BlockCipherBaseTemplate&lt;Info&gt;;</span>00168 <span class="comment">*/</span>00169 <span class="comment"></span>00170 <span class="comment">//! .</span>00171 <span class="comment"></span><span class="keyword">template</span> &lt;CipherDir DIR, <span class="keyword">class</span> BASE&gt;<a name="l00172"></a><a class="code" href="class_block_cipher_template.html">00172</a> <span class="keyword">class </span><a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a> : <span class="keyword">public</span> BASE00173 {00174 <span class="keyword">public</span>:00175         <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a>() {}00176         <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a>(<span class="keyword">const</span> byte *key)00177                 {SetKey(key, DEFAULT_KEYLENGTH);}00178         <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length)00179                 {SetKey(key, length);}00180         <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> rounds)00181                 {SetKeyWithRounds(key, length, rounds);}00182 00183         <span class="keywordtype">bool</span> IsForwardTransformation()<span class="keyword"> const </span>{<span class="keywordflow">return</span> DIR == ENCRYPTION;}00184 00185         <span class="keywordtype">void</span> SetKey(<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> &amp;param = g_nullNameValuePairs)00186         {00187                 CheckedSetKey(<span class="keyword">this</span>, DIR, key, length, param);00188         }00189 00190         <a class="code" href="class_clonable.html">Clonable</a> * Clone() {<span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate&lt;DIR, BASE&gt;</a>(*this);}00191 };00192 <span class="comment"></span>00193 <span class="comment">//! .</span>00194 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keyword">class</span> BASE, <span class="keyword">class</span> INFO = BASE&gt;<a name="l00195"></a><a class="code" href="class_message_authentication_code_final_template.html">00195</a> <span class="keyword">class </span><a class="code" href="class_message_authentication_code_final_template.html">MessageAuthenticationCodeFinalTemplate</a> : <span class="keyword">public</span> 00196 #ifdef CRYPTOPP_DOXYGEN_PROCESSING00197         <a class="code" href="class_message_authentication_code.html">MessageAuthenticationCode</a>00198 #else00199         AlgorithmImpl&lt;SimpleKeyingInterfaceImpl&lt;BASE, INFO&gt;, INFO&gt;00200 #endif00201 {00202 <span class="keyword">public</span>:00203         <a class="code" href="class_message_authentication_code_final_template.html">MessageAuthenticationCodeFinalTemplate</a>() {}00204         <a class="code" href="class_message_authentication_code_final_template.html">MessageAuthenticationCodeFinalTemplate</a>(<span class="keyword">const</span> byte *key)00205                 {<a class="code" href="class_message_authentication_code_final_template.html#_message_authentication_code_final_templatea3">SetKey</a>(key, DEFAULT_KEYLENGTH);}00206         <a class="code" href="class_message_authentication_code_final_template.html">MessageAuthenticationCodeFinalTemplate</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length)00207                 {<a class="code" href="class_message_authentication_code_final_template.html#_message_authentication_code_final_templatea3">SetKey</a>(key, length);}00208 <a name="l00209"></a><a class="code" href="class_message_authentication_code_final_template.html#_message_authentication_code_final_templatea3">00209</a>         <span class="keywordtype">void</span> <a class="code" href="class_message_authentication_code_final_template.html#_message_authentication_code_final_templatea3">SetKey</a>(<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> &amp;param = g_nullNameValuePairs)00210         {00211                 CheckedSetKey(<span class="keyword">this</span>, Empty(), key, length, param);00212         }00213 00214         <a class="code" href="class_clonable.html">Clonable</a> * <a class="code" href="class_clonable.html#_zlib_decompressora18">Clone</a>() {<span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_message_authentication_code_final_template.html">MessageAuthenticationCodeFinalTemplate&lt;BASE, INFO&gt;</a>(*this);}00215 };00216 00217 <span class="comment">// ************** documentation ***************</span>00218 <span class="comment"></span>00219 <span class="comment">//! These objects usually should not be used directly. See CipherModeDocumentation instead.</span>00220 <span class="comment"></span><span class="comment">/*! Each class derived from this one defines two types, Encryption and Decryption, </span>00221 <span class="comment">        both of which implement the BlockCipher interface. */</span><a name="l00222"></a><a class="code" href="struct_block_cipher_documentation.html">00222</a> <span class="keyword">struct </span><a class="code" href="struct_block_cipher_documentation.html">BlockCipherDocumentation</a>00223 {<span class="comment"></span>00224 <span class="comment">        //! implements the BlockCipher interface</span><a name="l00225"></a><a class="code" href="struct_block_cipher_documentation.html#_r_c2w4">00225</a> <span class="comment"></span>        <span class="keyword">typedef</span> <a class="code" href="class_block_cipher.html">BlockCipher</a> <a class="code" href="class_block_cipher.html">Encryption</a>;<span class="comment"></span>00226 <span class="comment">        //! implements the BlockCipher interface</span><a name="l00227"></a><a class="code" href="struct_block_cipher_documentation.html#_r_c2w5">00227</a> <span class="comment"></span>        <span class="keyword">typedef</span> <a class="code" href="class_block_cipher.html">BlockCipher</a> <a class="code" href="class_block_cipher.html">Decryption</a>;00228 };00229 <span class="comment"></span>00230 <span class="comment">/*! \brief Each class derived from this one defines two types, Encryption and Decryption, </span>00231 <span class="comment">        both of which implement the SymmetricCipher interface. See CipherModeDocumentation</span>00232 <span class="comment">        for information about using block ciphers. */</span><a name="l00233"></a><a class="code" href="struct_symmetric_cipher_documentation.html">00233</a> <span class="keyword">struct </span><a class="code" href="struct_symmetric_cipher_documentation.html">SymmetricCipherDocumentation</a>00234 {<span class="comment"></span>00235 <span class="comment">        //! implements the SymmetricCipher interface</span><a name="l00236"></a><a class="code" href="struct_symmetric_cipher_documentation.html#_symmetric_cipher_documentationw0">00236</a> <span class="comment"></span>        <span class="keyword">typedef</span> <a class="code" href="class_symmetric_cipher.html">SymmetricCipher</a> <a class="code" href="class_symmetric_cipher.html">Encryption</a>;<span class="comment"></span>00237 <span class="comment">        //! implements the SymmetricCipher interface</span><a name="l00238"></a><a class="code" href="struct_symmetric_cipher_documentation.html#_symmetric_cipher_documentationw1">00238</a> <span class="comment"></span>        <span class="keyword">typedef</span> <a class="code" href="class_symmetric_cipher.html">SymmetricCipher</a> <a class="code" href="class_symmetric_cipher.html">Decryption</a>;00239 };00240 00241 NAMESPACE_END00242 00243 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:24 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 + -