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

📄 cryptlib_8cpp-source.html

📁 著名的密码库Crypto++的文档 C++语言的杰作。程序员必备。
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00152"></a>00152         } <span class="keywordflow">while</span> (value &gt; range);<a name="l00153"></a>00153 <a name="l00154"></a>00154         <span class="keywordflow">return</span> value+min;<a name="l00155"></a>00155 }<a name="l00156"></a>00156 <a name="l00157"></a><a class="code" href="class_random_number_generator.html#497145546d24e6d4abaf10b7e0f1ba17">00157</a> <span class="keywordtype">void</span> <a class="code" href="class_random_number_generator.html#497145546d24e6d4abaf10b7e0f1ba17" title="generate random array of bytes">RandomNumberGenerator::GenerateBlock</a>(byte *output, <span class="keywordtype">size_t</span> size)<a name="l00158"></a>00158 {<a name="l00159"></a>00159         <a class="code" href="class_array_sink.html" title="Copy input to a memory buffer.">ArraySink</a> s(output, size);<a name="l00160"></a>00160         <a class="code" href="class_random_number_generator.html#5cc474006e2c7383ec20cc4d0c2abbaf" title="generate random bytes as input to a BufferedTransformation">GenerateIntoBufferedTransformation</a>(s, BufferedTransformation::NULL_CHANNEL, size);<a name="l00161"></a>00161 }<a name="l00162"></a>00162 <a name="l00163"></a><a class="code" href="class_random_number_generator.html#44f70ad8fed869a4ee55f50ef8e6e699">00163</a> <span class="keywordtype">void</span> <a class="code" href="class_random_number_generator.html#44f70ad8fed869a4ee55f50ef8e6e699" title="generate and discard n bytes">RandomNumberGenerator::DiscardBytes</a>(<span class="keywordtype">size_t</span> n)<a name="l00164"></a>00164 {<a name="l00165"></a>00165         <a class="code" href="class_random_number_generator.html#5cc474006e2c7383ec20cc4d0c2abbaf" title="generate random bytes as input to a BufferedTransformation">GenerateIntoBufferedTransformation</a>(TheBitBucket(), BufferedTransformation::NULL_CHANNEL, n);<a name="l00166"></a>00166 }<a name="l00167"></a>00167 <a name="l00168"></a><a class="code" href="class_random_number_generator.html#5cc474006e2c7383ec20cc4d0c2abbaf">00168</a> <span class="keywordtype">void</span> <a class="code" href="class_random_number_generator.html#5cc474006e2c7383ec20cc4d0c2abbaf" title="generate random bytes as input to a BufferedTransformation">RandomNumberGenerator::GenerateIntoBufferedTransformation</a>(<a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> &amp;target, <span class="keyword">const</span> std::string &amp;channel, lword length)<a name="l00169"></a>00169 {<a name="l00170"></a>00170         <a class="code" href="class_fixed_size_sec_block.html" title="a SecBlock with fixed size, allocated statically">FixedSizeSecBlock&lt;byte, 256&gt;</a> buffer;<a name="l00171"></a>00171         <span class="keywordflow">while</span> (length)<a name="l00172"></a>00172         {<a name="l00173"></a>00173                 <span class="keywordtype">size_t</span> len = UnsignedMin(buffer.<a class="code" href="class_sec_block.html#f5999bffe3193e62719cc0792b0282a7">size</a>(), length);<a name="l00174"></a>00174                 <a class="code" href="class_random_number_generator.html#497145546d24e6d4abaf10b7e0f1ba17" title="generate random array of bytes">GenerateBlock</a>(buffer, len);<a name="l00175"></a>00175                 target.<a class="code" href="class_buffered_transformation.html#97a60b54fafdb3df59e1457ef629fc5f">ChannelPut</a>(channel, buffer, len);<a name="l00176"></a>00176                 length -= len;<a name="l00177"></a>00177         }<a name="l00178"></a>00178 }<a name="l00179"></a>00179 <span class="comment"></span><a name="l00180"></a>00180 <span class="comment">//! see NullRNG()</span><a name="l00181"></a><a class="code" href="class_class_null_r_n_g.html">00181</a> <span class="comment"></span><span class="keyword">class </span><a class="code" href="class_class_null_r_n_g.html" title="see NullRNG()">ClassNullRNG</a> : <span class="keyword">public</span> <a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a><a name="l00182"></a>00182 {<a name="l00183"></a>00183 <span class="keyword">public</span>:<a name="l00184"></a><a class="code" href="class_class_null_r_n_g.html#4339d2936dbca593ca7845de90a7420a">00184</a>         std::string <a class="code" href="class_algorithm.html#4f31510a192d1121856efe8ad0a9b844" title="returns name of this algorithm, not universally implemented yet">AlgorithmName</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <span class="stringliteral">"NullRNG"</span>;}<a name="l00185"></a><a class="code" href="class_class_null_r_n_g.html#3fe959f398f36e108f2ba3e57f17644f">00185</a>         <span class="keywordtype">void</span> <a class="code" href="class_random_number_generator.html#497145546d24e6d4abaf10b7e0f1ba17" title="generate random array of bytes">GenerateBlock</a>(byte *output, <span class="keywordtype">size_t</span> size) {<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">"NullRNG: NullRNG should only be passed to functions that don't need to generate random bytes"</span>);}<a name="l00186"></a>00186 };<a name="l00187"></a>00187 <a name="l00188"></a><a class="code" href="cryptlib_8h.html#fcd6162a0a4d19df92106149e7eaf55a">00188</a> <a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a> &amp; NullRNG()<a name="l00189"></a>00189 {<a name="l00190"></a>00190         <span class="keyword">static</span> <a class="code" href="class_class_null_r_n_g.html" title="see NullRNG()">ClassNullRNG</a> s_nullRNG;<a name="l00191"></a>00191         <span class="keywordflow">return</span> s_nullRNG;<a name="l00192"></a>00192 }<a name="l00193"></a>00193 <a name="l00194"></a><a class="code" href="class_hash_transformation.html#0f6069eadf492d970c3eb8cdf656e742">00194</a> <span class="keywordtype">bool</span> <a class="code" href="class_hash_transformation.html#0f6069eadf492d970c3eb8cdf656e742" title="truncated version of Verify()">HashTransformation::TruncatedVerify</a>(<span class="keyword">const</span> byte *digestIn, <span class="keywordtype">size_t</span> digestLength)<a name="l00195"></a>00195 {<a name="l00196"></a>00196         <a class="code" href="class_hash_transformation.html#64ba03d31c489dc32b50e00d377d8032">ThrowIfInvalidTruncatedSize</a>(digestLength);<a name="l00197"></a>00197         <a class="code" href="class_sec_block.html" title="a block of memory allocated using A">SecByteBlock</a> digest(digestLength);<a name="l00198"></a>00198         <a class="code" href="class_hash_transformation.html#590ecda344aa0fb045abf42ec08823b2" title="truncated version of Final()">TruncatedFinal</a>(digest, digestLength);<a name="l00199"></a>00199         <span class="keywordflow">return</span> memcmp(digest, digestIn, digestLength) == 0;<a name="l00200"></a>00200 }<a name="l00201"></a>00201 <a name="l00202"></a><a class="code" href="class_hash_transformation.html#64ba03d31c489dc32b50e00d377d8032">00202</a> <span class="keywordtype">void</span> <a class="code" href="class_hash_transformation.html#64ba03d31c489dc32b50e00d377d8032">HashTransformation::ThrowIfInvalidTruncatedSize</a>(<span class="keywordtype">size_t</span> size)<span class="keyword"> const</span><a name="l00203"></a>00203 <span class="keyword"></span>{<a name="l00204"></a>00204         <span class="keywordflow">if</span> (size &gt; <a class="code" href="class_hash_transformation.html#41faf8b1293a6c72390cb0c8bd668097" title="size of the hash returned by Final()">DigestSize</a>())<a name="l00205"></a>00205                 <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">"HashTransformation: can't truncate a "</span> + IntToString(<a class="code" href="class_hash_transformation.html#41faf8b1293a6c72390cb0c8bd668097" title="size of the hash returned by Final()">DigestSize</a>()) + <span class="stringliteral">" byte digest to "</span> + IntToString(size) + <span class="stringliteral">" bytes"</span>);<a name="l00206"></a>00206 }<a name="l00207"></a>00207 <a name="l00208"></a><a class="code" href="class_buffered_transformation.html#051a0b5e3e4cc81aca43a9c6cb02e0f9">00208</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_buffered_transformation.html#051a0b5e3e4cc81aca43a9c6cb02e0f9" title="maximum number of wait objects that this object can return">BufferedTransformation::GetMaxWaitObjectCount</a>()<span class="keyword"> const</span><a name="l00209"></a>00209 <span class="keyword"></span>{<a name="l00210"></a>00210         <span class="keyword">const</span> <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *t = <a class="code" href="class_buffered_transformation.html#ba6bbc169e26ed77a6bb5d50f91abda0" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>();<a name="l00211"></a>00211         <span class="keywordflow">return</span> t ? t-&gt;<a class="code" href="class_buffered_transformation.html#051a0b5e3e4cc81aca43a9c6cb02e0f9" title="maximum number of wait objects that this object can return">GetMaxWaitObjectCount</a>() : 0;<a name="l00212"></a>00212 }<a name="l00213"></a>00213 <a name="l00214"></a><a class="code" href="class_buffered_transformation.html#127ccd1793fdda6548cd1295f848d0f7">00214</a> <span class="keywordtype">void</span> <a class="code" href="class_buffered_transformation.html#127ccd1793fdda6548cd1295f848d0f7" title="put wait objects into container">BufferedTransformation::GetWaitObjects</a>(<a class="code" href="class_wait_object_container.html" title="container of wait objects">WaitObjectContainer</a> &amp;container, <a class="code" href="class_call_stack.html">CallStack</a> <span class="keyword">const</span>&amp; callStack)<a name="l00215"></a>00215 {<a name="l00216"></a>00216         <a class="code" href="class_buffered_transformation.html" title="interface for buffered transformations">BufferedTransformation</a> *t = <a class="code" href="class_buffered_transformation.html#ba6bbc169e26ed77a6bb5d50f91abda0" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>();<a name="l00217"></a>00217         <span class="keywordflow">if</span> (t)<a name="l00218"></a>00218                 t-&gt;<a class="code" href="class_buffered_transformation.html#127ccd1793fdda6548cd1295f848d0f7" title="put wait objects into container">GetWaitObjects</a>(container, callStack);  <span class="comment">// reduce clutter by not adding to stack here</span><a name="l00219"></a>00219 }<a name="l00220"></a>00220 <a name="l00221"></a><a class="code" href="class_buffered_transformation.html#0dd5456c06e0e47d901e8055b50df929">00221</a> <span class="keywordtype">void</span> <a class="code" href="class_buffered_transformation.html#0dd5456c06e0e47d901e8055b50df929" title="initialize or reinitialize this object">BufferedTransformation::Initialize</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;parameters, <span class="keywordtype">int</span> propagation)<a name="l00222"></a>00222 {<a name="l00223"></a>00223         assert(!<a class="code" href="class_buffered_transformation.html#ba6bbc169e26ed77a6bb5d50f91abda0" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>());<a name="l00224"></a>00224         <a class="code" href="class_buffered_transformation.html#7bb05ac3b6302e2ab994586d526fa804">IsolatedInitialize</a>(parameters);<a name="l00225"></a>00225 }<a name="l00226"></a>00226 <a name="l00227"></a><a class="code" href="class_buffered_transformation.html#8a62b1b6c8f310363f32b05b20c306eb">00227</a> <span class="keywordtype">bool</span> <a class="code" href="class_buffered_transformation.html#8a62b1b6c8f310363f32b05b20c306eb" title="flush buffered input and/or output">BufferedTransformation::Flush</a>(<span class="keywordtype">bool</span> hardFlush, <span class="keywordtype">int</span> propagation, <span class="keywordtype">bool</span> blocking)<a name="l00228"></a>00228 {<a name="l00229"></a>00229         assert(!<a class="code" href="class_buffered_transformation.html#ba6bbc169e26ed77a6bb5d50f91abda0" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>());<a name="l00230"></a>00230         <span class="keywordflow">return</span> IsolatedFlush(hardFlush, blocking);<a name="l00231"></a>00231 }<a name="l00232"></a>00232 <a name="l00233"></a><a class="code" href="class_buffered_transformation.html#ae4c5ae024419e31bfa0c24eb35b24c2">00233</a> <span class="keywordtype">bool</span> <a class="code" href="class_buffered_transformation.html#ae4c5ae024419e31bfa0c24eb35b24c2" title="mark end of a series of messages">BufferedTransformation::MessageSeriesEnd</a>(<span class="keywordtype">int</span> propagation, <span class="keywordtype">bool</span> blocking)<a name="l00234"></a>00234 {<a name="l00235"></a>00235         assert(!<a class="code" href="class_buffered_transformation.html#ba6bbc169e26ed77a6bb5d50f91abda0" title="returns the object immediately attached to this object or NULL for no attachment">AttachedTransformation</a>());<a name="l00236"></a>00236         <span class="keywordflow">return</span> <a class="code" href="class_buffered_transformation.html#af09f0cd6dbd022539a9ac5c316d4984">IsolatedMessageSeriesEnd</a>(blocking);<a name="l00237"></a>00237 }

⌨️ 快捷键说明

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