📄 rng_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Crypto++: rng.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.2 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Compound List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Compound Members</a> | <a class="qindex" href="globals.html">File Members</a></div><h1>rng.h</h1><div class="fragment"><pre>00001 <span class="comment">// rng.h - misc RNG related classes, see also osrng.h, randpool.h</span>00002 00003 <span class="preprocessor">#ifndef CRYPTOPP_RNG_H</span>00004 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_RNG_H</span>00005 <span class="preprocessor"></span>00006 <span class="preprocessor">#include "<a class="code" href="cryptlib_8h.html">cryptlib.h</a>"</span>00007 <span class="preprocessor">#include "filters.h"</span>00008 00009 NAMESPACE_BEGIN(CryptoPP)00010 00011 <span class="comment">//! linear congruential generator</span>00012 <span class="comment"></span><span class="comment">/*! originally by William S. England, do not use for cryptographic purposes */</span><a name="l00013"></a><a class="code" href="class_l_c___r_n_g.html">00013</a> <span class="keyword">class </span><a class="code" href="class_l_c___r_n_g.html">LC_RNG</a> : <span class="keyword">public</span> <a class="code" href="class_random_number_generator.html">RandomNumberGenerator</a>00014 {00015 <span class="keyword">public</span>:00016 <a class="code" href="class_l_c___r_n_g.html">LC_RNG</a>(word32 init_seed)00017 : seed(init_seed) {}00018 00019 byte <a class="code" href="class_l_c___r_n_g.html#_l_c___r_n_ga1">GenerateByte</a>();00020 00021 word32 GetSeed() {<span class="keywordflow">return</span> seed;}00022 00023 <span class="keyword">private</span>:00024 word32 seed;00025 00026 <span class="keyword">static</span> <span class="keyword">const</span> word32 m;00027 <span class="keyword">static</span> <span class="keyword">const</span> word32 q;00028 <span class="keyword">static</span> <span class="keyword">const</span> word16 a;00029 <span class="keyword">static</span> <span class="keyword">const</span> word16 r;00030 };00031 <span class="comment"></span>00032 <span class="comment">//! RNG derived from ANSI X9.17 Appendix C</span>00033 <span class="comment"></span><a name="l00034"></a><a class="code" href="class_x917_r_n_g.html">00034</a> <span class="keyword">class </span>CRYPTOPP_DLL X917RNG : <span class="keyword">public</span> <a class="code" href="class_random_number_generator.html">RandomNumberGenerator</a>, <span class="keyword">public</span> NotCopyable00035 {00036 <span class="keyword">public</span>:00037 <span class="comment">// cipher will be deleted by destructor, deterministicTimeVector = 0 means obtain time vector from system</span>00038 X917RNG(<a class="code" href="class_block_transformation.html">BlockTransformation</a> *cipher, <span class="keyword">const</span> byte *seed, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> deterministicTimeVector = 0);00039 00040 byte <a class="code" href="class_random_number_generator.html#_sapphire_r_n_ga2">GenerateByte</a>();00041 00042 <span class="keyword">private</span>:00043 member_ptr<BlockTransformation> cipher;00044 <span class="keyword">const</span> <span class="keywordtype">int</span> S; <span class="comment">// blocksize of cipher</span>00045 <a class="code" href="class_sec_block.html">SecByteBlock</a> dtbuf; <span class="comment">// buffer for enciphered timestamp</span>00046 <a class="code" href="class_sec_block.html">SecByteBlock</a> randseed, randbuf;00047 <span class="keywordtype">int</span> randbuf_counter; <span class="comment">// # of unused bytes left in randbuf</span>00048 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> m_deterministicTimeVector;00049 };00050 <span class="comment"></span>00051 <span class="comment">/** This class implements Maurer's Universal Statistical Test for Random Bit Generators</span>00052 <span class="comment"> it is intended for measuring the randomness of *PHYSICAL* RNGs.</span>00053 <span class="comment"> For more details see his paper in Journal of Cryptology, 1992. */</span>00054 <a name="l00055"></a><a class="code" href="class_maurer_randomness_test.html">00055</a> <span class="keyword">class </span><a class="code" href="class_maurer_randomness_test.html">MaurerRandomnessTest</a> : <span class="keyword">public</span> <a class="code" href="class_sink.html">Sink</a>00056 {00057 <span class="keyword">public</span>:00058 <a class="code" href="class_maurer_randomness_test.html">MaurerRandomnessTest</a>();00059 00060 <span class="keywordtype">void</span> <a class="code" href="class_buffered_transformation.html#_zlib_decompressorz1_0">Put</a>(byte inByte);00061 <span class="keywordtype">void</span> <a class="code" href="class_buffered_transformation.html#_zlib_decompressorz1_0">Put</a>(<span class="keyword">const</span> byte *inString, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> length);00062 00063 <span class="comment">// BytesNeeded() returns how many more bytes of input is needed by the test</span>00064 <span class="comment">// GetTestValue() should not be called before BytesNeeded()==0</span>00065 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> BytesNeeded()<span class="keyword"> const </span>{<span class="keywordflow">return</span> n >= (Q+K) ? 0 : Q+K-n;}00066 00067 <span class="comment">// returns a number between 0.0 and 1.0, describing the quality of the</span>00068 <span class="comment">// random numbers entered</span>00069 <span class="keywordtype">double</span> GetTestValue() <span class="keyword">const</span>;00070 00071 <span class="keyword">private</span>:00072 <span class="keyword">enum</span> {L=8, V=256, Q=2000, K=2000};00073 <span class="keywordtype">double</span> sum;00074 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n;00075 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tab[V];00076 };00077 00078 NAMESPACE_END00079 00080 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:24 2003 for Crypto++ by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -