blumshub_8cpp-source.html
来自「Crypto++是一个非常强大的密码学库,主要是功能全」· HTML 代码 · 共 63 行
HTML
63 行
<!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++: blumshub.cpp 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>blumshub.cpp</h1><div class="fragment"><pre>00001 <span class="comment">// blumshub.cpp - written and placed in the public domain by Wei Dai</span>00002 00003 <span class="preprocessor">#include "pch.h"</span>00004 <span class="preprocessor">#include "blumshub.h"</span>00005 00006 NAMESPACE_BEGIN(CryptoPP)00007 00008 PublicBlumBlumShub::PublicBlumBlumShub(<span class="keyword">const</span> <a class="code" href="class_integer.html">Integer</a> &n, <span class="keyword">const</span> <a class="code" href="class_integer.html">Integer</a> &seed)00009 : modn(n),00010 maxBits(BitPrecision(n.BitCount())-1)00011 {00012 current = modn.Square(modn.Square(seed));00013 bitsLeft = maxBits;00014 }00015 <a name="l00016"></a><a class="code" href="class_public_blum_blum_shub.html#_public_blum_blum_shuba1">00016</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_public_blum_blum_shub.html#_public_blum_blum_shuba1">PublicBlumBlumShub::GenerateBit</a>()00017 {00018 <span class="keywordflow">if</span> (bitsLeft==0)00019 {00020 current = modn.<a class="code" href="class_modular_arithmetic.html#_modular_arithmetica23">Square</a>(current);00021 bitsLeft = maxBits;00022 }00023 00024 <span class="keywordflow">return</span> current.<a class="code" href="class_integer.html#_integerz41_5">GetBit</a>(--bitsLeft);00025 }00026 <a name="l00027"></a><a class="code" href="class_public_blum_blum_shub.html#_public_blum_blum_shuba2">00027</a> byte <a class="code" href="class_public_blum_blum_shub.html#_public_blum_blum_shuba2">PublicBlumBlumShub::GenerateByte</a>()00028 {00029 byte b=0;00030 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i<8; i++)00031 b = (b << 1) | <a class="code" href="class_public_blum_blum_shub.html#_public_blum_blum_shuba1">PublicBlumBlumShub::GenerateBit</a>();00032 <span class="keywordflow">return</span> b;00033 }00034 00035 BlumBlumShub::BlumBlumShub(<span class="keyword">const</span> <a class="code" href="class_integer.html">Integer</a> &p, <span class="keyword">const</span> <a class="code" href="class_integer.html">Integer</a> &q, <span class="keyword">const</span> <a class="code" href="class_integer.html">Integer</a> &seed)00036 : <a class="code" href="class_public_blum_blum_shub.html">PublicBlumBlumShub</a>(p*q, seed),00037 p(p), q(q),00038 x0(modn.<a class="code" href="class_square.html">Square</a>(seed))00039 {00040 }00041 <a name="l00042"></a><a class="code" href="class_blum_blum_shub.html#_blum_blum_shuba2">00042</a> <span class="keywordtype">void</span> <a class="code" href="class_blum_blum_shub.html#_blum_blum_shuba2">BlumBlumShub::Seek</a>(dword index)00043 {00044 <a class="code" href="class_integer.html">Integer</a> e = a_exp_b_mod_c (2, ((index*8) / maxBits + 1), (p-1)*(q-1));00045 current = modn.<a class="code" href="class_abstract_ring.html#_euclidean_domain_ofa18">Exponentiate</a>(x0, e);00046 bitsLeft = maxBits - int((index*8) % maxBits);00047 }00048 00049 NAMESPACE_END</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Jul 8 23:34:09 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 + =
减小字号Ctrl + -
显示快捷键?