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

📄 safer_8h-source.html

📁 Crypto++是一个非常强大的密码学库,主要是功能全
💻 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++: safer.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&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Compound&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Compound&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div><h1>safer.h</h1><a href="safer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#ifndef CRYPTOPP_SAFER_H</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_SAFER_H</span>00003 <span class="preprocessor"></span><span class="comment"></span>00004 <span class="comment">/** \file</span>00005 <span class="comment">*/</span>00006 00007 <span class="preprocessor">#include "seckey.h"</span>00008 <span class="preprocessor">#include "secblock.h"</span>00009 00010 NAMESPACE_BEGIN(CryptoPP)00011 00012 <span class="comment">/// base class, do not use directly</span><a name="l00013"></a><a class="code" href="class_s_a_f_e_r.html">00013</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_s_a_f_e_r.html">SAFER</a>00014 {00015 <span class="keyword">public</span>:00016         <span class="keyword">class </span>Base : <span class="keyword">public</span> <a class="code" href="class_block_cipher.html">BlockCipher</a>00017         {00018         <span class="keyword">public</span>:00019                 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> GetAlignment()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1;}00020                 <span class="keywordtype">void</span> UncheckedSetKey(<a class="code" href="cryptlib_8h.html#a11">CipherDir</a> dir, <span class="keyword">const</span> byte *userkey, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length, <span class="keywordtype">unsigned</span> nof_rounds);00021 00022                 <span class="keywordtype">bool</span> strengthened;00023                 <a class="code" href="class_sec_block.html">SecByteBlock</a> keySchedule;00024                 <span class="keyword">static</span> <span class="keyword">const</span> byte exp_tab[256];00025                 <span class="keyword">static</span> <span class="keyword">const</span> byte log_tab[256];00026         };00027 00028         <span class="keyword">class </span>Enc : <span class="keyword">public</span> Base00029         {00030         <span class="keyword">public</span>:00031                 <span class="keywordtype">void</span> ProcessAndXorBlock(<span class="keyword">const</span> byte *inBlock, <span class="keyword">const</span> byte *xorBlock, byte *outBlock) <span class="keyword">const</span>;00032         };00033 00034         <span class="keyword">class </span>Dec : <span class="keyword">public</span> Base00035         {00036         <span class="keyword">public</span>:00037                 <span class="keywordtype">void</span> ProcessAndXorBlock(<span class="keyword">const</span> byte *inBlock, <span class="keyword">const</span> byte *xorBlock, byte *outBlock) <span class="keyword">const</span>;00038         };00039 };00040 00041 <span class="keyword">struct </span>SAFER_K_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a>&lt;8&gt;, <span class="keyword">public</span> <a class="code" href="class_variable_key_length.html">VariableKeyLength</a>&lt;16, 8, 16, 8&gt;, <span class="keyword">public</span> <a class="code" href="class_variable_rounds.html">VariableRounds</a>&lt;10, 1, 13&gt;00042 {00043         <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"SAFER-K"</span>;}00044         <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> DefaultRounds(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> keylength) {<span class="keywordflow">return</span> keylength == 8 ? 6 : 10;}00045 };00046 <span class="comment"></span>00047 <span class="comment">/// &lt;a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K"&gt;SAFER-K&lt;/a&gt;</span><a name="l00048"></a><a class="code" href="class_s_a_f_e_r___k.html">00048</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_s_a_f_e_r___k.html">SAFER_K</a> : <span class="keyword">public</span> SAFER_K_Info, <span class="keyword">public</span> <a class="code" href="class_s_a_f_e_r.html">SAFER</a>, <span class="keyword">public</span> <a class="code" href="struct_block_cipher_documentation.html">BlockCipherDocumentation</a>00049 {00050         <span class="keyword">class </span>Enc : <span class="keyword">public</span> BlockCipherBaseTemplate&lt;SAFER_K_Info, SAFER::Enc&gt;00051         {00052         <span class="keyword">public</span>:00053                 Enc() {strengthened = <span class="keyword">false</span>;}00054         };00055 00056         <span class="keyword">class </span>Dec : <span class="keyword">public</span> BlockCipherBaseTemplate&lt;SAFER_K_Info, SAFER::Dec&gt;00057         {00058         <span class="keyword">public</span>:00059                 Dec() {strengthened = <span class="keyword">false</span>;}00060         };00061 00062 <span class="keyword">public</span>:<a name="l00063"></a><a class="code" href="class_s_a_f_e_r___k.html#_s_a_f_e_r___kw0">00063</a>         <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate&lt;ENCRYPTION, Enc&gt;</a> <a class="code" href="class_block_cipher_template.html">Encryption</a>;<a name="l00064"></a><a class="code" href="class_s_a_f_e_r___k.html#_s_a_f_e_r___kw1">00064</a>         <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate&lt;DECRYPTION, Dec&gt;</a> <a class="code" href="class_block_cipher_template.html">Decryption</a>;00065 };00066 00067 <span class="keyword">struct </span>SAFER_SK_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a>&lt;8&gt;, <span class="keyword">public</span> <a class="code" href="class_variable_key_length.html">VariableKeyLength</a>&lt;16, 8, 16, 8&gt;, <span class="keyword">public</span> <a class="code" href="class_variable_rounds.html">VariableRounds</a>&lt;10, 1, 13&gt;00068 {00069         <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"SAFER-SK"</span>;}00070         <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> DefaultRounds(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> keylength) {<span class="keywordflow">return</span> keylength == 8 ? 8 : 10;}00071 };00072 <span class="comment"></span>00073 <span class="comment">/// &lt;a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK"&gt;SAFER-SK&lt;/a&gt;</span><a name="l00074"></a><a class="code" href="class_s_a_f_e_r___s_k.html">00074</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_s_a_f_e_r___s_k.html">SAFER_SK</a> : <span class="keyword">public</span> SAFER_SK_Info, <span class="keyword">public</span> <a class="code" href="class_s_a_f_e_r.html">SAFER</a>, <span class="keyword">public</span> <a class="code" href="struct_block_cipher_documentation.html">BlockCipherDocumentation</a>00075 {00076         <span class="keyword">class </span>Enc : <span class="keyword">public</span> BlockCipherBaseTemplate&lt;SAFER_SK_Info, SAFER::Enc&gt;00077         {00078         <span class="keyword">public</span>:00079                 Enc() {strengthened = <span class="keyword">true</span>;}00080         };00081 00082         <span class="keyword">class </span>Dec : <span class="keyword">public</span> BlockCipherBaseTemplate&lt;SAFER_SK_Info, SAFER::Dec&gt;00083         {00084         <span class="keyword">public</span>:00085                 Dec() {strengthened = <span class="keyword">true</span>;}00086         };00087 00088 <span class="keyword">public</span>:<a name="l00089"></a><a class="code" href="class_s_a_f_e_r___s_k.html#_s_a_f_e_r___s_kw0">00089</a>         <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate&lt;ENCRYPTION, Enc&gt;</a> <a class="code" href="class_block_cipher_template.html">Encryption</a>;<a name="l00090"></a><a class="code" href="class_s_a_f_e_r___s_k.html#_s_a_f_e_r___s_kw1">00090</a>         <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate&lt;DECRYPTION, Dec&gt;</a> <a class="code" href="class_block_cipher_template.html">Decryption</a>;00091 };00092 00093 <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">SAFER_K::Encryption</a> <a class="code" href="class_block_cipher_template.html">SAFER_K_Encryption</a>;00094 <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">SAFER_K::Decryption</a> <a class="code" href="class_block_cipher_template.html">SAFER_K_Decryption</a>;00095 00096 <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">SAFER_SK::Encryption</a> <a class="code" href="class_block_cipher_template.html">SAFER_SK_Encryption</a>;00097 <span class="keyword">typedef</span> <a class="code" href="class_block_cipher_template.html">SAFER_SK::Decryption</a> <a class="code" href="class_block_cipher_template.html">SAFER_SK_Decryption</a>;00098 00099 NAMESPACE_END00100 00101 <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 + -