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

📄 esign_8cpp-source.html

📁 Crypto++是一个非常强大的密码学库,主要是功能全
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00106                 UnalignedPutWord(BIG_ENDIAN_ORDER, seed, (word32)1);00107                 m_q.<a class="code" href="class_integer.html#_integerz43_14">GenerateRandom</a>(rng, CombinedNameValuePairs(primeParam, MakeParameters(<span class="stringliteral">"Seed"</span>, <a class="code" href="class_const_byte_array_parameter.html">ConstByteArrayParameter</a>(seed))));00108         }00109         <span class="keywordflow">else</span>00110         {00111                 m_p.<a class="code" href="class_integer.html#_integerz43_14">GenerateRandom</a>(rng, primeParam);00112                 m_q.<a class="code" href="class_integer.html#_integerz43_14">GenerateRandom</a>(rng, primeParam);00113         }00114 00115         m_n = m_p * m_p * m_q;00116 00117         assert(m_n.<a class="code" href="class_integer.html#_integerz41_2">BitCount</a>() == modulusSize);00118 }00119 <a name="l00120"></a><a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona2">00120</a> <span class="keywordtype">void</span> <a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona2">InvertibleESIGNFunction::BERDecode</a>(<a class="code" href="class_buffered_transformation.html">BufferedTransformation</a> &amp;bt)00121 {00122         <a class="code" href="class_b_e_r_sequence_decoder.html">BERSequenceDecoder</a> privateKey(bt);00123                 m_n.<a class="code" href="class_integer.html#_integerz39_9">BERDecode</a>(privateKey);00124                 m_e.<a class="code" href="class_integer.html#_integerz39_9">BERDecode</a>(privateKey);00125                 m_p.<a class="code" href="class_integer.html#_integerz39_9">BERDecode</a>(privateKey);00126                 m_q.<a class="code" href="class_integer.html#_integerz39_9">BERDecode</a>(privateKey);00127         privateKey.<a class="code" href="class_b_e_r_general_decoder.html#_b_e_r_set_decodera9">MessageEnd</a>();00128 }00129 <a name="l00130"></a><a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona3">00130</a> <span class="keywordtype">void</span> <a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona3">InvertibleESIGNFunction::DEREncode</a>(<a class="code" href="class_buffered_transformation.html">BufferedTransformation</a> &amp;bt)<span class="keyword"> const</span>00131 <span class="keyword"></span>{00132         <a class="code" href="class_d_e_r_sequence_encoder.html">DERSequenceEncoder</a> privateKey(bt);00133                 m_n.<a class="code" href="class_integer.html#_integerz39_3">DEREncode</a>(privateKey);00134                 m_e.<a class="code" href="class_integer.html#_integerz39_3">DEREncode</a>(privateKey);00135                 m_p.<a class="code" href="class_integer.html#_integerz39_3">DEREncode</a>(privateKey);00136                 m_q.<a class="code" href="class_integer.html#_integerz39_3">DEREncode</a>(privateKey);00137         privateKey.<a class="code" href="class_d_e_r_general_encoder.html#_d_e_r_set_encodera2">MessageEnd</a>();00138 }00139 00140 <a class="code" href="class_integer.html">Integer</a> InvertibleESIGNFunction::CalculateRandomizedInverse(<a class="code" href="class_random_number_generator.html">RandomNumberGenerator</a> &amp;rng, <span class="keyword">const</span> <a class="code" href="class_integer.html">Integer</a> &amp;x)<span class="keyword"> const </span>00141 <span class="keyword"></span>{00142         DoQuickSanityCheck();00143 00144         <a class="code" href="class_integer.html">Integer</a> pq = m_p * m_q;00145         <a class="code" href="class_integer.html">Integer</a> p2 = m_p * m_p;00146         <a class="code" href="class_integer.html">Integer</a> r, z, re, a, w0, w1;00147 00148         <span class="keywordflow">do</span>00149         {00150                 r.<a class="code" href="class_integer.html#_integerz43_10">Randomize</a>(rng, Integer::Zero(), pq);00151                 z = x &lt;&lt; (2*GetK()+2);00152                 re = a_exp_b_mod_c(r, m_e, m_n);00153                 a = (z - re) % m_n;00154                 <a class="code" href="class_integer.html#_integerz49_9">Integer::Divide</a>(w1, w0, a, pq);00155                 <span class="keywordflow">if</span> (w1.<a class="code" href="class_integer.html#_integerz41_9">NotZero</a>())00156                 {00157                         ++w0;00158                         w1 = pq - w1;00159                 }00160         }00161         <span class="keywordflow">while</span> ((w1 &gt;&gt; 2*GetK()+1).IsPositive());00162 00163         <a class="code" href="class_modular_arithmetic.html">ModularArithmetic</a> modp(m_p);00164         <a class="code" href="class_integer.html">Integer</a> t = modp.<a class="code" href="class_modular_arithmetic.html#_montgomery_representationa37">Divide</a>(w0 * r % m_p, m_e * re % m_p);00165         <a class="code" href="class_integer.html">Integer</a> s = r + t*pq;00166         assert(s &lt; m_n);00167 <span class="comment">/*</span>00168 <span class="comment">        using namespace std;</span>00169 <span class="comment">        cout &lt;&lt; "f = " &lt;&lt; x &lt;&lt; endl;</span>00170 <span class="comment">        cout &lt;&lt; "r = " &lt;&lt; r &lt;&lt; endl;</span>00171 <span class="comment">        cout &lt;&lt; "z = " &lt;&lt; z &lt;&lt; endl;</span>00172 <span class="comment">        cout &lt;&lt; "a = " &lt;&lt; a &lt;&lt; endl;</span>00173 <span class="comment">        cout &lt;&lt; "w0 = " &lt;&lt; w0 &lt;&lt; endl;</span>00174 <span class="comment">        cout &lt;&lt; "w1 = " &lt;&lt; w1 &lt;&lt; endl;</span>00175 <span class="comment">        cout &lt;&lt; "t = " &lt;&lt; t &lt;&lt; endl;</span>00176 <span class="comment">        cout &lt;&lt; "s = " &lt;&lt; s &lt;&lt; endl;</span>00177 <span class="comment">*/</span>00178         <span class="keywordflow">return</span> s;00179 }00180 <a name="l00181"></a><a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona5">00181</a> <span class="keywordtype">bool</span> <a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona5">InvertibleESIGNFunction::Validate</a>(<a class="code" href="class_random_number_generator.html">RandomNumberGenerator</a> &amp;rng, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level)<span class="keyword"> const</span>00182 <span class="keyword"></span>{00183         <span class="keywordtype">bool</span> pass = <a class="code" href="class_e_s_i_g_n_function.html#_e_s_i_g_n_functiona3">ESIGNFunction::Validate</a>(rng, level);00184         pass = pass &amp;&amp; m_p &gt; <a class="code" href="class_integer.html#_integerz37_11">Integer::One</a>() &amp;&amp; m_p.<a class="code" href="class_integer.html#_integerz41_15">IsOdd</a>() &amp;&amp; m_p &lt; m_n;00185         pass = pass &amp;&amp; m_q &gt; <a class="code" href="class_integer.html#_integerz37_11">Integer::One</a>() &amp;&amp; m_q.<a class="code" href="class_integer.html#_integerz41_15">IsOdd</a>() &amp;&amp; m_q &lt; m_n;00186         pass = pass &amp;&amp; m_p.BitCount() == m_q.BitCount();00187         <span class="keywordflow">if</span> (level &gt;= 1)00188                 pass = pass &amp;&amp; m_p * m_p * m_q == m_n;00189         <span class="keywordflow">if</span> (level &gt;= 2)00190                 pass = pass &amp;&amp; VerifyPrime(rng, m_p, level-2) &amp;&amp; VerifyPrime(rng, m_q, level-2);00191         <span class="keywordflow">return</span> pass;00192 }00193 <a name="l00194"></a><a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona6">00194</a> <span class="keywordtype">bool</span> <a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona6">InvertibleESIGNFunction::GetVoidValue</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keyword">const</span> std::type_info &amp;valueType, <span class="keywordtype">void</span> *pValue)<span class="keyword"> const</span>00195 <span class="keyword"></span>{00196         <span class="keywordflow">return</span> GetValueHelper&lt;ESIGNFunction&gt;(<span class="keyword">this</span>, name, valueType, pValue).Assignable()00197                 CRYPTOPP_GET_FUNCTION_ENTRY(<a class="code" href="namespace_name.html#a24">Prime1</a>)00198                 CRYPTOPP_GET_FUNCTION_ENTRY(<a class="code" href="namespace_name.html#a25">Prime2</a>)00199                 ;00200 }00201 <a name="l00202"></a><a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona7">00202</a> <span class="keywordtype">void</span> <a class="code" href="class_invertible_e_s_i_g_n_function.html#_invertible_e_s_i_g_n_functiona7">InvertibleESIGNFunction::AssignFrom</a>(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html">NameValuePairs</a> &amp;source)00203 {00204         AssignFromHelper&lt;ESIGNFunction&gt;(<span class="keyword">this</span>, source)00205                 CRYPTOPP_SET_FUNCTION_ENTRY(<a class="code" href="namespace_name.html#a24">Prime1</a>)00206                 CRYPTOPP_SET_FUNCTION_ENTRY(<a class="code" href="namespace_name.html#a25">Prime2</a>)00207                 ;00208 }00209 00210 NAMESPACE_END</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:14 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 + -