📄 rc2_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++: rc2.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>rc2.h</h1><a href="rc2_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="preprocessor">#ifndef CRYPTOPP_RC2_H</span>00002 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_RC2_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="keyword">struct </span>RC2_Info : <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html">FixedBlockSize</a><8>, <span class="keyword">public</span> <a class="code" href="class_variable_key_length.html">VariableKeyLength</a><16, 1, 128>00013 {00014 <span class="keyword">enum</span> {DEFAULT_EFFECTIVE_KEYLENGTH = 1024, MAX_EFFECTIVE_KEYLENGTH = 1024};00015 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *StaticAlgorithmName() {<span class="keywordflow">return</span> <span class="stringliteral">"RC2"</span>;}00016 };00017 <span class="comment"></span>00018 <span class="comment">/// <a href="http://www.weidai.com/scan-mirror/cs.html#RC2">RC2</a></span><a name="l00019"></a><a class="code" href="class_r_c2.html">00019</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_r_c2.html">RC2</a> : <span class="keyword">public</span> RC2_Info, <span class="keyword">public</span> <a class="code" href="struct_block_cipher_documentation.html">BlockCipherDocumentation</a>00020 {00021 <span class="keyword">class </span>Base : <span class="keyword">public</span> BlockCipherBaseTemplate<RC2_Info>00022 {00023 <span class="keyword">public</span>:00024 <span class="keywordtype">void</span> UncheckedSetKey(<a class="code" href="cryptlib_8h.html#a11">CipherDir</a> direction, <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> effectiveKeyLength);00025 <span class="keywordtype">void</span> SetKeyWithEffectiveKeyLength(<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> effectiveKeyLength);00026 00027 <span class="keyword">protected</span>:00028 <span class="keyword">template</span> <<span class="keyword">class</span> T>00029 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> CheckedSetKey(T *obj, <a class="code" href="cryptlib_8h.html#a11">CipherDir</a> 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> &param)00030 {00031 obj->ThrowIfInvalidKeyLength(length);00032 <span class="keywordtype">int</span> effectiveKeyLength = param.<a class="code" href="class_name_value_pairs.html#_x_t_r___d_ha43">GetIntValueWithDefault</a>(<span class="stringliteral">"EffectiveKeyLength"</span>, DEFAULT_EFFECTIVE_KEYLENGTH);00033 obj->SetKeyWithEffectiveKeyLength(key, length, effectiveKeyLength);00034 }00035 00036 FixedSizeSecBlock<word16, 64> K; <span class="comment">// expanded key table</span>00037 };00038 00039 <span class="keyword">class </span>Enc : <span class="keyword">public</span> Base00040 {00041 <span class="keyword">public</span>:00042 <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>;00043 };00044 00045 <span class="keyword">class </span>Dec : <span class="keyword">public</span> Base00046 {00047 <span class="keyword">public</span>:00048 <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>;00049 };00050 00051 <span class="keyword">public</span>:00052 <span class="keyword">class </span>Encryption : <span class="keyword">public</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a><ENCRYPTION, Enc>00053 {00054 <span class="keyword">public</span>:00055 <a class="code" href="struct_block_cipher_documentation.html#_r_c2w4">Encryption</a>() {}00056 <a class="code" href="struct_block_cipher_documentation.html#_r_c2w4">Encryption</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> keyLen=DEFAULT_KEYLENGTH, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> effectiveLen=1024)00057 {SetKeyWithEffectiveKeyLength(key, keyLen, effectiveLen);}00058 };00059 00060 <span class="keyword">class </span>Decryption : <span class="keyword">public</span> <a class="code" href="class_block_cipher_template.html">BlockCipherTemplate</a><DECRYPTION, Dec>00061 {00062 <span class="keyword">public</span>:00063 <a class="code" href="struct_block_cipher_documentation.html#_r_c2w5">Decryption</a>() {}00064 <a class="code" href="struct_block_cipher_documentation.html#_r_c2w5">Decryption</a>(<span class="keyword">const</span> byte *key, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> keyLen=DEFAULT_KEYLENGTH, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> effectiveLen=1024)00065 {SetKeyWithEffectiveKeyLength(key, keyLen, effectiveLen);}00066 };00067 };00068 00069 <span class="keyword">typedef</span> RC2::Encryption RC2Encryption;00070 <span class="keyword">typedef</span> RC2::Decryption RC2Decryption;00071 00072 NAMESPACE_END00073 00074 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:23 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 + -