📄 pubkey_8cpp-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Crypto++: pubkey.cpp Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.2 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="classes.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 List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul></div><h1>pubkey.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// pubkey.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 "pch.h"</span><a name="l00004"></a>00004 <a name="l00005"></a>00005 <span class="preprocessor">#ifndef CRYPTOPP_IMPORTS</span><a name="l00006"></a>00006 <span class="preprocessor"></span><a name="l00007"></a>00007 <span class="preprocessor">#include "<a class="code" href="pubkey_8h.html" title="This file contains helper classes/functions for implementing public key algorithms...">pubkey.h</a>"</span><a name="l00008"></a>00008 <a name="l00009"></a>00009 NAMESPACE_BEGIN(CryptoPP)<a name="l00010"></a>00010 <a name="l00011"></a><a class="code" href="pubkey_8h.html#ca700ec196ece2df0ebe8e06d61f3240">00011</a> void P1363_MGF1KDF2_Common(<a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> &hash, byte *output, <span class="keywordtype">size_t</span> outputLength, const byte *input, <span class="keywordtype">size_t</span> inputLength, const byte *derivationParams, <span class="keywordtype">size_t</span> derivationParamsLength, <span class="keywordtype">bool</span> mask, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> counterStart)<a name="l00012"></a>00012 {<a name="l00013"></a>00013 <a class="code" href="class_array_sink.html" title="Copy input to a memory buffer.">ArraySink</a> *sink;<a name="l00014"></a>00014 <a class="code" href="class_hash_filter.html" title="Filter Wrapper for HashTransformation.">HashFilter</a> filter(hash, sink = mask ? <span class="keyword">new</span> <a class="code" href="class_array_xor_sink.html" title="Xor input to a memory buffer.">ArrayXorSink</a>(output, outputLength) : <span class="keyword">new</span> <a class="code" href="class_array_sink.html" title="Copy input to a memory buffer.">ArraySink</a>(output, outputLength));<a name="l00015"></a>00015 word32 counter = counterStart;<a name="l00016"></a>00016 <span class="keywordflow">while</span> (sink-><a class="code" href="class_array_sink.html#8a0b2bc344136755ae7edc83cea078cc">AvailableSize</a>() > 0)<a name="l00017"></a>00017 {<a name="l00018"></a>00018 filter.<a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(input, inputLength);<a name="l00019"></a>00019 filter.<a class="code" href="class_buffered_transformation.html#ffcc574867d51528afe3c96721ded075" title="input a 32-bit word">PutWord32</a>(counter++);<a name="l00020"></a>00020 filter.<a class="code" href="class_buffered_transformation.html#e70658b0d271f8e114ac6c3cc9774ede" title="input a byte for processing">Put</a>(derivationParams, derivationParamsLength);<a name="l00021"></a>00021 filter.<a class="code" href="class_buffered_transformation.html#20ae0ef2e4ff338b43849e541e9b940f">MessageEnd</a>();<a name="l00022"></a>00022 }<a name="l00023"></a>00023 }<a name="l00024"></a>00024 <a name="l00025"></a><a class="code" href="class_p_k___deterministic_signature_message_encoding_method.html#4031e7c508b4e28e82a45800d19d55fe">00025</a> <span class="keywordtype">bool</span> <a class="code" href="class_p_k___deterministic_signature_message_encoding_method.html#4031e7c508b4e28e82a45800d19d55fe">PK_DeterministicSignatureMessageEncodingMethod::VerifyMessageRepresentative</a>(<a name="l00026"></a>00026 <a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> &hash, <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> hashIdentifier, <span class="keywordtype">bool</span> messageEmpty,<a name="l00027"></a>00027 byte *representative, <span class="keywordtype">size_t</span> representativeBitLength)<span class="keyword"> const</span><a name="l00028"></a>00028 <span class="keyword"></span>{<a name="l00029"></a>00029 <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> computedRepresentative(BitsToBytes(representativeBitLength));<a name="l00030"></a>00030 ComputeMessageRepresentative(NullRNG(), NULL, 0, hash, hashIdentifier, messageEmpty, computedRepresentative, representativeBitLength);<a name="l00031"></a>00031 <span class="keywordflow">return</span> memcmp(representative, computedRepresentative, computedRepresentative.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>()) == 0;<a name="l00032"></a>00032 }<a name="l00033"></a>00033 <a name="l00034"></a><a class="code" href="class_p_k___recoverable_signature_message_encoding_method.html#956019572222b3c6c3d1631bf338ff17">00034</a> <span class="keywordtype">bool</span> <a class="code" href="class_p_k___recoverable_signature_message_encoding_method.html#956019572222b3c6c3d1631bf338ff17">PK_RecoverableSignatureMessageEncodingMethod::VerifyMessageRepresentative</a>(<a name="l00035"></a>00035 <a class="code" href="class_hash_transformation.html" title="interface for hash functions and data processing part of MACs">HashTransformation</a> &hash, <a class="code" href="pubkey_8h.html#ef874ed3f2d212ac4629255c8ef86dd0">HashIdentifier</a> hashIdentifier, <span class="keywordtype">bool</span> messageEmpty,<a name="l00036"></a>00036 byte *representative, <span class="keywordtype">size_t</span> representativeBitLength)<span class="keyword"> const</span><a name="l00037"></a>00037 <span class="keyword"></span>{<a name="l00038"></a>00038 <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> recoveredMessage(<a class="code" href="class_p_k___signature_message_encoding_method.html#d93488f6af02bd529106c78f6e177a29">MaxRecoverableLength</a>(representativeBitLength, hashIdentifier.second, hash.<a class="code" href="class_hash_transformation.html#41faf8b1293a6c72390cb0c8bd668097" title="size of the hash returned by Final()">DigestSize</a>()));<a name="l00039"></a>00039 <a class="code" href="struct_decoding_result.html" title="used to return decoding results">DecodingResult</a> result = <a class="code" href="class_p_k___signature_message_encoding_method.html#4debaa9f683a82bb11fbeb668bacbd04">RecoverMessageFromRepresentative</a>(<a name="l00040"></a>00040 hash, hashIdentifier, messageEmpty, representative, representativeBitLength, recoveredMessage);<a name="l00041"></a>00041 <span class="keywordflow">return</span> result.<a class="code" href="struct_decoding_result.html#b88062318cd0e68b3061db351d3ba34d">isValidCoding</a> && result.<a class="code" href="struct_decoding_result.html#f4496c82e5764175a27e36629e1cded7">messageLength</a> == 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -