On Sep 13, 9:18 pm, Marco <[email protected]> wrote:
> How can i create a DETERMINISTIC, seeded random source?
>
> I tried various examples from the wiki, like the one below, and none
> of them generates the same block twice.
>
> What am I missing?
>
> const unsigned int SEEDSIZE = 16;
> byte pcbSeed[ SEEDSIZE ];
>
> const unsigned int BLOCKSIZE = 16 * 8;
> byte pcbScratch[ BLOCKSIZE ];
>
> //Set the seed to "xxxx...x"
> for(size_t i = 0; i < SEEDSIZE; ++i) {
>     pcbSeed[i] =  (byte)'x';
>
> }
>
> CryptoPP::RandomPool rng;
> // also tried
> // CryptoPP::AutoSeededX917RNG<CryptoPP::DES_EDE3> rng(true, false);
RandomPool is a PGP style pool, and its not deterministic. For example
RandomPool makes the following call:
    time_t t = time(NULL);
    ...

AutoSeededX917RNG is not not deterministic either.
IncorporateEntropy() calls Reseed(), which looks like:
    OS_GenerateRandomBlock(blocking, seed, seed.size());
    if (length > 0)
     {
        SHA256 hash;
        hash.Update(seed, seed.size());
        hash.Update(input, length);
        hash.TruncatedFinal(seed, UnsignedMin(hash.DigestSize(),
seed.size()));
    }

OS_GenerateRandomBlock will use OS provided services, such as /dev/
[u]random or CryptGenRandom.

The source for RandPool can be found at 
http://www.cryptopp.com/docs/ref/randpool_8cpp_source.html,
and AutoSeededX917RNG at http://www.cryptopp.com/docs/ref/osrng_8h_source.html.

LCGs are deterministic. http://www.cryptopp.com/docs/ref/class_l_c___r_n_g.html.

Jeff

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to