org.logi.crypto
Class Producer
java.lang.Object
org.logi.crypto.Crypto
org.logi.crypto.Producer
- All Implemented Interfaces:
- java.lang.Runnable
- Direct Known Subclasses:
- OFBProducer
- public abstract class Producer
- extends Crypto
- implements java.lang.Runnable
Subclasses of Producer can run in their own thread producing bytes which
can be used by a consumer thread. The produced bytes are stored in a
fixed-size buffer, the size of which is specified when the object is
created.
Concrete implementations must implement the method
public abstract void calculate(byte[] buf);
to fill the array buf with the buf.length bytest
of the data to be buffered.
Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
Constructor Summary |
protected |
Producer(int bufSize)
Create a new Producer with 4 sub-buffers each holding bufSize bytes. |
Method Summary |
abstract void |
calculate(byte[] buf)
Fills buf with newly produced bytes. |
void |
kill()
Terminate the producer thread. |
byte[] |
nextBuffer()
Return the next array of bytes calculated by the producer. |
void |
run()
Repeatedly call calculate(byte[]) on each of the sub-buffers,
respecting the locking semantics of nextBuffer(). |
protected void |
start()
Start the producer thread. |
Methods inherited from class org.logi.crypto.Crypto |
binString, binString, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, readBlock, readInt, writeBytes, writeBytes, writeInt |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Producer
protected Producer(int bufSize)
- Create a new Producer with 4 sub-buffers each holding bufSize bytes.
kill
public void kill()
- Terminate the producer thread.
start
protected void start()
- Start the producer thread. This should be called by a sub-class when
it is ready to start calculating. This will probably be on the last
line of a constructor.
nextBuffer
public byte[] nextBuffer()
- Return the next array of bytes calculated by the producer. The thread
calling this method will have exclusive access to the returned array
until the next call to this method, after which the producer thread
may fill it with new bytes.
run
public void run()
- Repeatedly call calculate(byte[]) on each of the sub-buffers,
respecting the locking semantics of nextBuffer().
- Specified by:
run
in interface java.lang.Runnable
calculate
public abstract void calculate(byte[] buf)
- Fills buf with newly produced bytes.