Top Description Fields Constructors Methods
org.bouncycastle.crypto.internal.modes

public Class SICBlockCipher

extends StreamBlockCipher
implements SkippingStreamCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.internal.SkippingStreamCipher, org.bouncycastle.crypto.internal.SkippingCipher, org.bouncycastle.crypto.internal.StreamCipher
Imports
org.bouncycastle.crypto.internal.BlockCipher, .CipherParameters, .DataLengthException, .SkippingStreamCipher, .StreamBlockCipher, org.bouncycastle.crypto.internal.params.ParametersWithIV, org.bouncycastle.util.Arrays, .Pack

Implements the Segmented Integer Counter (SIC) mode on top of a simple block cipher. This mode is also known as CTR mode.

Field Summary

Modifier and TypeField and Description
private final int
private int
private final BlockCipher
private byte[]
private byte[]
private byte[]

Constructor Summary

AccessConstructor and Description
public
SICBlockCipher(BlockCipher
the block cipher to be used.
c
)

Basic constructor.

Method Summary

Modifier and TypeMethod and Description
private void
adjustCounter(long n)

protected byte
private void
private void
private void
decrementCounterPow2(int pow2Div8)

public String
public int
getBlockSize()

Implements org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).
public long
getPosition()

Implements org.bouncycastle.crypto.internal.SkippingCipher.getPosition.

Return the current "position" of the cipher
private void
incrementCounter(int offSet)

private void
private void
incrementCounterPow2(int pow2Div8)

public void
init(boolean
if true the cipher is initialised for encryption, if false for decryption.
forEncryption
,
CipherParameters
the key and other data required by the cipher.
params
)

Implements org.bouncycastle.crypto.internal.StreamCipher.init, org.bouncycastle.crypto.internal.BlockCipher.init.

Initialise the cipher.
public int
processBlock(byte[]
the array containing the input data.
in
,
int
offset into the in array the data starts at.
inOff
,
byte[]
the array the output data will be copied into.
out
,
int
the offset into the out array the output will start at.
outOff
)

Implements org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.
public void
public long
seekTo(long
the number of bytes in to set the cipher state to.
position
)

Implements org.bouncycastle.crypto.internal.SkippingCipher.seekTo.

Reset the cipher and then skip forward to a given position.
public long
skip(long
the number of bytes to skip (positive forward, negative backwards).
numberOfBytes
)

Implements org.bouncycastle.crypto.internal.SkippingCipher.skip.

Skip numberOfBytes forwards, or backwards.
Inherited from org.bouncycastle.crypto.internal.StreamBlockCipher:
getUnderlyingCipherprocessBytesreturnByte

Field Detail

blockSizeback to summary
private final int blockSize
byteCountback to summary
private int byteCount
cipherback to summary
private final BlockCipher cipher

Hides org.bouncycastle.crypto.internal.StreamBlockCipher.cipher.

counterback to summary
private byte[] counter
counterOutback to summary
private byte[] counterOut
IVback to summary
private byte[] IV

Constructor Detail

SICBlockCipherback to summary
public SICBlockCipher(BlockCipher c)

Basic constructor.

Parameters
c:BlockCipher

the block cipher to be used.

Method Detail

adjustCounterback to summary
private void adjustCounter(long n)
calculateByteback to summary
protected byte calculateByte(byte in) throws DataLengthException, IllegalStateException

Implements abstract org.bouncycastle.crypto.internal.StreamBlockCipher.calculateByte.

checkCounterback to summary
private void checkCounter()
decrementCounterback to summary
private void decrementCounter()
decrementCounterPow2back to summary
private void decrementCounterPow2(int pow2Div8)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.internal.StreamCipher.getAlgorithmName, org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.internal.StreamCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.

Returns:String

the name of the algorithm the cipher implements.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Doc from org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).

Returns:int

the block size for this cipher in bytes.

getPositionback to summary
public long getPosition()

Implements org.bouncycastle.crypto.internal.SkippingCipher.getPosition.

Doc from org.bouncycastle.crypto.internal.SkippingCipher.getPosition.

Return the current "position" of the cipher

Returns:long

the current byte position.

incrementCounterback to summary
private void incrementCounter(int offSet)
incrementCounterback to summary
private void incrementCounter()
incrementCounterPow2back to summary
private void incrementCounterPow2(int pow2Div8)
initback to summary
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException

Implements org.bouncycastle.crypto.internal.StreamCipher.init, org.bouncycastle.crypto.internal.BlockCipher.init.

Doc from org.bouncycastle.crypto.internal.StreamCipher.init.

Initialise the cipher.

Parameters
forEncryption:boolean

if true the cipher is initialised for encryption, if false for decryption.

params:CipherParameters

the key and other data required by the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
processBlockback to summary
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException

Implements org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Doc from org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.

Parameters
in:byte[]

the array containing the input data.

inOff:int

offset into the in array the data starts at.

out:byte[]

the array the output data will be copied into.

outOff:int

the offset into the out array the output will start at.

Returns:int

the number of bytes processed and produced.

Exceptions
DataLengthException:
if there isn't enough data in in, or space in out.
IllegalStateException:
if the cipher isn't initialised.
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.internal.StreamCipher.reset, org.bouncycastle.crypto.internal.BlockCipher.reset.

Doc from org.bouncycastle.crypto.internal.StreamCipher.reset.

reset the cipher. This leaves it in the same state it was at after the last init (if there was one).

seekToback to summary
public long seekTo(long position)

Implements org.bouncycastle.crypto.internal.SkippingCipher.seekTo.

Doc from org.bouncycastle.crypto.internal.SkippingCipher.seekTo.

Reset the cipher and then skip forward to a given position.

Parameters
position:long

the number of bytes in to set the cipher state to.

Returns:long

the byte position moved to.

skipback to summary
public long skip(long numberOfBytes)

Implements org.bouncycastle.crypto.internal.SkippingCipher.skip.

Doc from org.bouncycastle.crypto.internal.SkippingCipher.skip.

Skip numberOfBytes forwards, or backwards.

Parameters
numberOfBytes:long

the number of bytes to skip (positive forward, negative backwards).

Returns:long

the number of bytes actually skipped.