public class CtrBlockCipher extends Object implements SeekableBlockCipher
SICBlockCipher
class,
but allows random access to a block, too.
Like the SICBlockCipher
class, the block counter is incremented
after updating the cipher input in big endian order.Modifier and Type | Field and Description |
---|---|
protected long |
blockCounter |
protected int |
blockSize |
protected BlockCipher |
cipher |
protected byte[] |
cipherIn |
protected byte[] |
cipherOut |
protected byte[] |
IV |
Constructor and Description |
---|
CtrBlockCipher(BlockCipher cipher)
Constructs a new CTR block cipher.
|
Modifier and Type | Method and Description |
---|---|
String |
getAlgorithmName() |
long |
getBlockCounter()
Returns the index of the block, starting at 0, which will be processed
next when
BlockCipher.processBlock(byte[], int, byte[], int) is called. |
int |
getBlockSize() |
protected void |
incCounter() |
void |
init(boolean forEncryption,
CipherParameters params) |
int |
processBlock(byte[] in,
int inOff,
byte[] out,
int outOff) |
void |
reset() |
void |
setBlockCounter(long blockCounter)
Sets the counter so that the block with the given index, starting
at 0, can be processed next.
|
protected long blockCounter
protected final int blockSize
protected final BlockCipher cipher
protected final byte[] cipherIn
protected final byte[] cipherOut
protected final byte[] IV
public CtrBlockCipher(BlockCipher cipher)
cipher
- The underlying block cipher to use.public String getAlgorithmName()
getAlgorithmName
in interface BlockCipher
public long getBlockCounter()
SeekableBlockCipher
BlockCipher.processBlock(byte[], int, byte[], int)
is called.getBlockCounter
in interface SeekableBlockCipher
public int getBlockSize()
getBlockSize
in interface BlockCipher
protected void incCounter()
public void init(boolean forEncryption, CipherParameters params)
init
in interface BlockCipher
public final int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException
processBlock
in interface BlockCipher
DataLengthException
IllegalStateException
public void reset()
reset
in interface BlockCipher
public void setBlockCounter(long blockCounter)
SeekableBlockCipher
setBlockCounter
in interface SeekableBlockCipher
blockCounter
- The index of the block, starting at 0, which will be
processed next when
BlockCipher.processBlock(byte[], int, byte[], int)
is called.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.