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

📄 pubkey_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<a name="l00104"></a>00104 <a name="l00105"></a><a class="code" href="class_t_f___verifier_base.html#de187ebe9057cd724638d0d4ee45fae2">00105</a> <span class="keywordtype">bool</span> <a class="code" href="class_t_f___verifier_base.html#de187ebe9057cd724638d0d4ee45fae2" title="check whether messageAccumulator contains a valid signature and message, and restart...">TF_VerifierBase::VerifyAndRestart</a>(<a class="code" href="class_p_k___message_accumulator.html" title="interface for accumulating messages to be signed or verified">PK_MessageAccumulator</a> &amp;messageAccumulator)<span class="keyword"> const</span><a name="l00106"></a>00106 <span class="keyword"></span>{<a name="l00107"></a>00107         <a class="code" href="class_p_k___message_accumulator_base.html">PK_MessageAccumulatorBase</a> &amp;ma = <span class="keyword">static_cast&lt;</span><a class="code" href="class_p_k___message_accumulator_base.html">PK_MessageAccumulatorBase</a> &amp;<span class="keyword">&gt;</span>(messageAccumulator);<a name="l00108"></a>00108         <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> <span class="keywordtype">id</span> = GetHashIdentifier();<a name="l00109"></a>00109         <span class="keyword">const</span> <a class="code" href="class_p_k___signature_message_encoding_method.html" title="interface for message encoding method for public key signature schemes">MessageEncodingInterface</a> &amp;encoding = GetMessageEncodingInterface();<a name="l00110"></a>00110 <a name="l00111"></a>00111         <span class="keywordflow">if</span> (<a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>() &lt; encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#0fa26f3c87be18c7be3d851537c276d6">MinRepresentativeBitLength</a>(<span class="keywordtype">id</span>.second, ma.<a class="code" href="class_p_k___message_accumulator_base.html#2b50619968b03f69ba3ad7ba21e780bf">AccessHash</a>().<a class="code" href="class_hash_transformation.html#41faf8b1293a6c72390cb0c8bd668097" title="size of the hash returned by Final()">DigestSize</a>()))<a name="l00112"></a>00112                 <span class="keywordflow">throw</span> <a class="code" href="class_p_k___signature_scheme_1_1_key_too_short.html" title="key too short exception, may be thrown by any function in this class if the private...">PK_SignatureScheme::KeyTooShort</a>();<a name="l00113"></a>00113 <a name="l00114"></a>00114         <span class="keywordtype">bool</span> result = encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#797280b3d1114036389b03c36aa77456">VerifyMessageRepresentative</a>(<a name="l00115"></a>00115                 ma.<a class="code" href="class_p_k___message_accumulator_base.html#2b50619968b03f69ba3ad7ba21e780bf">AccessHash</a>(), id, ma.<a class="code" href="class_p_k___message_accumulator_base.html#6d0a3ce0258e928c8fb146989a6a7884">m_empty</a>, ma.<a class="code" href="class_p_k___message_accumulator_base.html#bbef3e3ccb561a43b3ee7446c838a0da">m_representative</a>, <a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>());<a name="l00116"></a>00116         ma.<a class="code" href="class_p_k___message_accumulator_base.html#6d0a3ce0258e928c8fb146989a6a7884">m_empty</a> = <span class="keyword">true</span>;<a name="l00117"></a>00117         <span class="keywordflow">return</span> result;<a name="l00118"></a>00118 }<a name="l00119"></a>00119 <a name="l00120"></a><a class="code" href="class_t_f___verifier_base.html#fff8535e4229e7e27e0824ce68e7e723">00120</a> <a class="code" href="struct_decoding_result.html" title="used to return decoding results">DecodingResult</a> <a class="code" href="class_t_f___verifier_base.html#fff8535e4229e7e27e0824ce68e7e723" title="recover a message from its signature">TF_VerifierBase::RecoverAndRestart</a>(byte *recoveredMessage, <a class="code" href="class_p_k___message_accumulator.html" title="interface for accumulating messages to be signed or verified">PK_MessageAccumulator</a> &amp;messageAccumulator)<span class="keyword"> const</span><a name="l00121"></a>00121 <span class="keyword"></span>{<a name="l00122"></a>00122         <a class="code" href="class_p_k___message_accumulator_base.html">PK_MessageAccumulatorBase</a> &amp;ma = <span class="keyword">static_cast&lt;</span><a class="code" href="class_p_k___message_accumulator_base.html">PK_MessageAccumulatorBase</a> &amp;<span class="keyword">&gt;</span>(messageAccumulator);<a name="l00123"></a>00123         <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> <span class="keywordtype">id</span> = GetHashIdentifier();<a name="l00124"></a>00124         <span class="keyword">const</span> <a class="code" href="class_p_k___signature_message_encoding_method.html" title="interface for message encoding method for public key signature schemes">MessageEncodingInterface</a> &amp;encoding = GetMessageEncodingInterface();<a name="l00125"></a>00125 <a name="l00126"></a>00126         <span class="keywordflow">if</span> (<a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>() &lt; encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#0fa26f3c87be18c7be3d851537c276d6">MinRepresentativeBitLength</a>(<span class="keywordtype">id</span>.second, ma.<a class="code" href="class_p_k___message_accumulator_base.html#2b50619968b03f69ba3ad7ba21e780bf">AccessHash</a>().<a class="code" href="class_hash_transformation.html#41faf8b1293a6c72390cb0c8bd668097" title="size of the hash returned by Final()">DigestSize</a>()))<a name="l00127"></a>00127                 <span class="keywordflow">throw</span> <a class="code" href="class_p_k___signature_scheme_1_1_key_too_short.html" title="key too short exception, may be thrown by any function in this class if the private...">PK_SignatureScheme::KeyTooShort</a>();<a name="l00128"></a>00128 <a name="l00129"></a>00129         <a class="code" href="struct_decoding_result.html" title="used to return decoding results">DecodingResult</a> result = encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#4debaa9f683a82bb11fbeb668bacbd04">RecoverMessageFromRepresentative</a>(<a name="l00130"></a>00130                 ma.<a class="code" href="class_p_k___message_accumulator_base.html#2b50619968b03f69ba3ad7ba21e780bf">AccessHash</a>(), id, ma.<a class="code" href="class_p_k___message_accumulator_base.html#6d0a3ce0258e928c8fb146989a6a7884">m_empty</a>, ma.<a class="code" href="class_p_k___message_accumulator_base.html#bbef3e3ccb561a43b3ee7446c838a0da">m_representative</a>, <a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>(), recoveredMessage);<a name="l00131"></a>00131         ma.<a class="code" href="class_p_k___message_accumulator_base.html#6d0a3ce0258e928c8fb146989a6a7884">m_empty</a> = <span class="keyword">true</span>;<a name="l00132"></a>00132         <span class="keywordflow">return</span> result;<a name="l00133"></a>00133 }<a name="l00134"></a>00134 <a name="l00135"></a><a class="code" href="class_t_f___decryptor_base.html#f46c7592f103bcb827445e5cbce8b7f9">00135</a> <a class="code" href="struct_decoding_result.html" title="used to return decoding results">DecodingResult</a> <a class="code" href="class_t_f___decryptor_base.html#f46c7592f103bcb827445e5cbce8b7f9" title="decrypt a byte string, and return the length of plaintext">TF_DecryptorBase::Decrypt</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> byte *ciphertext, <span class="keywordtype">size_t</span> ciphertextLength, byte *plaintext, <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;parameters)<span class="keyword"> const</span><a name="l00136"></a>00136 <span class="keyword"></span>{<a name="l00137"></a>00137         <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> paddedBlock(<a class="code" href="class_t_f___crypto_system_base.html#5ad757b5d844b247b0f40969ab5d5957">PaddedBlockByteLength</a>());<a name="l00138"></a>00138         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> x = GetTrapdoorFunctionInterface().<a class="code" href="class_trapdoor_function_inverse.html#cd12caa3b27c018a85967ae7664cc920">CalculateInverse</a>(rng, <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>(ciphertext, <a class="code" href="class_t_f___crypto_system_base.html#91638e029e369d985f7858ad7daf2019" title="return fixed ciphertext length, if one exists, otherwise return 0">FixedCiphertextLength</a>()));<a name="l00139"></a>00139         <span class="keywordflow">if</span> (x.<a class="code" href="class_integer.html#e7ee3f1bbea2b3138c6d8f1ce1aa2bf9" title="number of significant bytes = ceiling(BitCount()/8)">ByteCount</a>() &gt; paddedBlock.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>())<a name="l00140"></a>00140                 x = <a class="code" href="class_integer.html#19b7e6d48b1b57bd4846160ea2928175" title="avoid calling constructors for these frequently used integers">Integer::Zero</a>();    <span class="comment">// don't return false here to prevent timing attack</span><a name="l00141"></a>00141         x.<a class="code" href="class_integer.html#c12ea467de9a609b86ec03d8cb8837e4" title="encode in big-endian format">Encode</a>(paddedBlock, paddedBlock.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>());<a name="l00142"></a>00142         <span class="keywordflow">return</span> GetMessageEncodingInterface().<a class="code" href="class_p_k___encryption_message_encoding_method.html#ae1a16a08fefe7d75063955f5efd4ad9">Unpad</a>(paddedBlock, <a class="code" href="class_t_f___crypto_system_base.html#bb04a40679e4c4ec5a0eb00b85615d56">PaddedBlockBitLength</a>(), plaintext, parameters);<a name="l00143"></a>00143 }<a name="l00144"></a>00144 <a name="l00145"></a><a class="code" href="class_t_f___encryptor_base.html#fa1feef1aeea65276bba4788f5d7b0b4">00145</a> <span class="keywordtype">void</span> <a class="code" href="class_t_f___encryptor_base.html#fa1feef1aeea65276bba4788f5d7b0b4" title="encrypt a byte string">TF_EncryptorBase::Encrypt</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> byte *plaintext, <span class="keywordtype">size_t</span> plaintextLength, byte *ciphertext, <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;parameters)<span class="keyword"> const</span><a name="l00146"></a>00146 <span class="keyword"></span>{<a name="l00147"></a>00147         <span class="keywordflow">if</span> (plaintextLength &gt; <a class="code" href="class_t_f___crypto_system_base.html#28e8c81f06982065c479b0eb561f3e86" title="return maximum plaintext length given the fixed ciphertext length, if one exists...">FixedMaxPlaintextLength</a>())<a name="l00148"></a>00148                 <span class="keywordflow">throw</span> <a class="code" href="class_invalid_argument.html" title="exception thrown when an invalid argument is detected">InvalidArgument</a>(<a class="code" href="class_algorithm.html#4f31510a192d1121856efe8ad0a9b844" title="returns name of this algorithm, not universally implemented yet">AlgorithmName</a>() + <span class="stringliteral">": message too long for this public key"</span>);<a name="l00149"></a>00149 <a name="l00150"></a>00150         <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> paddedBlock(<a class="code" href="class_t_f___crypto_system_base.html#5ad757b5d844b247b0f40969ab5d5957">PaddedBlockByteLength</a>());<a name="l00151"></a>00151         GetMessageEncodingInterface().<a class="code" href="class_p_k___encryption_message_encoding_method.html#f0277309b65e54263c1fe48bf384375a">Pad</a>(rng, plaintext, plaintextLength, paddedBlock, <a class="code" href="class_t_f___crypto_system_base.html#bb04a40679e4c4ec5a0eb00b85615d56">PaddedBlockBitLength</a>(), parameters);<a name="l00152"></a>00152         GetTrapdoorFunctionInterface().<a class="code" href="class_randomized_trapdoor_function.html#0ef90207f59fb08deaafed6ce1ff2e6a">ApplyRandomizedFunction</a>(rng, <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>(paddedBlock, paddedBlock.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>())).<a class="code" href="class_integer.html#c12ea467de9a609b86ec03d8cb8837e4" title="encode in big-endian format">Encode</a>(ciphertext, <a class="code" href="class_t_f___crypto_system_base.html#91638e029e369d985f7858ad7daf2019" title="return fixed ciphertext length, if one exists, otherwise return 0">FixedCiphertextLength</a>());<a name="l00153"></a>00153 }<a name="l00154"></a>00154 <a name="l00155"></a>00155 NAMESPACE_END<a name="l00156"></a>00156 <a name="l00157"></a>00157 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jun 1 11:11:23 2007 for Crypto++ by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.2 </small></address></body></html>

⌨️ 快捷键说明

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