|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fasteasytrade.JRandTest.Algo.Cipher
com.fasteasytrade.JRandTest.Algo.BBSPrng
BBS encryption algorithm.
The following program implements the Blum-Blum-Shub random bits generator. The test suite is according to FIPS 140-1. See "Handbook of Applied Cryptography" by Alfred J. Menezes et al Section 5.4.4 pages 181 - 183 and 5.40 Algorithm page 186.
Field Summary | |
(package private) int |
bit_length
n's length/num of bits |
(package private) BigInteger |
n
n = p * q, and calculations are done mod n. |
(package private) BigInteger |
p
prime (with probability < 2 ** -100) |
(package private) BigInteger |
q
prime (with probability < 2 ** -100) |
(package private) BigInteger |
x
x is the "state" of the prng. x = x**2 mod n. |
(package private) BigInteger |
x0
x0 is the "initial state" of the prng. |
Constructor Summary | |
(package private) |
BBSPrng()
|
(package private) |
BBSPrng(BigInteger n,
BigInteger p,
BigInteger q)
|
(package private) |
BBSPrng(BigInteger n,
BigInteger p,
BigInteger q,
BigInteger x)
|
(package private) |
BBSPrng(int x)
|
Method Summary | |
BigInteger |
getN()
Public key. |
BigInteger |
getP()
Secret key. |
BigInteger |
getQ()
Secret key (need only one of p or q). |
BigInteger |
getX()
Encryption: you need to get last x and write it to cipher output stream. |
long |
nextLong()
calculate x**2 mod n and returns lowest 64 bits. |
void |
reset()
Reset "state" of prng by setting x to x0 (initial x). |
(package private) void |
setup(int l)
select random p, q, n=p*q, x (mod n). |
void |
setX(BigInteger x)
|
Methods inherited from class com.fasteasytrade.JRandTest.Algo.Cipher |
compareBytes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
final int bit_length
BigInteger n
BigInteger p
BigInteger q
BigInteger x
BigInteger x0
reset method set x to x0.
Constructor Detail |
BBSPrng()
BBSPrng(int x)
BBSPrng(BigInteger n, BigInteger p, BigInteger q)
BBSPrng(BigInteger n, BigInteger p, BigInteger q, BigInteger x)
Method Detail |
void setup(int l)
l
- length of n, num of bits.public long nextLong()
public BigInteger getP()
public BigInteger getQ()
public BigInteger getN()
public BigInteger getX()
Decryption: you need to read "last x" from input stream, and calculate X0, the first x based on n (public key), p and q (secret key/keys).
public void setX(BigInteger x)
x
- new x0public void reset()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |