StreamBlockCipherpublic class StreamBlockCipher extends Object implements StreamCiphera wrapper for block ciphers with a single byte block size, so that they
can be treated like stream ciphers. |
Fields Summary |
---|
private BlockCipher | cipher | private byte[] | oneByte |
Constructors Summary |
---|
public StreamBlockCipher(BlockCipher cipher)basic constructor.
if (cipher.getBlockSize() != 1)
{
throw new IllegalArgumentException("block cipher block size != 1.");
}
this.cipher = cipher;
|
Methods Summary |
---|
public java.lang.String | getAlgorithmName()return the name of the algorithm we are wrapping.
return cipher.getAlgorithmName();
| public void | init(boolean forEncryption, CipherParameters params)initialise the underlying cipher.
cipher.init(forEncryption, params);
| public void | processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)process a block of bytes from in putting the result into out.
if (outOff + len > out.length)
{
throw new DataLengthException("output buffer too small in processBytes()");
}
for (int i = 0; i != len; i++)
{
cipher.processBlock(in, inOff + i, out, outOff + i);
}
| public void | reset()reset the underlying cipher. This leaves it in the same state
it was at after the last init (if there was one).
cipher.reset();
| public byte | returnByte(byte in)encrypt/decrypt a single byte returning the result.
oneByte[0] = in;
cipher.processBlock(oneByte, 0, oneByte, 0);
return oneByte[0];
|
|