Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 07dfcfe50d66c9a48a3c5e6c1693f12a > files > 1879

cryptopp-doc-5.6.1-0.1.svn479.fc13.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Crypto++: rabin.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>rabin.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// rabin.cpp - written and placed in the public domain by Wei Dai</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;pch.h&quot;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;<a class="code" href="rabin_8h.html">rabin.h</a>&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &quot;nbtheory.h&quot;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;asn.h&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;sha.h&quot;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &quot;modarith.h&quot;</span>
<a name="l00009"></a>00009 
<a name="l00010"></a>00010 NAMESPACE_BEGIN(CryptoPP)
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 void <a class="code" href="class_rabin_function.html" title="_">RabinFunction</a>::BERDecode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;bt)
<a name="l00013"></a>00013 {
<a name="l00014"></a>00014         <a class="code" href="class_b_e_r_sequence_decoder.html" title="BER Sequence Decoder.">BERSequenceDecoder</a> seq(bt);
<a name="l00015"></a>00015         m_n.BERDecode(seq);
<a name="l00016"></a>00016         m_r.BERDecode(seq);
<a name="l00017"></a>00017         m_s.BERDecode(seq);
<a name="l00018"></a>00018         seq.MessageEnd();
<a name="l00019"></a>00019 }
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="keywordtype">void</span> RabinFunction::DEREncode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;bt)<span class="keyword"> const</span>
<a name="l00022"></a>00022 <span class="keyword"></span>{
<a name="l00023"></a>00023         <a class="code" href="class_d_e_r_sequence_encoder.html" title="DER Sequence Encoder.">DERSequenceEncoder</a> seq(bt);
<a name="l00024"></a>00024         m_n.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00025"></a>00025         m_r.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00026"></a>00026         m_s.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00027"></a>00027         seq.MessageEnd();
<a name="l00028"></a>00028 }
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> RabinFunction::ApplyFunction(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;in)<span class="keyword"> const</span>
<a name="l00031"></a>00031 <span class="keyword"></span>{
<a name="l00032"></a>00032         DoQuickSanityCheck();
<a name="l00033"></a>00033 
<a name="l00034"></a>00034         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> out = in.Squared()%m_n;
<a name="l00035"></a>00035         <span class="keywordflow">if</span> (in.IsOdd())
<a name="l00036"></a>00036                 out = out*m_r%m_n;
<a name="l00037"></a>00037         <span class="keywordflow">if</span> (Jacobi(in, m_n)==-1)
<a name="l00038"></a>00038                 out = out*m_s%m_n;
<a name="l00039"></a>00039         <span class="keywordflow">return</span> out;
<a name="l00040"></a>00040 }
<a name="l00041"></a>00041 
<a name="l00042"></a><a class="code" href="class_rabin_function.html#a0134de415d790de6cb65d5b9940f36e5">00042</a> <span class="keywordtype">bool</span> <a class="code" href="class_rabin_function.html#a0134de415d790de6cb65d5b9940f36e5" title="check this object for errors">RabinFunction::Validate</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level)<span class="keyword"> const</span>
<a name="l00043"></a>00043 <span class="keyword"></span>{
<a name="l00044"></a>00044         <span class="keywordtype">bool</span> pass = <span class="keyword">true</span>;
<a name="l00045"></a>00045         pass = pass &amp;&amp; m_n &gt; <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>() &amp;&amp; m_n%4 == 1;
<a name="l00046"></a>00046         pass = pass &amp;&amp; m_r &gt; <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>() &amp;&amp; m_r &lt; m_n;
<a name="l00047"></a>00047         pass = pass &amp;&amp; m_s &gt; <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>() &amp;&amp; m_s &lt; m_n;
<a name="l00048"></a>00048         <span class="keywordflow">if</span> (level &gt;= 1)
<a name="l00049"></a>00049                 pass = pass &amp;&amp; Jacobi(m_r, m_n) == -1 &amp;&amp; Jacobi(m_s, m_n) == -1;
<a name="l00050"></a>00050         <span class="keywordflow">return</span> pass;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="class_rabin_function.html#acce821b84d2ba2aa7a63984146a95dcb">00053</a> <span class="keywordtype">bool</span> <a class="code" href="class_rabin_function.html#acce821b84d2ba2aa7a63984146a95dcb" title="to be implemented by derived classes, users should use one of the above functions...">RabinFunction::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>
<a name="l00054"></a>00054 <span class="keyword"></span>{
<a name="l00055"></a>00055         <span class="keywordflow">return</span> GetValueHelper(<span class="keyword">this</span>, name, valueType, pValue).Assignable()
<a name="l00056"></a>00056                 CRYPTOPP_GET_FUNCTION_ENTRY(Modulus)
<a name="l00057"></a>00057                 CRYPTOPP_GET_FUNCTION_ENTRY(QuadraticResidueModPrime1)
<a name="l00058"></a>00058                 CRYPTOPP_GET_FUNCTION_ENTRY(QuadraticResidueModPrime2)
<a name="l00059"></a>00059                 ;
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 
<a name="l00062"></a><a class="code" href="class_rabin_function.html#ae585a0d58b1b95579459c2b42eea980c">00062</a> <span class="keywordtype">void</span> <a class="code" href="class_rabin_function.html#ae585a0d58b1b95579459c2b42eea980c" title="assign values from source to this object">RabinFunction::AssignFrom</a>(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &amp;source)
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064         AssignFromHelper(<span class="keyword">this</span>, source)
<a name="l00065"></a>00065                 CRYPTOPP_SET_FUNCTION_ENTRY(Modulus)
<a name="l00066"></a>00066                 CRYPTOPP_SET_FUNCTION_ENTRY(QuadraticResidueModPrime1)
<a name="l00067"></a>00067                 CRYPTOPP_SET_FUNCTION_ENTRY(QuadraticResidueModPrime2)
<a name="l00068"></a>00068                 ;
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00071"></a>00071 <span class="comment">// *****************************************************************************</span>
<a name="l00072"></a>00072 <span class="comment">// private key operations:</span>
<a name="l00073"></a>00073 
<a name="l00074"></a>00074 <span class="comment">// generate a random private key</span>
<a name="l00075"></a><a class="code" href="class_invertible_rabin_function.html#a571737380b956b4add10c855484af670">00075</a> <span class="keywordtype">void</span> <a class="code" href="class_invertible_rabin_function.html#a571737380b956b4add10c855484af670">InvertibleRabinFunction::GenerateRandom</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &amp;alg)
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077         <span class="keywordtype">int</span> modulusSize = 2048;
<a name="l00078"></a>00078         alg.<a class="code" href="class_name_value_pairs.html#a39b6daefcabcdd07f5ae482a075e1728" title="get a named value with type int">GetIntValue</a>(<span class="stringliteral">&quot;ModulusSize&quot;</span>, modulusSize) || alg.<a class="code" href="class_name_value_pairs.html#a39b6daefcabcdd07f5ae482a075e1728" title="get a named value with type int">GetIntValue</a>(<span class="stringliteral">&quot;KeySize&quot;</span>, modulusSize);
<a name="l00079"></a>00079 
<a name="l00080"></a>00080         <span class="keywordflow">if</span> (modulusSize &lt; 16)
<a name="l00081"></a>00081                 <span class="keywordflow">throw</span> <a class="code" href="class_invalid_argument.html" title="exception thrown when an invalid argument is detected">InvalidArgument</a>(<span class="stringliteral">&quot;InvertibleRabinFunction: specified modulus size is too small&quot;</span>);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083         <span class="comment">// VC70 workaround: putting these after primeParam causes overlapped stack allocation</span>
<a name="l00084"></a>00084         <span class="keywordtype">bool</span> rFound=<span class="keyword">false</span>, sFound=<span class="keyword">false</span>;
<a name="l00085"></a>00085         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> t=2;
<a name="l00086"></a>00086 
<a name="l00087"></a>00087         <a class="code" href="class_algorithm_parameters.html">AlgorithmParameters</a> primeParam = MakeParametersForTwoPrimesOfEqualSize(modulusSize)
<a name="l00088"></a>00088                 (<span class="stringliteral">&quot;EquivalentTo&quot;</span>, 3)(<span class="stringliteral">&quot;Mod&quot;</span>, 4);
<a name="l00089"></a>00089         m_p.GenerateRandom(rng, primeParam);
<a name="l00090"></a>00090         m_q.GenerateRandom(rng, primeParam);
<a name="l00091"></a>00091 
<a name="l00092"></a>00092         <span class="keywordflow">while</span> (!(rFound &amp;&amp; sFound))
<a name="l00093"></a>00093         {
<a name="l00094"></a>00094                 <span class="keywordtype">int</span> jp = Jacobi(t, m_p);
<a name="l00095"></a>00095                 <span class="keywordtype">int</span> jq = Jacobi(t, m_q);
<a name="l00096"></a>00096 
<a name="l00097"></a>00097                 <span class="keywordflow">if</span> (!rFound &amp;&amp; jp==1 &amp;&amp; jq==-1)
<a name="l00098"></a>00098                 {
<a name="l00099"></a>00099                         m_r = t;
<a name="l00100"></a>00100                         rFound = <span class="keyword">true</span>;
<a name="l00101"></a>00101                 }
<a name="l00102"></a>00102 
<a name="l00103"></a>00103                 <span class="keywordflow">if</span> (!sFound &amp;&amp; jp==-1 &amp;&amp; jq==1)
<a name="l00104"></a>00104                 {
<a name="l00105"></a>00105                         m_s = t;
<a name="l00106"></a>00106                         sFound = <span class="keyword">true</span>;
<a name="l00107"></a>00107                 }
<a name="l00108"></a>00108 
<a name="l00109"></a>00109                 ++t;
<a name="l00110"></a>00110         }
<a name="l00111"></a>00111 
<a name="l00112"></a>00112         m_n = m_p * m_q;
<a name="l00113"></a>00113         m_u = m_q.<a class="code" href="class_integer.html#a881f9c714ee42f35718725a43d4d7db3" title="calculate multiplicative inverse of *this mod n">InverseMod</a>(m_p);
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 
<a name="l00116"></a>00116 <span class="keywordtype">void</span> InvertibleRabinFunction::BERDecode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;bt)
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118         <a class="code" href="class_b_e_r_sequence_decoder.html" title="BER Sequence Decoder.">BERSequenceDecoder</a> seq(bt);
<a name="l00119"></a>00119         m_n.BERDecode(seq);
<a name="l00120"></a>00120         m_r.BERDecode(seq);
<a name="l00121"></a>00121         m_s.BERDecode(seq);
<a name="l00122"></a>00122         m_p.BERDecode(seq);
<a name="l00123"></a>00123         m_q.BERDecode(seq);
<a name="l00124"></a>00124         m_u.BERDecode(seq);
<a name="l00125"></a>00125         seq.MessageEnd();
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 <span class="keywordtype">void</span> InvertibleRabinFunction::DEREncode(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;bt)<span class="keyword"> const</span>
<a name="l00129"></a>00129 <span class="keyword"></span>{
<a name="l00130"></a>00130         <a class="code" href="class_d_e_r_sequence_encoder.html" title="DER Sequence Encoder.">DERSequenceEncoder</a> seq(bt);
<a name="l00131"></a>00131         m_n.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00132"></a>00132         m_r.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00133"></a>00133         m_s.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00134"></a>00134         m_p.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00135"></a>00135         m_q.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00136"></a>00136         m_u.<a class="code" href="class_integer.html#a6ab51a05bee88cfa690179611e8a084e" title="encode using Distinguished Encoding Rules, put result into a BufferedTransformation...">DEREncode</a>(seq);
<a name="l00137"></a>00137         seq.MessageEnd();
<a name="l00138"></a>00138 }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> InvertibleRabinFunction::CalculateInverse(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &amp;in)<span class="keyword"> const</span>
<a name="l00141"></a>00141 <span class="keyword"></span>{
<a name="l00142"></a>00142         DoQuickSanityCheck();
<a name="l00143"></a>00143 
<a name="l00144"></a>00144         <a class="code" href="class_modular_arithmetic.html" title="ring of congruence classes modulo n">ModularArithmetic</a> modn(m_n);
<a name="l00145"></a>00145         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> r(rng, <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>(), m_n - <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>());
<a name="l00146"></a>00146         r = modn.Square(r);
<a name="l00147"></a>00147         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> r2 = modn.Square(r);
<a name="l00148"></a>00148         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> c = modn.Multiply(in, r2);              <span class="comment">// blind</span>
<a name="l00149"></a>00149 
<a name="l00150"></a>00150         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> cp=c%m_p, cq=c%m_q;
<a name="l00151"></a>00151 
<a name="l00152"></a>00152         <span class="keywordtype">int</span> jp = Jacobi(cp, m_p);
<a name="l00153"></a>00153         <span class="keywordtype">int</span> jq = Jacobi(cq, m_q);
<a name="l00154"></a>00154 
<a name="l00155"></a>00155         <span class="keywordflow">if</span> (jq==-1)
<a name="l00156"></a>00156         {
<a name="l00157"></a>00157                 cp = cp*EuclideanMultiplicativeInverse(m_r, m_p)%m_p;
<a name="l00158"></a>00158                 cq = cq*EuclideanMultiplicativeInverse(m_r, m_q)%m_q;
<a name="l00159"></a>00159         }
<a name="l00160"></a>00160 
<a name="l00161"></a>00161         <span class="keywordflow">if</span> (jp==-1)
<a name="l00162"></a>00162         {
<a name="l00163"></a>00163                 cp = cp*EuclideanMultiplicativeInverse(m_s, m_p)%m_p;
<a name="l00164"></a>00164                 cq = cq*EuclideanMultiplicativeInverse(m_s, m_q)%m_q;
<a name="l00165"></a>00165         }
<a name="l00166"></a>00166 
<a name="l00167"></a>00167         cp = ModularSquareRoot(cp, m_p);
<a name="l00168"></a>00168         cq = ModularSquareRoot(cq, m_q);
<a name="l00169"></a>00169 
<a name="l00170"></a>00170         <span class="keywordflow">if</span> (jp==-1)
<a name="l00171"></a>00171                 cp = m_p-cp;
<a name="l00172"></a>00172 
<a name="l00173"></a>00173         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> out = CRT(cq, m_q, cp, m_p, m_u);
<a name="l00174"></a>00174 
<a name="l00175"></a>00175         out = modn.<a class="code" href="class_integer.html#a567c89aa176b354143c99d558d05a5fb" title="calculate r and q such that (a == d*q + r) &amp;amp;&amp;amp; (0 &amp;lt;= r &amp;lt; abs(d))">Divide</a>(out, r);      <span class="comment">// unblind</span>
<a name="l00176"></a>00176 
<a name="l00177"></a>00177         <span class="keywordflow">if</span> ((jq==-1 &amp;&amp; out.IsEven()) || (jq==1 &amp;&amp; out.IsOdd()))
<a name="l00178"></a>00178                 out = m_n-out;
<a name="l00179"></a>00179 
<a name="l00180"></a>00180         <span class="keywordflow">return</span> out;
<a name="l00181"></a>00181 }
<a name="l00182"></a>00182 
<a name="l00183"></a><a class="code" href="class_invertible_rabin_function.html#ab943e623f7f1ffb3d890c1ab9e4e3474">00183</a> <span class="keywordtype">bool</span> <a class="code" href="class_invertible_rabin_function.html#ab943e623f7f1ffb3d890c1ab9e4e3474" title="check this object for errors">InvertibleRabinFunction::Validate</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level)<span class="keyword"> const</span>
<a name="l00184"></a>00184 <span class="keyword"></span>{
<a name="l00185"></a>00185         <span class="keywordtype">bool</span> pass = <a class="code" href="class_invertible_rabin_function.html#ab943e623f7f1ffb3d890c1ab9e4e3474" title="check this object for errors">RabinFunction::Validate</a>(rng, level);
<a name="l00186"></a>00186         pass = pass &amp;&amp; m_p &gt; <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>() &amp;&amp; m_p%4 == 3 &amp;&amp; m_p &lt; m_n;
<a name="l00187"></a>00187         pass = pass &amp;&amp; m_q &gt; <a class="code" href="class_integer.html#a8c070592581bf6c2f928c72bfa1c1638" title="avoid calling constructors for these frequently used integers">Integer::One</a>() &amp;&amp; m_q%4 == 3 &amp;&amp; m_q &lt; m_n;
<a name="l00188"></a>00188         pass = pass &amp;&amp; m_u.IsPositive() &amp;&amp; m_u &lt; m_p;
<a name="l00189"></a>00189         <span class="keywordflow">if</span> (level &gt;= 1)
<a name="l00190"></a>00190         {
<a name="l00191"></a>00191                 pass = pass &amp;&amp; m_p * m_q == m_n;
<a name="l00192"></a>00192                 pass = pass &amp;&amp; m_u * m_q % m_p == 1;
<a name="l00193"></a>00193                 pass = pass &amp;&amp; Jacobi(m_r, m_p) == 1;
<a name="l00194"></a>00194                 pass = pass &amp;&amp; Jacobi(m_r, m_q) == -1;
<a name="l00195"></a>00195                 pass = pass &amp;&amp; Jacobi(m_s, m_p) == -1;
<a name="l00196"></a>00196                 pass = pass &amp;&amp; Jacobi(m_s, m_q) == 1;
<a name="l00197"></a>00197         }
<a name="l00198"></a>00198         <span class="keywordflow">if</span> (level &gt;= 2)
<a name="l00199"></a>00199                 pass = pass &amp;&amp; VerifyPrime(rng, m_p, level-2) &amp;&amp; VerifyPrime(rng, m_q, level-2);
<a name="l00200"></a>00200         <span class="keywordflow">return</span> pass;
<a name="l00201"></a>00201 }
<a name="l00202"></a>00202 
<a name="l00203"></a><a class="code" href="class_invertible_rabin_function.html#a52931eba7e69b47a1b9307dc92721e0f">00203</a> <span class="keywordtype">bool</span> <a class="code" href="class_invertible_rabin_function.html#a52931eba7e69b47a1b9307dc92721e0f" title="to be implemented by derived classes, users should use one of the above functions...">InvertibleRabinFunction::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>
<a name="l00204"></a>00204 <span class="keyword"></span>{
<a name="l00205"></a>00205         <span class="keywordflow">return</span> GetValueHelper&lt;RabinFunction&gt;(<span class="keyword">this</span>, name, valueType, pValue).Assignable()
<a name="l00206"></a>00206                 CRYPTOPP_GET_FUNCTION_ENTRY(Prime1)
<a name="l00207"></a>00207                 CRYPTOPP_GET_FUNCTION_ENTRY(Prime2)
<a name="l00208"></a>00208                 CRYPTOPP_GET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
<a name="l00209"></a>00209                 ;
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 
<a name="l00212"></a><a class="code" href="class_invertible_rabin_function.html#a66594bb7f369e4ecc30bbe6ae62527ea">00212</a> <span class="keywordtype">void</span> <a class="code" href="class_invertible_rabin_function.html#a66594bb7f369e4ecc30bbe6ae62527ea" title="assign values from source to this object">InvertibleRabinFunction::AssignFrom</a>(<span class="keyword">const</span> <a class="code" href="class_name_value_pairs.html" title="interface for retrieving values given their names">NameValuePairs</a> &amp;source)
<a name="l00213"></a>00213 {
<a name="l00214"></a>00214         AssignFromHelper&lt;RabinFunction&gt;(<span class="keyword">this</span>, source)
<a name="l00215"></a>00215                 CRYPTOPP_SET_FUNCTION_ENTRY(Prime1)
<a name="l00216"></a>00216                 CRYPTOPP_SET_FUNCTION_ENTRY(Prime2)
<a name="l00217"></a>00217                 CRYPTOPP_SET_FUNCTION_ENTRY(MultiplicativeInverseOfPrime2ModPrime1)
<a name="l00218"></a>00218                 ;
<a name="l00219"></a>00219 }
<a name="l00220"></a>00220 
<a name="l00221"></a>00221 NAMESPACE_END
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>