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

public Class G3413CFBBlockCipher

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

An implementation of the CFB mode for GOST 3412 2015 cipher. See GOST R 3413 2015

Field Summary

Modifier and TypeField and Description
private int
private int
private BlockCipher
private boolean
private byte[]
private byte[]
private boolean
private int
m

private byte[]
R

private byte[]
private final int
s

Constructor Summary

AccessConstructor and Description
public
G3413CFBBlockCipher(BlockCipher
base cipher
cipher
)

Base constructor.

public
G3413CFBBlockCipher(BlockCipher
base cipher
cipher
,
int
basic unit (defined as s)
bitBlockSize
)

Base constructor with specific block size.

Method Summary

Modifier and TypeMethod and Description
protected byte
pack-priv byte[]

Returns:

gamma
createGamma
()

creating gamma value

pack-priv void
generateR(byte[]
processed block
C
)

generate new R value

public String
public int
getBlockSize()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).
public void
init(boolean
ignored because encryption and decryption are same
forEncryption
,
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 initialisation vector R. If an IV isn't passed as part of the parameter, the IV will be all zeros.
private void
initArrays()

allocate memory for R and R_init arrays

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.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.

copy R_init into R and reset the underlying cipher.
private void
setupDefaultParams()

this method sets default values to s and m parameters: s = blockSize; m = 2 * blockSize

Inherited from org.bouncycastle.crypto.StreamBlockCipher:
getUnderlyingCipherprocessBytesreturnByte

Field Detail

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

Hides org.bouncycastle.crypto.StreamBlockCipher.cipher.

forEncryptionback to summary
private boolean forEncryption
gammaback to summary
private byte[] gamma
inBufback to summary
private byte[] inBuf
initializedback to summary
private boolean initialized
mback to summary
private int m
Rback to summary
private byte[] R
R_initback to summary
private byte[] R_init
sback to summary
private final int s

Constructor Detail

G3413CFBBlockCipherback to summary
public G3413CFBBlockCipher(BlockCipher cipher)

Base constructor.

Parameters
cipher:BlockCipher

base cipher

G3413CFBBlockCipherback to summary
public G3413CFBBlockCipher(BlockCipher cipher, int bitBlockSize)

Base constructor with specific block size.

Parameters
cipher:BlockCipher

base cipher

bitBlockSize:int

basic unit (defined as s)

Method Detail

calculateByteback to summary
protected byte calculateByte(byte in)

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

createGammaback to summary
pack-priv byte[] createGamma()

creating gamma value

Returns:byte[]

gamma

generateRback to summary
pack-priv void generateR(byte[] C)

generate new R value

Parameters
C:byte[]

processed block

getAlgorithmNameback to summary
public String getAlgorithmName()

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

Doc from org.bouncycastle.crypto.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.BlockCipher.getBlockSize.

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

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

Returns:int

the block size for this cipher in bytes.

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

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

Initialise the cipher and initialisation vector R. 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. R_init = IV, and R1 = R_init

Parameters
forEncryption:boolean

ignored because encryption and decryption are same

params:CipherParameters

the key and other data required by the cipher.

Exceptions
IllegalArgumentException:

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

if the params argument is inappropriate.

initArraysback to summary
private void initArrays()

allocate memory for R and R_init arrays

processBlockback to summary
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, IllegalStateException

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Doc from 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 input , 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.

copy R_init into R and reset the underlying cipher.

setupDefaultParamsback to summary
private void setupDefaultParams()

this method sets default values to s and m parameters:
s = blockSize;
m = 2 * blockSize