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

📄 seckey_8h-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<a name="l00060"></a>00060 };<a name="l00061"></a>00061 <a name="l00062"></a>00062 <span class="comment">// ************** key length ***************</span><a name="l00063"></a>00063 <span class="comment"></span><a name="l00064"></a>00064 <span class="comment">//! to be inherited by keyed algorithms with fixed key length</span><a name="l00065"></a>00065 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> N, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IV_L = 0&gt;<a name="l00066"></a><a class="code" href="class_fixed_key_length.html">00066</a> <span class="keyword">class </span><a class="code" href="class_fixed_key_length.html" title="to be inherited by keyed algorithms with fixed key length">FixedKeyLength</a><a name="l00067"></a>00067 {<a name="l00068"></a>00068 <span class="keyword">public</span>:<a name="l00069"></a><a class="code" href="class_fixed_key_length.html#b994d881a105849f64a973373e8f282c">00069</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_fixed_key_length.html#b994d881a105849f64a973373e8f282c">KEYLENGTH</a>=N)<a name="l00070"></a><a class="code" href="class_fixed_key_length.html#198440f34bfe0f343fab3cdbef586a3b">00070</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_fixed_key_length.html#198440f34bfe0f343fab3cdbef586a3b">MIN_KEYLENGTH</a>=N)<a name="l00071"></a><a class="code" href="class_fixed_key_length.html#7c599a7ebb4e0fa4773c4cd1b4023b18">00071</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_fixed_key_length.html#7c599a7ebb4e0fa4773c4cd1b4023b18">MAX_KEYLENGTH</a>=N)<a name="l00072"></a><a class="code" href="class_fixed_key_length.html#1e9951e11c42a0a8c75bd959bcf26f31">00072</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_fixed_key_length.html#1e9951e11c42a0a8c75bd959bcf26f31">DEFAULT_KEYLENGTH</a>=N)<a name="l00073"></a><a class="code" href="class_fixed_key_length.html#b1a634167fe78a3ee06554a268e6d61c">00073</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_fixed_key_length.html#b1a634167fe78a3ee06554a268e6d61c">IV_REQUIREMENT</a> = IV_REQ)<a name="l00074"></a><a class="code" href="class_fixed_key_length.html#467a0101968e4181f770509e19ebef28">00074</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_fixed_key_length.html#467a0101968e4181f770509e19ebef28">IV_LENGTH</a> = IV_L)<a name="l00075"></a><a class="code" href="class_fixed_key_length.html#f6052c926d7d040b524a829e96710496">00075</a>         static <span class="keywordtype">size_t</span> CRYPTOPP_API <a class="code" href="class_fixed_key_length.html#f6052c926d7d040b524a829e96710496">StaticGetValidKeyLength</a>(<span class="keywordtype">size_t</span>) {<span class="keywordflow">return</span> <a class="code" href="class_fixed_key_length.html#b994d881a105849f64a973373e8f282c">KEYLENGTH</a>;}<a name="l00076"></a>00076 };<a name="l00077"></a>00077 <span class="comment"></span><a name="l00078"></a>00078 <span class="comment">/// support query of variable key length, template parameters are default, min, max, multiple (default multiple 1)</span><a name="l00079"></a>00079 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> D, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> N, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> M, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> Q = 1, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IV_L = 0&gt;<a name="l00080"></a><a class="code" href="class_variable_key_length.html">00080</a> <span class="keyword">class </span><a class="code" href="class_variable_key_length.html" title="support query of variable key length, template parameters are default, min, max,...">VariableKeyLength</a><a name="l00081"></a>00081 {<a name="l00082"></a>00082         <span class="comment">// make these private to avoid Doxygen documenting them in all derived classes</span><a name="l00083"></a>00083         CRYPTOPP_COMPILE_ASSERT(Q &gt; 0);<a name="l00084"></a>00084         CRYPTOPP_COMPILE_ASSERT(N % Q == 0);<a name="l00085"></a>00085         CRYPTOPP_COMPILE_ASSERT(M % Q == 0);<a name="l00086"></a>00086         CRYPTOPP_COMPILE_ASSERT(N &lt; M);<a name="l00087"></a>00087         CRYPTOPP_COMPILE_ASSERT(D &gt;= N);<a name="l00088"></a>00088         CRYPTOPP_COMPILE_ASSERT(M &gt;= D);<a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="keyword">public</span>:<a name="l00091"></a><a class="code" href="class_variable_key_length.html#ff5e41e92f02a8bb6a976b748e4e2ec9">00091</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_variable_key_length.html#ff5e41e92f02a8bb6a976b748e4e2ec9">MIN_KEYLENGTH</a>=N)<a name="l00092"></a><a class="code" href="class_variable_key_length.html#26f33392d61edcaa678ae65002842d36">00092</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_variable_key_length.html#26f33392d61edcaa678ae65002842d36">MAX_KEYLENGTH</a>=M)<a name="l00093"></a><a class="code" href="class_variable_key_length.html#3788ee30b190bdc0c0e89d2721162614">00093</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_variable_key_length.html#3788ee30b190bdc0c0e89d2721162614">DEFAULT_KEYLENGTH</a>=D)<a name="l00094"></a><a class="code" href="class_variable_key_length.html#caa6d8918bbd17c2da84e752df7bd285">00094</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_variable_key_length.html#caa6d8918bbd17c2da84e752df7bd285">KEYLENGTH_MULTIPLE</a>=Q)<a name="l00095"></a><a class="code" href="class_variable_key_length.html#efee62ae9b6dd90ede7211844235fc7b">00095</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_variable_key_length.html#efee62ae9b6dd90ede7211844235fc7b">IV_REQUIREMENT</a>=IV_REQ)<a name="l00096"></a><a class="code" href="class_variable_key_length.html#e5687e4a40c5289764feac86eed81cc2">00096</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_variable_key_length.html#e5687e4a40c5289764feac86eed81cc2">IV_LENGTH</a>=IV_L)<a name="l00097"></a>00097 <a name="l00098"></a><a class="code" href="class_variable_key_length.html#5bf532b28513e7e1d3d7202fd044b4c9">00098</a>         static <span class="keywordtype">size_t</span> CRYPTOPP_API <a class="code" href="class_variable_key_length.html#5bf532b28513e7e1d3d7202fd044b4c9">StaticGetValidKeyLength</a>(<span class="keywordtype">size_t</span> n)<a name="l00099"></a>00099         {<a name="l00100"></a>00100                 <span class="keywordflow">if</span> (n &lt; (<span class="keywordtype">size_t</span>)<a class="code" href="class_variable_key_length.html#ff5e41e92f02a8bb6a976b748e4e2ec9">MIN_KEYLENGTH</a>)<a name="l00101"></a>00101                         <span class="keywordflow">return</span> MIN_KEYLENGTH;<a name="l00102"></a>00102                 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (n &gt; (<span class="keywordtype">size_t</span>)<a class="code" href="class_variable_key_length.html#26f33392d61edcaa678ae65002842d36">MAX_KEYLENGTH</a>)<a name="l00103"></a>00103                         <span class="keywordflow">return</span> (<span class="keywordtype">size_t</span>)MAX_KEYLENGTH;<a name="l00104"></a>00104                 <span class="keywordflow">else</span><a name="l00105"></a>00105                 {<a name="l00106"></a>00106                         n += <a class="code" href="class_variable_key_length.html#caa6d8918bbd17c2da84e752df7bd285">KEYLENGTH_MULTIPLE</a>-1;<a name="l00107"></a>00107                         <span class="keywordflow">return</span> n - n%<a class="code" href="class_variable_key_length.html#caa6d8918bbd17c2da84e752df7bd285">KEYLENGTH_MULTIPLE</a>;<a name="l00108"></a>00108                 }<a name="l00109"></a>00109         }<a name="l00110"></a>00110 };<a name="l00111"></a>00111 <span class="comment"></span><a name="l00112"></a>00112 <span class="comment">/// support query of key length that's the same as another class</span><a name="l00113"></a>00113 <span class="comment"></span><span class="keyword">template</span> &lt;<span class="keyword">class</span> T, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IV_REQ = SimpleKeyingInterface::NOT_RESYNCHRONIZABLE, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IV_L = 0&gt;<a name="l00114"></a><a class="code" href="class_same_key_length_as.html">00114</a> <span class="keyword">class </span><a class="code" href="class_same_key_length_as.html" title="support query of key length that's the same as another class">SameKeyLengthAs</a><a name="l00115"></a>00115 {<a name="l00116"></a>00116 <span class="keyword">public</span>:<a name="l00117"></a><a class="code" href="class_same_key_length_as.html#527f2760da06bc768e5dbeab732392ee">00117</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_same_key_length_as.html#527f2760da06bc768e5dbeab732392ee">MIN_KEYLENGTH</a>=T::MIN_KEYLENGTH)<a name="l00118"></a><a class="code" href="class_same_key_length_as.html#a4474256666f0a2fe2428164e95dabb4">00118</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_same_key_length_as.html#a4474256666f0a2fe2428164e95dabb4">MAX_KEYLENGTH</a>=T::<a class="code" href="class_same_key_length_as.html#a4474256666f0a2fe2428164e95dabb4">MAX_KEYLENGTH</a>)<a name="l00119"></a><a class="code" href="class_same_key_length_as.html#2178ba0a86c81fa36ab235c748062b2e">00119</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_same_key_length_as.html#2178ba0a86c81fa36ab235c748062b2e">DEFAULT_KEYLENGTH</a>=T::<a class="code" href="class_same_key_length_as.html#2178ba0a86c81fa36ab235c748062b2e">DEFAULT_KEYLENGTH</a>)<a name="l00120"></a><a class="code" href="class_same_key_length_as.html#1b7699903c1c89fc6c8dcf76ae7abd7c">00120</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_same_key_length_as.html#1b7699903c1c89fc6c8dcf76ae7abd7c">IV_REQUIREMENT</a>=IV_REQ)<a name="l00121"></a><a class="code" href="class_same_key_length_as.html#cb6c95b5e235a10e50dd7e4d25faecfe">00121</a>         CRYPTOPP_CONSTANT(<a class="code" href="class_same_key_length_as.html#cb6c95b5e235a10e50dd7e4d25faecfe">IV_LENGTH</a>=IV_L)<a name="l00122"></a>00122 <a name="l00123"></a><a class="code" href="class_same_key_length_as.html#d1427c116ee54d7bc4309c8dd2ae3531">00123</a>         static <span class="keywordtype">size_t</span> CRYPTOPP_API <a class="code" href="class_same_key_length_as.html#d1427c116ee54d7bc4309c8dd2ae3531">StaticGetValidKeyLength</a>(<span class="keywordtype">size_t</span> keylength)<a name="l00124"></a>00124                 {<span class="keywordflow">return</span> T::StaticGetValidKeyLength(keylength);}<a name="l00125"></a>00125 };<a name="l00126"></a>00126 <a name="l00127"></a>00127 <span class="comment">// ************** implementation helper for SimpleKeyed ***************</span><a name="l00128"></a>00128 <span class="comment"></span><a name="l00129"></a>00129 <span class="comment">//! _</span><a name="l00130"></a>00130 <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="l00131"></a><a class="code" href="class_simple_keying_interface_impl.html">00131</a> <span class="keyword">class </span>CRYPTOPP_NO_VTABLE SimpleKeyingInterfaceImpl : <span class="keyword">public</span> BASE<a name="l00132"></a>00132 {<a name="l00133"></a>00133 <span class="keyword">public</span>:<a name="l00134"></a><a class="code" href="class_simple_keying_interface_impl.html#f3e42c83041a26ffaef5e378e352caa0">00134</a>         <span class="keywordtype">size_t</span> MinKeyLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::MIN_KEYLENGTH;}<a name="l00135"></a><a class="code" href="class_simple_keying_interface_impl.html#c72a5a82d8a5d9e19e18f7e146b35df4">00135</a>         <span class="keywordtype">size_t</span> MaxKeyLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<span class="keywordtype">size_t</span>)INFO::MAX_KEYLENGTH;}<a name="l00136"></a><a class="code" href="class_simple_keying_interface_impl.html#017e0545328286b51892a93f95aabf8e">00136</a>         <span class="keywordtype">size_t</span> DefaultKeyLength()<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::DEFAULT_KEYLENGTH;}<a name="l00137"></a><a class="code" href="class_simple_keying_interface_impl.html#b0d253f0866af8431fcafdfc9d32e888">00137</a>         <span class="keywordtype">size_t</span> GetValidKeyLength(<span class="keywordtype">size_t</span> n)<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::StaticGetValidKeyLength(n);}<a name="l00138"></a><a class="code" href="class_simple_keying_interface_impl.html#f9e6ac5f39488b6a3f8220c539c6cfeb">00138</a>         <a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e">SimpleKeyingInterface::IV_Requirement</a> IVRequirement()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<a class="code" href="class_simple_keying_interface.html#88201c180fbfaa9fef2715252546ad6e">SimpleKeyingInterface::IV_Requirement</a>)INFO::IV_REQUIREMENT;}<a name="l00139"></a><a class="code" href="class_simple_keying_interface_impl.html#cba54a012806e2b2d0f61c1aa64a3a25">00139</a>         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> IVSize()<span class="keyword"> const </span>{<span class="keywordflow">return</span> INFO::IV_LENGTH;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -