public class AWT11SeedGenerator extends HashObjectSeedGenerator
HashObjectSeedGenerator
and uses its API, see there for more documentation.
The API:
A seedGenListener should implement at least one of the MouseMotionListener, MouseListener, and KeyListener interfaces. The default listener implements all of them, but only uses the mousePressed, mouseMoved, mouseDragged, and keyTyped events to build the random seed. The other events are ignored for the reasons explained below. If you write your own listener, just make it call addSeedObject() for all events you wish to use for seeding.
Every time addEvent() is called, it will add the current time as returned by System.currentTimeMillis(), the string representation of the event as obtained by toString(), and the identityHashCode() of the event to the input of an SHA-1 hash. The string representation of an event contains all the information about the event (event source, event type, event parameters, etc). When getSeed() is finally called, the hash is returned, therefore it is always 20 bytes long. This also means, that one instance of this class can generate no more than 160 random bits.
This class assumes that the amount of uncertainty per event is (on average) at least three bits per event. In other words this means that an attacker would have to use no more than eight tries (on average) to guess all of these correctly:
seedGenListener
Constructor and Description |
---|
AWT11SeedGenerator()
Generate a seed generator for the default number of random bits
(currently 136).
|
AWT11SeedGenerator(int numBits)
Generate a seed generator for the specified number of bits.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addEvent(java.awt.AWTEvent event)
Deprecated.
use addSeedObject() instead.
|
void |
addEventSource(java.awt.Component component)
Add a component as a source of events.
|
protected int |
extractSeedData(java.lang.Object obj)
Add the given event to the seed.
|
void |
setEventListener(java.lang.Object listener)
Set the event listener that will pass the events to us.
|
addSeedObject, getMessageDigest, getSeed, getStatus, reinit, updateHash, updateHash, updateHash
getDefault, getSeedLength, hasSeedLengthChanged, setDefault, setSeedLength
callSeedGenListener, getDefault, getDefaultSeedGenerator, seedAvailable, setDefaultSeedGenerator, setSeedGenListener
public AWT11SeedGenerator(int numBits)
public AWT11SeedGenerator()
public void setEventListener(java.lang.Object listener)
public void addEventSource(java.awt.Component component)
public boolean addEvent(java.awt.AWTEvent event)
protected int extractSeedData(java.lang.Object obj) throws java.lang.IllegalArgumentException
addSeedObject()
with the object
passed to it.extractSeedData
in class HashObjectSeedGenerator
RandomException
- if obj is not a subclass of java.awt.event.AWTEventjava.lang.IllegalArgumentException