|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.efs.Gatherer
public final class Gatherer
General gatherer of entropy from sources other than serlvet page hits. This can gather entropy from files, processes, and Web pages.
| Field Summary | |
|---|---|
static boolean |
DEFAULT_USESEEDFILE
Default value of useSeedFile. |
static java.lang.String |
PNAME__SRCLIST
Top-level property (attribute) name for the list of sources. |
static java.lang.String |
PNAME__USESEEDFILE
Top-level property (attribute) name for flag to use a seed file or not. |
| Constructor Summary | |
|---|---|
Gatherer(EntropyPool _pool,
GenParams _genParams,
SrcParams[] _sources,
java.io.File _seedFile)
Make new gatherer. |
|
| Method Summary | |
|---|---|
protected void |
finalize()
Make sure gathering has been stopped by GC of this Gatherer object. |
static java.security.DigestOutputStream |
getNullDigestStream()
Make a stream that computes a secure digest an throws away its content. |
EntropyPool |
getPool()
Recover a reference to the underlying EntropyPool; never returns null. |
static boolean |
mustConservePower(GenParams genParams)
If true, the system should conserve power (eg CPU cycles). |
static Gatherer |
parseGatherer(java.util.Properties p,
java.lang.String prefix,
EntropyPool pool,
java.io.File seedFile)
Retrieve Gatherer from Properties. |
void |
saveSeed()
Attempt to save a seed file (if seedFile is set). |
void |
start()
Call once after construction to start gatherer activity. |
void |
stop()
Stops the entropy gathering. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PNAME__SRCLIST
public static final boolean DEFAULT_USESEEDFILE
public static final java.lang.String PNAME__USESEEDFILE
| Constructor Detail |
|---|
public Gatherer(EntropyPool _pool,
GenParams _genParams,
SrcParams[] _sources,
java.io.File _seedFile)
None of these items need be private to this gatherer, eg other sources may inject bits into the same EntropyPool.
This will not start any gatherer activity until start() is called, and will stop that activity when stop() is called or when this object is garbage collected (the threads hold no reference back to this object).
We create one thread to manage each entropy source.
We may steal some bits from the pool at start-up to help hide our internal state and that of our gatherers and to try to prevent traffic analysis revealing anything about pool state.
Some methods on this object, such as start(), are synchronized for thread safety. Others, such as stop() and finalize() are not to avoid the possibility of deadlock in the GC process.
_sources - list of entropy source descriptions;
must be non-zero length and contain no nulls_seedFile - if non-null is the location of a seed file to
read (and overwrite) at startup, and to save to at shutdown
and possibly periodically in between; thus any seed file
but be readable/writable/creatable by us| Method Detail |
|---|
public EntropyPool getPool()
public void saveSeed()
throws java.io.IOException
We could disguise the seed file to hide it from some low-level disc or network-traffic sniffing by making it more redundant and by spreading out the bits.
We note the time that we successfully complete the saving of the seed.
java.io.IOException
public void start()
throws java.io.IOException
If the source is marked as expensive then the first run is deferred by that minimum interval. For a non-expensive source the first run is scheduled immediately. This avoids pestering/overusing an expensive source if we restart frequently, eg for crash/reboot.
If a seed file name has been passed to the constructor we attempt to read it after starting up our entropy gatherers, then attempt to immediately overwrite it with a new file of the right size to hide the old file contents.
java.lang.IllegalStateException - if called more than once
java.io.IOException - in case of difficulty reading/rewriting the
seed filepublic void stop()
Cancels all the timers (if not already done). Should be idempotent, but no attempt to use this class should be made after stop() has been called.
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
public static Gatherer parseGatherer(java.util.Properties p,
java.lang.String prefix,
EntropyPool pool,
java.io.File seedFile)
First this constructs a whitespace-separated list of names of sources to use. Then it looks up the general parameters. Then it looks up the sources by name. If the prefix is null then the property names used are of the form:
sources
useSeedFile
genParams.genAttributeName
srcParams.sourceName.srcAttributeName
else they are of the form:
prefix.sources
prefix.useSeedFile
prefix.genParams.genAttributeName
prefix.srcParams.sourceName.srcAttributeName
seedFile - if non-null and read/writable (or creatable)
and the useSeedFile property is true,
then use the given file as a seed file at start-up and shut-downpool - the EntropyPool that this gatherer will try to keep filledp - the properties to read from
(they are not altered by thus routine)prefix - the prefix to apply to property names; null means
no prefix at all else the value passed has a ``.'' appended
and is then prefixed to the property named used
java.lang.IllegalArgumentException - if any of the parameters
specified by the properties is invalid or unusablepublic static java.security.DigestOutputStream getNullDigestStream()
This uses the EntropyPool's preferred digest algorithm.
Use getMessageDigest() to get access to the underlying hash when you are done.
If a suitable hash/digest cannot be created this throws a fatal Error
java.lang.Error - if a suitable hash algorithm cannot be foundpublic static boolean mustConservePower(GenParams genParams)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||