📄 rsa_8h-source.html
字号:
<a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="keyword">protected</span>:<a name="l00049"></a><a class="code" href="class_r_s_a_function.html#b2e89822414861cb312d52d8c7ac3017">00049</a> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> m_n, m_e;<a name="l00050"></a>00050 };<a name="l00051"></a>00051 <span class="comment"></span><a name="l00052"></a>00052 <span class="comment">//! _</span><a name="l00053"></a><a class="code" href="class_invertible_r_s_a_function.html">00053</a> <span class="comment"></span><span class="keyword">class </span>CRYPTOPP_DLL <a class="code" href="class_invertible_r_s_a_function.html" title="_">InvertibleRSAFunction</a> : <span class="keyword">public</span> <a class="code" href="class_r_s_a_function.html" title="_">RSAFunction</a>, <span class="keyword">public</span> <a class="code" href="class_trapdoor_function_inverse.html" title="_">TrapdoorFunctionInverse</a>, <span class="keyword">public</span> <a class="code" href="class_p_k_c_s8_private_key.html" title="encodes/decodes privateKeyInfo">PKCS8PrivateKey</a><a name="l00054"></a>00054 {<a name="l00055"></a>00055 <span class="keyword">typedef</span> <a class="code" href="class_invertible_r_s_a_function.html" title="_">InvertibleRSAFunction</a> <a class="code" href="class_r_s_a_function.html" title="_">ThisClass</a>;<a name="l00056"></a>00056 <a name="l00057"></a>00057 <span class="keyword">public</span>:<a name="l00058"></a>00058 <span class="keywordtype">void</span> <a class="code" href="class_r_s_a_function.html#8f1a1bd46126545fe9e43cd1e259cba2">Initialize</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> modulusBits, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &e = 17);<a name="l00059"></a><a class="code" href="class_invertible_r_s_a_function.html#6ff0e6c1bb44bff9fd7d3745b9f8de92">00059</a> <span class="keywordtype">void</span> <a class="code" href="class_r_s_a_function.html#8f1a1bd46126545fe9e43cd1e259cba2">Initialize</a>(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &e, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &d, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &p, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &q, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &dp, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &dq, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &u)<a name="l00060"></a>00060 {m_n = n; m_e = e; m_d = d; m_p = p; m_q = q; m_dp = dp; m_dq = dq; m_u = u;}<span class="comment"></span><a name="l00061"></a>00061 <span class="comment"> //! factor n given private exponent</span><a name="l00062"></a>00062 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="class_r_s_a_function.html#8f1a1bd46126545fe9e43cd1e259cba2">Initialize</a>(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &e, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &d);<a name="l00063"></a>00063 <a name="l00064"></a>00064 <span class="comment">// PKCS8PrivateKey</span><a name="l00065"></a><a class="code" href="class_invertible_r_s_a_function.html#315fea96cb04dc41150d92cf5d1ce3e0">00065</a> <span class="keywordtype">void</span> <a class="code" href="class_p_k_c_s8_private_key.html#9ffab1c1391e4faf356668d8e2cd7d32" title="decode this object from a BufferedTransformation, using BER (Basic Encoding Rules)...">BERDecode</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt)<a name="l00066"></a>00066 {<a class="code" href="class_p_k_c_s8_private_key.html#9ffab1c1391e4faf356668d8e2cd7d32" title="decode this object from a BufferedTransformation, using BER (Basic Encoding Rules)...">PKCS8PrivateKey::BERDecode</a>(bt);}<a name="l00067"></a><a class="code" href="class_invertible_r_s_a_function.html#f8c59c737c96b4809734971d0703707d">00067</a> <span class="keywordtype">void</span> <a class="code" href="class_p_k_c_s8_private_key.html#83e4531f1f514441107a1f35274589b8" title="encode this object into a BufferedTransformation, using DER (Distinguished Encoding...">DEREncode</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt)<span class="keyword"> const</span><a name="l00068"></a>00068 <span class="keyword"> </span>{<a class="code" href="class_p_k_c_s8_private_key.html#83e4531f1f514441107a1f35274589b8" title="encode this object into a BufferedTransformation, using DER (Distinguished Encoding...">PKCS8PrivateKey::DEREncode</a>(bt);}<a name="l00069"></a><a class="code" href="class_invertible_r_s_a_function.html#d8a540a6369b9043d082b0dc38b99d4b">00069</a> <span class="keywordtype">void</span> <a class="code" href="class_a_s_n1_crypto_material.html#23d34a094f5765a1cf51f22ae1233f66" title="load key from a BufferedTransformation">Load</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt)<a name="l00070"></a>00070 {<a class="code" href="class_p_k_c_s8_private_key.html#9ffab1c1391e4faf356668d8e2cd7d32" title="decode this object from a BufferedTransformation, using BER (Basic Encoding Rules)...">PKCS8PrivateKey::BERDecode</a>(bt);}<a name="l00071"></a><a class="code" href="class_invertible_r_s_a_function.html#09ea42eb393e6145171124ccdbc8883f">00071</a> <span class="keywordtype">void</span> <a class="code" href="class_a_s_n1_crypto_material.html#8092ce7a774430f54c70632812ce3399" title="save key into a BufferedTransformation">Save</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt)<span class="keyword"> const</span><a name="l00072"></a>00072 <span class="keyword"> </span>{<a class="code" href="class_p_k_c_s8_private_key.html#83e4531f1f514441107a1f35274589b8" title="encode this object into a BufferedTransformation, using DER (Distinguished Encoding...">PKCS8PrivateKey::DEREncode</a>(bt);}<a name="l00073"></a><a class="code" href="class_invertible_r_s_a_function.html#d268008c11f68dca31b5e0aee713f7f7">00073</a> <a class="code" href="class_o_i_d.html" title="Object Identifier.">OID</a> <a class="code" href="class_r_s_a_function.html#525ac5bbc49c2e19fe359e69470eb304">GetAlgorithmID</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_r_s_a_function.html#525ac5bbc49c2e19fe359e69470eb304">RSAFunction::GetAlgorithmID</a>();}<a name="l00074"></a>00074 <span class="keywordtype">void</span> <a class="code" href="class_p_k_c_s8_private_key.html#b759ba85c01e99203f08da6084d61318" title="decode privateKey part of privateKeyInfo, without the OCTET STRING header">BERDecodePrivateKey</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt, <span class="keywordtype">bool</span> parametersPresent, <span class="keywordtype">size_t</span> size);<a name="l00075"></a>00075 <span class="keywordtype">void</span> <a class="code" href="class_p_k_c_s8_private_key.html#4effc9a887bb955bca2ad6199b2abf89" title="encode privateKey part of privateKeyInfo, without the OCTET STRING header">DEREncodePrivateKey</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &bt) <span class="keyword">const</span>;<a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="comment">// TrapdoorFunctionInverse</span><a name="l00078"></a>00078 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> CalculateInverse(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &x) <span class="keyword">const</span>;<a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="comment">// GeneratableCryptoMaterial</span><a name="l00081"></a>00081 <span class="keywordtype">bool</span> <a class="code" href="class_crypto_material.html#439743c6b4e89ca8228a12fa1ea43ab1" title="check this object for errors">Validate</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &rng, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> level) <span class="keyword">const</span>;<span class="comment"></span><a name="l00082"></a>00082 <span class="comment"> /*! parameters: (ModulusSize, PublicExponent (default 17)) */</span><a name="l00083"></a>00083 <span class="keywordtype">void</span> <a class="code" href="class_generatable_crypto_material.html#be368b52db1ca7079b690f2d6e605f7a" title="generate a random key or crypto parameters">GenerateRandom</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &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> &alg);<a name="l00084"></a>00084 <span class="keywordtype">bool</span> <a class="code" href="class_name_value_pairs.html#9fc3f5c4480d53b8104c67ca7958e332" title="to be implemented by derived classes, users should use one of the above functions...">GetVoidValue</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name, <span class="keyword">const</span> std::type_info &valueType, <span class="keywordtype">void</span> *pValue) <span class="keyword">const</span>;<a name="l00085"></a>00085 <span class="keywordtype">void</span> <a class="code" href="class_crypto_material.html#20181c1b39a74a9fe91385b025b773c6" title="assign values from source to this object">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> &source);<a name="l00086"></a>00086 <a name="l00087"></a>00087 <span class="comment">// non-derived interface</span><a name="l00088"></a><a class="code" href="class_invertible_r_s_a_function.html#006237f2106e46520b493bbd40e29d89">00088</a> <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetPrime1()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_p;}<a name="l00089"></a><a class="code" href="class_invertible_r_s_a_function.html#440388b7d271d28e6302d5f8a37fda02">00089</a> <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetPrime2()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_q;}<a name="l00090"></a><a class="code" href="class_invertible_r_s_a_function.html#93c1fcc51224f38db69ca437dad3d9bc">00090</a> <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetPrivateExponent()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_d;}<a name="l00091"></a><a class="code" href="class_invertible_r_s_a_function.html#d9b6e2499e7397d153a8af5041159568">00091</a> <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetModPrime1PrivateExponent()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_dp;}<a name="l00092"></a><a class="code" href="class_invertible_r_s_a_function.html#537246a35eb0d5422cf949f43c6b00fd">00092</a> <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetModPrime2PrivateExponent()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_dq;}<a name="l00093"></a><a class="code" href="class_invertible_r_s_a_function.html#b50b9c3d14efcf1e5fa7b87b0c1b8dcd">00093</a> <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& GetMultiplicativeInverseOfPrime2ModPrime1()<span class="keyword"> const </span>{<span class="keywordflow">return</span> m_u;}<a name="l00094"></a>00094 <a name="l00095"></a><a class="code" href="class_invertible_r_s_a_function.html#bbaf0796c65e9a7ef02669faff4d600f">00095</a> <span class="keywordtype">void</span> SetPrime1(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &p) {m_p = p;}<a name="l00096"></a><a class="code" href="class_invertible_r_s_a_function.html#c5f75f19eb718a44d09066cc860f2e43">00096</a> <span class="keywordtype">void</span> SetPrime2(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &q) {m_q = q;}<a name="l00097"></a><a class="code" href="class_invertible_r_s_a_function.html#13956f432d0d2c47960da979cba18198">00097</a> <span class="keywordtype">void</span> SetPrivateExponent(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &d) {m_d = d;}<a name="l00098"></a><a class="code" href="class_invertible_r_s_a_function.html#5b01ca0407225d56dd1f06634d56e405">00098</a> <span class="keywordtype">void</span> SetModPrime1PrivateExponent(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &dp) {m_dp = dp;}<a name="l00099"></a><a class="code" href="class_invertible_r_s_a_function.html#8c005d9809d47a63b1c2bb9d5ad5b88e">00099</a> <span class="keywordtype">void</span> SetModPrime2PrivateExponent(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &dq) {m_dq = dq;}<a name="l00100"></a><a class="code" href="class_invertible_r_s_a_function.html#6a4bd221c844168cecf50ef04cada713">00100</a> <span class="keywordtype">void</span> SetMultiplicativeInverseOfPrime2ModPrime1(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &u) {m_u = u;}<a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="keyword">protected</span>:<a name="l00103"></a><a class="code" href="class_invertible_r_s_a_function.html#6b7b378c8be194a47faf824844ed6c7b">00103</a> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> m_d, m_p, m_q, m_dp, m_dq, m_u;<a name="l00104"></a>00104 };<a name="l00105"></a>00105 <a name="l00106"></a><a class="code" href="class_r_s_a_function___i_s_o.html">00106</a> <span class="keyword">class </span>CRYPTOPP_DLL RSAFunction_ISO : <span class="keyword">public</span> <a class="code" href="class_r_s_a_function.html" title="_">RSAFunction</a><a name="l00107"></a>00107 {<a name="l00108"></a>00108 <span class="keyword">public</span>:<a name="l00109"></a>00109 <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> <a class="code" href="class_r_s_a_function.html#8ff27b06cc624d5c41a1314b189cfab7">ApplyFunction</a>(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &x) <span class="keyword">const</span>;<a name="l00110"></a><a class="code" href="class_r_s_a_function___i_s_o.html#0573fcd6596f6d1d9e2b5dc8d7fd3453">00110</a> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> <a class="code" href="class_r_s_a_function.html#5eb6f0be67906fe2659e7d62fe54b317">PreimageBound</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> ++(m_n>>1);}<a name="l00111"></a>00111 };<a name="l00112"></a>00112 <a name="l00113"></a><a class="code" href="class_invertible_r_s_a_function___i_s_o.html">00113</a> <span class="keyword">class </span>CRYPTOPP_DLL InvertibleRSAFunction_ISO : <span class="keyword">public</span> <a class="code" href="class_invertible_r_s_a_function.html" title="_">InvertibleRSAFunction</a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -