Sophie

Sophie

distrib > Fedora > 13 > i386 > media > os > by-pkgid > 07dfcfe50d66c9a48a3c5e6c1693f12a > files > 1902

cryptopp-doc-5.6.1-0.1.svn479.fc13.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Crypto++: rng.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>rng.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// rng.h - misc RNG related classes, see also osrng.h, randpool.h</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="preprocessor">#ifndef CRYPTOPP_RNG_H</span>
<a name="l00004"></a>00004 <span class="preprocessor"></span><span class="preprocessor">#define CRYPTOPP_RNG_H</span>
<a name="l00005"></a>00005 <span class="preprocessor"></span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &quot;<a class="code" href="cryptlib_8h.html">cryptlib.h</a>&quot;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &quot;filters.h&quot;</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 NAMESPACE_BEGIN(CryptoPP)
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">//! linear congruential generator</span>
<a name="l00012"></a>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> class <a class="code" href="class_l_c___r_n_g.html" title="linear congruential generator">LC_RNG</a> : public <a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a>
<a name="l00014"></a>00014 {
<a name="l00015"></a>00015 <span class="keyword">public</span>:
<a name="l00016"></a>00016         <a class="code" href="class_l_c___r_n_g.html" title="linear congruential generator">LC_RNG</a>(word32 init_seed)
<a name="l00017"></a>00017                 : seed(init_seed) {}
<a name="l00018"></a>00018 
<a name="l00019"></a>00019         <span class="keywordtype">void</span> GenerateBlock(byte *output, <span class="keywordtype">size_t</span> size);
<a name="l00020"></a>00020 
<a name="l00021"></a>00021         word32 GetSeed() {<span class="keywordflow">return</span> seed;}
<a name="l00022"></a>00022 
<a name="l00023"></a>00023 <span class="keyword">private</span>:
<a name="l00024"></a>00024         word32 seed;
<a name="l00025"></a>00025 
<a name="l00026"></a>00026         <span class="keyword">static</span> <span class="keyword">const</span> word32 m;
<a name="l00027"></a>00027         <span class="keyword">static</span> <span class="keyword">const</span> word32 q;
<a name="l00028"></a>00028         <span class="keyword">static</span> <span class="keyword">const</span> word16 a;
<a name="l00029"></a>00029         <span class="keyword">static</span> <span class="keyword">const</span> word16 r;
<a name="l00030"></a>00030 };
<a name="l00031"></a>00031 <span class="comment"></span>
<a name="l00032"></a>00032 <span class="comment">//! RNG derived from ANSI X9.17 Appendix C</span>
<a name="l00033"></a>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 <a class="code" href="class_x917_r_n_g.html" title="RNG derived from ANSI X9.17 Appendix C.">X917RNG</a> : <span class="keyword">public</span> <a class="code" href="class_random_number_generator.html" title="interface for random number generators">RandomNumberGenerator</a>, <span class="keyword">public</span> <a class="code" href="class_not_copyable.html">NotCopyable</a>
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036 <span class="keyword">public</span>:
<a name="l00037"></a>00037         <span class="comment">// cipher will be deleted by destructor, deterministicTimeVector = 0 means obtain time vector from system</span>
<a name="l00038"></a>00038         <a class="code" href="class_x917_r_n_g.html" title="RNG derived from ANSI X9.17 Appendix C.">X917RNG</a>(<a class="code" href="class_block_transformation.html" title="interface for the data processing part of block ciphers">BlockTransformation</a> *cipher, <span class="keyword">const</span> byte *seed, <span class="keyword">const</span> byte *deterministicTimeVector = 0);
<a name="l00039"></a>00039 
<a name="l00040"></a>00040         <span class="keywordtype">void</span> <a class="code" href="class_random_number_generator.html#a5cc474006e2c7383ec20cc4d0c2abbaf" title="generate random bytes as input to a BufferedTransformation">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 size);
<a name="l00041"></a>00041 
<a name="l00042"></a>00042 <span class="keyword">private</span>:
<a name="l00043"></a>00043         <a class="code" href="classmember__ptr.html">member_ptr&lt;BlockTransformation&gt;</a> cipher;
<a name="l00044"></a>00044         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> S;                 <span class="comment">// blocksize of cipher</span>
<a name="l00045"></a>00045         <a class="code" href="class_sec_block.html">SecByteBlock</a> dtbuf;     <span class="comment">// buffer for enciphered timestamp</span>
<a name="l00046"></a>00046         <a class="code" href="class_sec_block.html">SecByteBlock</a> randseed, m_lastBlock, m_deterministicTimeVector;
<a name="l00047"></a>00047 };
<a name="l00048"></a>00048 <span class="comment"></span>
<a name="l00049"></a>00049 <span class="comment">/** This class implements Maurer&apos;s Universal Statistical Test for Random Bit Generators</span>
<a name="l00050"></a>00050 <span class="comment">    it is intended for measuring the randomness of *PHYSICAL* RNGs.</span>
<a name="l00051"></a>00051 <span class="comment">    For more details see his paper in Journal of Cryptology, 1992. */</span>
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="class_maurer_randomness_test.html">00053</a> <span class="keyword">class </span><a class="code" href="class_maurer_randomness_test.html" title="This class implements Maurer&amp;#39;s Universal Statistical Test for Random Bit Generators...">MaurerRandomnessTest</a> : <span class="keyword">public</span> <a class="code" href="class_bufferless.html" title="_">Bufferless</a>&lt;Sink&gt;
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055 <span class="keyword">public</span>:
<a name="l00056"></a>00056         <a class="code" href="class_maurer_randomness_test.html" title="This class implements Maurer&amp;#39;s Universal Statistical Test for Random Bit Generators...">MaurerRandomnessTest</a>();
<a name="l00057"></a>00057 
<a name="l00058"></a>00058         <span class="keywordtype">size_t</span> <a class="code" href="class_maurer_randomness_test.html#ae2629df58de48eafc8b8d9f0b060ff98" title="input multiple bytes for blocking or non-blocking processing">Put2</a>(<span class="keyword">const</span> byte *inString, <span class="keywordtype">size_t</span> length, <span class="keywordtype">int</span> messageEnd, <span class="keywordtype">bool</span> blocking);
<a name="l00059"></a>00059 
<a name="l00060"></a>00060         <span class="comment">// BytesNeeded() returns how many more bytes of input is needed by the test</span>
<a name="l00061"></a>00061         <span class="comment">// GetTestValue() should not be called before BytesNeeded()==0</span>
<a name="l00062"></a>00062         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> BytesNeeded()<span class="keyword"> const </span>{<span class="keywordflow">return</span> n &gt;= (Q+K) ? 0 : Q+K-n;}
<a name="l00063"></a>00063 
<a name="l00064"></a>00064         <span class="comment">// returns a number between 0.0 and 1.0, describing the quality of the</span>
<a name="l00065"></a>00065         <span class="comment">// random numbers entered</span>
<a name="l00066"></a>00066         <span class="keywordtype">double</span> GetTestValue() <span class="keyword">const</span>;
<a name="l00067"></a>00067 
<a name="l00068"></a>00068 <span class="keyword">private</span>:
<a name="l00069"></a>00069         <span class="keyword">enum</span> {L=8, V=256, Q=2000, K=2000};
<a name="l00070"></a>00070         <span class="keywordtype">double</span> sum;
<a name="l00071"></a>00071         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n;
<a name="l00072"></a>00072         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tab[V];
<a name="l00073"></a>00073 };
<a name="l00074"></a>00074 
<a name="l00075"></a>00075 NAMESPACE_END
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on 9 Dec 2009 for Crypto++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>