|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.security.random.SeedGenerator | +--iaik.security.random.HashObjectSeedGenerator
This seed generator is an abstract class designed to help you write seedgenerators that distill randomness from objects fed to it. Often applications will have access to data that includes some amount of randomness, like for example the events generated by the user moving his mouse. This randomness (plus possibly some non-random data) will be hashed by a MessageDigest object, its hash is the seed returned by this class.
The usage is rather simple. You just have to subclass this class and implement
the abstract method extractSeedData()
. Every time the user passes
an object to this class via addSeedObject
this object will be
passed to extractSeedData()
. The task of this method is
to extract randomness from the object and call one of the updateHash()
methods. Note that it should never hurt to hash not only the random parts
but also deterministic data, i.e. you can hash all fields of the object.
It is recommended to hash the current time as obtained by
System.currentTimeMillis()
in addition to be object itself.
For more information see the documentation of the extractSeedData()
and getMessageDigest()
methods.
SeedGenerator
,
AWT11SeedGenerator
,
AWT10SeedGenerator
Fields inherited from class iaik.security.random.SeedGenerator |
seedGenListener |
Constructor Summary | |
protected |
HashObjectSeedGenerator(int numBits)
Constructor for use by subclasses. |
Method Summary | |
boolean |
addSeedObject(Object obj)
Feed a new seed object to this seed generator. |
protected abstract int |
extractSeedData(Object obj)
This method extracts the random information from the object and updates the hash accordingly. |
protected MessageDigest |
getMessageDigest()
Return a new MessageDigest object to be used to digest the random information. |
byte[] |
getSeed()
Return the random seed. |
int[] |
getStatus()
Return the current status of seed generation. |
protected void |
updateHash(byte[] data)
Update the hash by data. |
protected void |
updateHash(long l)
Update the hash by longToBytes(l). |
protected void |
updateHash(String data)
Update the hash by data.getBytes(). |
Methods inherited from class iaik.security.random.SeedGenerator |
callSeedGenListener, getDefault, getDefaultSeedGenerator, longToBytes, seedAvailable, setDefault, setDefaultSeedGenerator, setSeedGenListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected HashObjectSeedGenerator(int numBits)
Method Detail |
protected MessageDigest getMessageDigest()
public final int[] getStatus()
getStatus
in class SeedGenerator
protected final void updateHash(byte[] data)
protected final void updateHash(String data)
protected final void updateHash(long l)
protected abstract int extractSeedData(Object obj) throws RandomException
addSeedObject()
only. It should return the number of random
bits obtained from the object. If the object is an instance of an unsupported
class it should throw a RandomException
.public final boolean addSeedObject(Object obj) throws RandomException
extractSeedData()
and the SeedGenListener (if one is registered).
If more seed objects are needed it return true, otherwise false.
If seed generation is already completed when this method is called,
it will instantly return false.public final byte[] getSeed()
getSeed
in class SeedGenerator
|
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 |