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

public Class G3413CTRBlockCipher

extends StreamBlockCipher
Class Inheritance
Imports
org.bouncycastle.crypto.BlockCipher, .CipherParameters, .DataLengthException, .StreamBlockCipher, org.bouncycastle.crypto.params.ParametersWithIV, org.bouncycastle.util.Arrays

implements the GOST 3412 2015 CTR counter mode (GCTR).

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
G3413CTRBlockCipher(BlockCipher
the block cipher to be used as the basis of the counter mode (must have a 64 bit block size).
cipher
)

Basic constructor.

public
G3413CTRBlockCipher(BlockCipher
the block cipher to be used as the basis of the counter mode (must have a 64 bit block size).
cipher
,
int
basic unit (defined as s)
bitBlockSize
)

Basic constructor.

Method Summary

Modifier and TypeMethod and Description
protected byte
private byte[]
private void
public String

Returns:

the name of the underlying algorithm followed by "/GCTR" and the block size in bits
getAlgorithmName
()

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

return the algorithm name and mode.

public int

Returns:

the block size we are operating at (in bytes).
getBlockSize
()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

return the block size we are operating at (in bytes).

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

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

Initialise the cipher and, possibly, the initialisation vector (IV).

private void
public int

Returns:

the number of bytes processed and produced.
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.BlockCipher.processBlock.

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

public void
reset()

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

reset the feedback vector back to the IV and reset the underlying cipher.

Inherited from org.bouncycastle.crypto.StreamBlockCipher:
getUnderlyingCipherprocessBytesreturnByte

Field Detail

blockSizeback to summary
private final int blockSize
bufback to summary
private byte[] buf
byteCountback to summary
private int byteCount
cipherback to summary
private final BlockCipher cipher

Hides org.bouncycastle.crypto.StreamBlockCipher.cipher.

CTRback to summary
private byte[] CTR
initializedback to summary
private boolean initialized
IVback to summary
private byte[] IV
sback to summary
private final int s

Constructor Detail

G3413CTRBlockCipherback to summary
public G3413CTRBlockCipher(BlockCipher cipher)

Basic constructor.

Parameters
cipher:BlockCipher

the block cipher to be used as the basis of the counter mode (must have a 64 bit block size).

G3413CTRBlockCipherback to summary
public G3413CTRBlockCipher(BlockCipher cipher, int bitBlockSize)

Basic constructor.

Parameters
cipher:BlockCipher

the block cipher to be used as the basis of the counter mode (must have a 64 bit block size).

bitBlockSize:int

basic unit (defined as s)

Method Detail

calculateByteback to summary
protected byte calculateByte(byte in)

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

generateBufback to summary
private byte[] generateBuf()
generateCRTback to summary
private void generateCRT()
getAlgorithmNameback to summary
public String getAlgorithmName()

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

return the algorithm name and mode.

Returns:String

the name of the underlying algorithm followed by "/GCTR" and the block size in bits

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

return the block size we are operating at (in bytes).

Returns:int

the block size we are operating at (in bytes).

initback to summary
public void init(boolean encrypting, CipherParameters params) throws IllegalArgumentException

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

Initialise the cipher and, possibly, the initialisation vector (IV). If an IV isn't passed as part of the parameter, the IV will be all zeros. An IV which is too short is handled in FIPS compliant fashion.

Parameters
encrypting: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.
initArraysback to summary
private void initArrays()
processBlockback to summary
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException

Implements org.bouncycastle.crypto.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.StreamCipher.reset, org.bouncycastle.crypto.BlockCipher.reset.

reset the feedback vector back to the IV and reset the underlying cipher.