📄 lubyrack_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++: lubyrack.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>lubyrack.h</h1><a href="lubyrack_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// lubyrack.h - written and placed in the public domain by Wei Dai</span><a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="preprocessor">#ifndef CRYPTOPP_LUBYRACK_H</span><a name="l00004"></a>00004 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_LUBYRACK_H</span><a name="l00005"></a>00005 <span class="preprocessor"></span><span class="comment"></span><a name="l00006"></a>00006 <span class="comment">/** \file */</span><a name="l00007"></a>00007 <a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="simple_8h.html">simple.h</a>"</span><a name="l00009"></a>00009 <span class="preprocessor">#include "secblock.h"</span><a name="l00010"></a>00010 <a name="l00011"></a>00011 NAMESPACE_BEGIN(CryptoPP)<a name="l00012"></a>00012 <a name="l00013"></a><a class="code" href="struct_digest_size_double_workaround.html">00013</a> template <class T> struct <a class="code" href="struct_digest_size_double_workaround.html">DigestSizeDoubleWorkaround</a> <span class="comment">// VC60 workaround</span><a name="l00014"></a>00014 {<a name="l00015"></a><a class="code" href="struct_digest_size_double_workaround.html#e44f2485f1fd3aa36fba4f3a27bb97ba">00015</a> CRYPTOPP_CONSTANT(RESULT = 2*T::DIGESTSIZE)<a name="l00016"></a>00016 };<a name="l00017"></a>00017 <span class="comment"></span><a name="l00018"></a>00018 <span class="comment">//! algorithm info</span><a name="l00019"></a>00019 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> T><a name="l00020"></a><a class="code" href="struct_l_r___info.html">00020</a> <span class="keyword">struct </span><a class="code" href="struct_l_r___info.html" title="algorithm info">LR_Info</a> : <span class="keyword">public</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><16, 0, 2*(INT_MAX/2), 2>, <span class="keyword">public</span> <a class="code" href="class_fixed_block_size.html" title="to be inherited by block ciphers with fixed block size">FixedBlockSize</a><DigestSizeDoubleWorkaround<T>::RESULT><a name="l00021"></a>00021 {<a name="l00022"></a><a class="code" href="struct_l_r___info.html#62a21cb8057cc805c7dc493bd007423a">00022</a> <span class="keyword">static</span> std::string <a class="code" href="struct_l_r___info.html#62a21cb8057cc805c7dc493bd007423a">StaticAlgorithmName</a>() {<span class="keywordflow">return</span> std::string(<span class="stringliteral">"LR/"</span>)+T::StaticAlgorithmName();}<a name="l00023"></a>00023 };<a name="l00024"></a>00024 <span class="comment"></span><a name="l00025"></a>00025 <span class="comment">//! Luby-Rackoff</span><a name="l00026"></a>00026 <span class="comment"></span><span class="keyword">template</span> <<span class="keyword">class</span> T><a name="l00027"></a><a class="code" href="class_l_r.html">00027</a> <span class="keyword">class </span><a class="code" href="class_l_r.html" title="Luby-Rackoff.">LR</a> : <span class="keyword">public</span> <a class="code" href="struct_l_r___info.html" title="algorithm info">LR_Info</a><T>, <span class="keyword">public</span> <a class="code" href="struct_block_cipher_documentation.html" title="These objects usually should not be used directly. See CipherModeDocumentation instead...">BlockCipherDocumentation</a><a name="l00028"></a>00028 {<a name="l00029"></a>00029 <span class="keyword">class </span>CRYPTOPP_NO_VTABLE Base : <span class="keyword">public</span> <a class="code" href="class_block_cipher_impl.html">BlockCipherImpl</a><LR_Info<T> ><a name="l00030"></a>00030 {<a name="l00031"></a>00031 <span class="keyword">public</span>:<a name="l00032"></a>00032 <span class="comment">// VC60 workaround: have to define these functions within class definition</span><a name="l00033"></a>00033 <span class="keywordtype">void</span> UncheckedSetKey(<span class="keyword">const</span> byte *userKey, <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" title="interface for retrieving values given their names">NameValuePairs</a> &params)<a name="l00034"></a>00034 {<a name="l00035"></a>00035 this->AssertValidKeyLength(length);<a name="l00036"></a>00036 <a name="l00037"></a>00037 L = length/2;<a name="l00038"></a>00038 buffer.New(2*S);<a name="l00039"></a>00039 digest.New(S);<a name="l00040"></a>00040 key.Assign(userKey, 2*L);<a name="l00041"></a>00041 }<a name="l00042"></a>00042 <a name="l00043"></a>00043 <span class="keyword">protected</span>:<a name="l00044"></a>00044 CRYPTOPP_CONSTANT(S=T::DIGESTSIZE)<a name="l00045"></a>00045 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> L; <span class="comment">// key length / 2</span><a name="l00046"></a>00046 <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> key;<a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="keyword">mutable</span> T hm;<a name="l00049"></a>00049 <span class="keyword">mutable</span> <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> buffer, digest;<a name="l00050"></a>00050 };<a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="keyword">class </span>CRYPTOPP_NO_VTABLE Enc : <span class="keyword">public</span> Base<a name="l00053"></a>00053 {<a name="l00054"></a>00054 <span class="keyword">public</span>:<a name="l00055"></a>00055 <a name="l00056"></a><a class="code" href="lubyrack_8h.html#81a7c36ecc75b2f02c2b6d2d6d49778e">00056</a> <span class="preprocessor">#define KL this->key</span><a name="l00057"></a><a class="code" href="lubyrack_8h.html#76f9425f5a9151312ae472a45a03b60c">00057</a> <span class="preprocessor"></span><span class="preprocessor">#define KR this->key+this->L</span><a name="l00058"></a><a class="code" href="lubyrack_8h.html#d567ea9864a3046e47ab69cdc050ecfa">00058</a> <span class="preprocessor"></span><span class="preprocessor">#define BL this->buffer</span><a name="l00059"></a><a class="code" href="lubyrack_8h.html#fa556a68b7c0fcc58cd87c5f36859f30">00059</a> <span class="preprocessor"></span><span class="preprocessor">#define BR this->buffer+this->S</span><a name="l00060"></a><a class="code" href="lubyrack_8h.html#a897a1a84f3d28807d788a018373469e">00060</a> <span class="preprocessor"></span><span class="preprocessor">#define IL inBlock</span><a name="l00061"></a><a class="code" href="lubyrack_8h.html#68e22635ff207d8ca10459833856bd75">00061</a> <span class="preprocessor"></span><span class="preprocessor">#define IR inBlock+this->S</span><a name="l00062"></a><a class="code" href="lubyrack_8h.html#c6afe0e55da5e0e43535ed27c26b55a3">00062</a> <span class="preprocessor"></span><span class="preprocessor">#define OL outBlock</span><a name="l00063"></a><a class="code" href="lubyrack_8h.html#3363ca4d6d3cc0230b2804280591c991">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define OR outBlock+this->S</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -