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

📄 pubkey_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<a name="l00042"></a>00042 }<a name="l00043"></a>00043 <a name="l00044"></a><a class="code" href="class_t_f___signer_base.html#4451069dd6bfd6e6ea4a3a2dfbc675e4">00044</a> <span class="keywordtype">void</span> <a class="code" href="class_t_f___signer_base.html#4451069dd6bfd6e6ea4a3a2dfbc675e4">TF_SignerBase::InputRecoverableMessage</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> byte *recoverableMessage, <span class="keywordtype">size_t</span> recoverableMessageLength)<span class="keyword"> const</span><a name="l00045"></a>00045 <span class="keyword"></span>{<a name="l00046"></a>00046         <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="l00047"></a>00047         <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> <span class="keywordtype">id</span> = GetHashIdentifier();<a name="l00048"></a>00048         <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="l00049"></a>00049 <a name="l00050"></a>00050         <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="l00051"></a>00051                 <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="l00052"></a>00052 <a name="l00053"></a>00053         <span class="keywordtype">size_t</span> maxRecoverableLength = encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#d93488f6af02bd529106c78f6e177a29">MaxRecoverableLength</a>(<a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>(), GetHashIdentifier().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="l00054"></a>00054 <a name="l00055"></a>00055         <span class="keywordflow">if</span> (maxRecoverableLength == 0)<a name="l00056"></a>00056                 {<span class="keywordflow">throw</span> <a class="code" href="class_not_implemented.html" title="exception thrown by a class if a non-implemented method is called">NotImplemented</a>(<span class="stringliteral">"TF_SignerBase: this algorithm does not support messsage recovery or the key is too short"</span>);}<a name="l00057"></a>00057         <span class="keywordflow">if</span> (recoverableMessageLength &gt; maxRecoverableLength)<a name="l00058"></a>00058                 <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">"TF_SignerBase: the recoverable message part is too long for the given key and algorithm"</span>);<a name="l00059"></a>00059 <a name="l00060"></a>00060         ma.<a class="code" href="class_p_k___message_accumulator_base.html#345bc33d413c1fd7669de9d9d1f089c2">m_recoverableMessage</a>.<a class="code" href="class_sec_block.html#2cf5dc5e31c63eb927f935af6104f36a" title="set contents and size">Assign</a>(recoverableMessage, recoverableMessageLength);<a name="l00061"></a>00061         encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#02cb23717289879c7e0fc7a0af804be7">ProcessRecoverableMessage</a>(<a name="l00062"></a>00062                 ma.<a class="code" href="class_p_k___message_accumulator_base.html#2b50619968b03f69ba3ad7ba21e780bf">AccessHash</a>(), <a name="l00063"></a>00063                 recoverableMessage, recoverableMessageLength,<a name="l00064"></a>00064                 NULL, 0, ma.<a class="code" href="class_p_k___message_accumulator_base.html#80c5888ebcacfcdf50f950ebba950209">m_semisignature</a>);<a name="l00065"></a>00065 }<a name="l00066"></a>00066 <a name="l00067"></a><a class="code" href="class_t_f___signer_base.html#31c080b001c73b07ee26730383250fd7">00067</a> <span class="keywordtype">size_t</span> <a class="code" href="class_t_f___signer_base.html#31c080b001c73b07ee26730383250fd7" title="sign and restart messageAccumulator">TF_SignerBase::SignAndRestart</a>(<a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp;rng, <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, byte *signature, <span class="keywordtype">bool</span> restart)<span class="keyword"> const</span><a name="l00068"></a>00068 <span class="keyword"></span>{<a name="l00069"></a>00069         <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="l00070"></a>00070         <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> <span class="keywordtype">id</span> = GetHashIdentifier();<a name="l00071"></a>00071         <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="l00072"></a>00072 <a name="l00073"></a>00073         <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="l00074"></a>00074                 <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="l00075"></a>00075 <a name="l00076"></a>00076         <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> representative(<a class="code" href="class_t_f___signature_scheme_base.html#2bf7feb3520b0cb95bc28173309d9d55">MessageRepresentativeLength</a>());<a name="l00077"></a>00077         encoding.<a class="code" href="class_p_k___signature_message_encoding_method.html#6958314b1fedb2c960ab24cbdc60089b">ComputeMessageRepresentative</a>(rng, <a name="l00078"></a>00078                 ma.<a class="code" href="class_p_k___message_accumulator_base.html#345bc33d413c1fd7669de9d9d1f089c2">m_recoverableMessage</a>, ma.<a class="code" href="class_p_k___message_accumulator_base.html#345bc33d413c1fd7669de9d9d1f089c2">m_recoverableMessage</a>.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>(), <a name="l00079"></a>00079                 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>,<a name="l00080"></a>00080                 representative, <a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>());<a name="l00081"></a>00081         ma.<a class="code" href="class_p_k___message_accumulator_base.html#6d0a3ce0258e928c8fb146989a6a7884">m_empty</a> = <span class="keyword">true</span>;<a name="l00082"></a>00082 <a name="l00083"></a>00083         <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> r(representative, representative.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>());<a name="l00084"></a>00084         <span class="keywordtype">size_t</span> signatureLength = <a class="code" href="class_t_f___signature_scheme_base.html#206919065f471c351afa3c1e04acb6a8" title="signature length if it only depends on the key, otherwise 0">SignatureLength</a>();<a name="l00085"></a>00085         GetTrapdoorFunctionInterface().<a class="code" href="class_randomized_trapdoor_function_inverse.html#2c01608b61496578c5fe2967e69b923a">CalculateRandomizedInverse</a>(rng, r).<a class="code" href="class_integer.html#c12ea467de9a609b86ec03d8cb8837e4" title="encode in big-endian format">Encode</a>(signature, signatureLength);<a name="l00086"></a>00086         <span class="keywordflow">return</span> signatureLength;<a name="l00087"></a>00087 }<a name="l00088"></a>00088 <a name="l00089"></a><a class="code" href="class_t_f___verifier_base.html#45485ca98bca3ac643aa3067f1824abd">00089</a> <span class="keywordtype">void</span> <a class="code" href="class_t_f___verifier_base.html#45485ca98bca3ac643aa3067f1824abd" title="input signature into a message accumulator">TF_VerifierBase::InputSignature</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> byte *signature, <span class="keywordtype">size_t</span> signatureLength)<span class="keyword"> const</span><a name="l00090"></a>00090 <span class="keyword"></span>{<a name="l00091"></a>00091         <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="l00092"></a>00092         <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> <span class="keywordtype">id</span> = GetHashIdentifier();<a name="l00093"></a>00093         <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="l00094"></a>00094 <a name="l00095"></a>00095         <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="l00096"></a>00096                 <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="l00097"></a>00097 <a name="l00098"></a>00098         ma.<a class="code" href="class_p_k___message_accumulator_base.html#bbef3e3ccb561a43b3ee7446c838a0da">m_representative</a>.<a class="code" href="class_sec_block.html#90d46e577c951d81a2d25a4742a3e979" title="change size, without preserving contents">New</a>(<a class="code" href="class_t_f___signature_scheme_base.html#2bf7feb3520b0cb95bc28173309d9d55">MessageRepresentativeLength</a>());<a name="l00099"></a>00099         <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.html#06f1c5450f47d1de7143619b42f5167b">ApplyFunction</a>(<a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>(signature, signatureLength));<a name="l00100"></a>00100         <span class="keywordflow">if</span> (x.<a class="code" href="class_integer.html#867356d88074424328d0ebb9bea63254" title="number of significant bits = floor(log2(abs(*this))) + 1">BitCount</a>() &gt; <a class="code" href="class_t_f___signature_scheme_base.html#acc39dfaa15c562803f9517d5326bd70">MessageRepresentativeBitLength</a>())<a name="l00101"></a>00101                 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="l00102"></a>00102         x.<a class="code" href="class_integer.html#c12ea467de9a609b86ec03d8cb8837e4" title="encode in big-endian format">Encode</a>(ma.<a class="code" href="class_p_k___message_accumulator_base.html#bbef3e3ccb561a43b3ee7446c838a0da">m_representative</a>, ma.<a class="code" href="class_p_k___message_accumulator_base.html#bbef3e3ccb561a43b3ee7446c838a0da">m_representative</a>.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>());<a name="l00103"></a>00103 }

⌨️ 快捷键说明

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