Seed in PRG in crypto++

26 views
Skip to first unread message

Aydin Abadi

unread,
Feb 15, 2015, 7:13:42 AM2/15/15
to cryptop...@googlegroups.com
I need to know how I can store (or access) the seed generated by a pseudorandom generator in crypto++. So i need to access the random seed to re-use it for some purpose. 

Many thanks

Jean-Pierre Münch

unread,
Feb 15, 2015, 9:25:27 AM2/15/15
to cryptop...@googlegroups.com
Hey Aydin,

the possibilities you need depend highly on the generator.
If you want to use X917C/Randpool generator, sotring the seed won't help you much as it uses the current time at each function call.
If you need he seed, you won't get it from the auto-seeded versions. You'll need to take one of the PRNGs and seed it yourself.

If you really need the be able to reproduce the ouput, you may just want to use AES in CTR mode or something similar.
I don't see any other possibilities as it's the purpose of a PRNG to be unpredictable.

BR

JPM

Jeffrey Walton

unread,
Feb 15, 2015, 8:03:06 PM2/15/15
to cryptop...@googlegroups.com

On Sunday, February 15, 2015 at 7:13:42 AM UTC-5, Aydin Abadi wrote:
I need to know how I can store (or access) the seed generated by a pseudorandom generator in crypto++. So i need to access the random seed to re-use it for some purpose.

You will probably have to use a RandomPool and manage the seed yourself. See the wiki page on RandomNumberGenerator for details (http://www.cryptopp.com/wiki/RandomNumberGenerator).

Jeffrey Walton

unread,
Feb 16, 2015, 2:59:33 PM2/16/15
to cryptop...@googlegroups.com
A RandomPool is the wrong tool here because it also uses time in its calculations. Sorry about that - I should have checked before I made the recommendation.

You can use OFB_Mode<T>::Encryption because it indirectly inherits from RandomNumberGenerator by way of AdditiveCipherTemplate<T>. For T (the T for OFB mode), use something like 3-key TripleDES, Camellia or AES. Crypto++'s test.cpp actually uses the AES/OFB generator (its the thing returned from GlobalPRNG()). Note: other modes of operation do *not* inherit from RandomNumberGenerator, so you can't use them in this instance.

There's also an alternate AES-256 based generator available on the wiki page at http://www.cryptopp.com/wiki/RandomNumberGenerator. Fetch the AES_RNG header file if you are interested in using it (its a header only implementation).

Jeff

Jean-Pierre Münch

unread,
Feb 18, 2015, 3:14:17 PM2/18/15
to cryptop...@googlegroups.com
Am Montag, 16. Februar 2015 20:59:33 UTC+1 schrieb Jeffrey Walton:


On Sunday, February 15, 2015 at 8:03:06 PM UTC-5, Jeffrey Walton wrote:

On Sunday, February 15, 2015 at 7:13:42 AM UTC-5, Aydin Abadi wrote:
I need to know how I can store (or access) the seed generated by a pseudorandom generator in crypto++. So i need to access the random seed to re-use it for some purpose.

You will probably have to use a RandomPool and manage the seed yourself. See the wiki page on RandomNumberGenerator for details (http://www.cryptopp.com/wiki/RandomNumberGenerator).

A RandomPool is the wrong tool here because it also uses time in its calculations. Sorry about that - I should have checked before I made the recommendation.

You can use OFB_Mode<T>::Encryption because it indirectly inherits from RandomNumberGenerator by way of AdditiveCipherTemplate<T>. For T (the T for OFB mode), use something like 3-key TripleDES, Camellia or AES. Crypto++'s test.cpp actually uses the AES/OFB generator (its the thing returned from GlobalPRNG()). Note: other modes of operation do *not* inherit from RandomNumberGenerator, so you can't use them in this instance.

 Except for CTR-Mode.
Any cipher running in CTR mode can be used as PRNG.

BR

JPM
Reply all
Reply to author
Forward
0 new messages