|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.security.random.SeedGenerator
A SeedGenerator is a class that "computes" random bits that can be used as seed for pseudo-random number generators (PRNG). This is an abstract class, subclasses have to implement this functionality. The generated bits should be truely random and non-deterministically generated based on e.g. user input, specialized external devices, or possibly the non-deterministic behaviour of a multi tasking operating system. Ideally all random bits needed for cryptographic applications would be generated in such a truely non-deterministic, random way. However, this turns out to be quite difficult on our (mostly ;) deterministic computers, therefore, only a random seed value is generated and then used with a deterministic PRNG. However, you should not use a single seed to generate a extremely long pseudo random sequence. In those cases it is advisable that you create a new seed every now and then.
The important point is that an attacker should have a probability no larger than 2-n of guessing the correct n bit seed, nor should he be able to manipulate the random bit generation in a way to increase his probability of guessing it. Note that the attacker could reside on (in order of increasing difficulty for us) on (a) some machine connected to us via the Internet or some other WAN (b) on the same LAN (c) running tasks on the same machine (d) have full control over the OS run on our machine and (e) be the user running the seed generator himself. Obviously applications will usually not be concerned all of these cases, but only the first two or three.
Also note that if a seed of e.g. 64 bit is fed to a PRNG which is later used to generate a 128 bit random encryption key, the effective strength of that key is only 64 bit because an attacker could recreate the deterministic steps used to blow up the seed from 64 to 128 bit. On the other hand it would be no problem at all to generate an arbitrary number of 56 bit keys from our 64 bit seed. In short, this means that the seed should always be at least as long as the longest independent random value that needs to be generated from it.
General API usage:
getSeed()
. Those will often be the output of some message
digest function and therefore be of constant length.
getSeed()
or it might be available immediately. You can check whether the seed is
ready by using a SeedGenListener
, you can call
seedAvailable()
, etc.
getSeed()
. Calling
getSeed
again will yield the same seed, if you want to generate
more random bits you have to create a new SeedGenerator object.
AWT11SeedGenerator
,
MetaSeedGenerator
,
AutoSeedGenerator
Field Summary | |
protected SeedGenListener |
seedGenListener
The current SeedGenListener of this class. |
Constructor Summary | |
protected |
SeedGenerator()
Constructor for use by subclasses. |
Method Summary | |
protected void |
callSeedGenListener()
If a SeedGenListener is set, call it with the parameters returned by getStatus. |
static SeedGenerator |
getDefault()
Get a new instance of the default seed generator. |
static SeedGenerator |
getDefaultSeedGenerator()
Deprecated. use getDefault() instead. |
abstract byte[] |
getSeed()
Get the generated random seed bits. |
abstract int[] |
getStatus()
Get the current status of seed generation. |
protected static byte[] |
longToBytes(long l)
Convert the given long to a byte array, MSB first. |
boolean |
seedAvailable()
Check whether the seed is available to be fetched via getSeed() .
|
static void |
setDefault(Class clazz)
Set the default seed generator. |
static void |
setDefaultSeedGenerator(SeedGenerator g)
Deprecated. use setDefault() instead. |
void |
setSeedGenListener(SeedGenListener seedGenListener)
Sets the SeedGenListener for this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected SeedGenListener seedGenListener
Constructor Detail |
protected SeedGenerator()
Method Detail |
public static SeedGenerator getDefault()
public static void setDefault(Class clazz)
IllegalArgumentException
- if there was an error with the SeedGeneratorpublic abstract byte[] getSeed()
public abstract int[] getStatus()
getStatus()[0]
equals
getStatus()[1]
, the seed is ready to be fetched via
getSeed()
.public final boolean seedAvailable()
getSeed()
.
This is implemented by calling getStatus()
.protected void callSeedGenListener()
public void setSeedGenListener(SeedGenListener seedGenListener)
protected static byte[] longToBytes(long l)
public static void setDefaultSeedGenerator(SeedGenerator g) throws RandomException
public static SeedGenerator getDefaultSeedGenerator()
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |