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

pack-priv Class GOST28147Engine

extends Object
implements BlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.internal.BlockCipher
Imports
java.util.Hashtable, org.bouncycastle.crypto.internal.BlockCipher, .CipherParameters, .DataLengthException, .OutputLengthException, org.bouncycastle.crypto.internal.params.KeyParameter, org.bouncycastle.util.Arrays, .Strings

implementation of GOST 28147-89

Field Summary

Modifier and TypeField and Description
protected static final int
private static byte[]
private static byte[]
private static byte[]
private static byte[]
private static byte[]
private static byte[]
private static byte[]
private boolean
private byte[]
S

private static byte[]
private static Hashtable<K, V>
private int[]

Constructor Summary

AccessConstructor and Description
public
GOST28147Engine()

standard constructor.

Method Summary

Modifier and TypeMethod and Description
private static void
addSBox(String sBoxName, byte[] sBox)

private int
bytesToint(byte[] in, int inOff)

private int[]
generateWorkingKey(boolean forEncryption, byte[] userKey)

public String
getAlgorithmName()

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

Return the name of the algorithm the cipher implements.
public int
getBlockSize()

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

Return the block size for this cipher (in bytes).
public static byte[]

Returns:

byte array representing the S-Box
getSBox
(String
name of the S-Box
sBoxName
)

Return the S-Box associated with SBoxName

private int
GOST28147_mainStep(int n1, int key)

private void
GOST28147Func(int[] workingKey, byte[] in, int inOff, byte[] out, int outOff)

public void
init(boolean
whether or not we are for encryption.
forEncryption
,
CipherParameters
the parameters required to set up the cipher.
params
)

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

initialise an GOST28147 cipher.
private void
intTobytes(int num, byte[] out, int outOff)

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
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLOCK_SIZEback to summary
protected static final int BLOCK_SIZE
DSbox_Aback to summary
private static byte[] DSbox_A
DSbox_Testback to summary
private static byte[] DSbox_Test
ESbox_Aback to summary
private static byte[] ESbox_A
ESbox_Bback to summary
private static byte[] ESbox_B
ESbox_Cback to summary
private static byte[] ESbox_C
ESbox_Dback to summary
private static byte[] ESbox_D
ESbox_Testback to summary
private static byte[] ESbox_Test
forEncryptionback to summary
private boolean forEncryption
Sback to summary
private byte[] S
Sbox_Defaultback to summary
private static byte[] Sbox_Default
sBoxesback to summary
private static Hashtable<K, V> sBoxes
workingKeyback to summary
private int[] workingKey

Constructor Detail

GOST28147Engineback to summary
public GOST28147Engine()

standard constructor.

Method Detail

addSBoxback to summary
private static void addSBox(String sBoxName, byte[] sBox)
bytesTointback to summary
private int bytesToint(byte[] in, int inOff)
generateWorkingKeyback to summary
private int[] generateWorkingKey(boolean forEncryption, byte[] userKey)
getAlgorithmNameback to summary
public String getAlgorithmName()

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

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

getSBoxback to summary
public static byte[] getSBox(String sBoxName)

Return the S-Box associated with SBoxName

Parameters
sBoxName:String

name of the S-Box

Returns:byte[]

byte array representing the S-Box

GOST28147_mainStepback to summary
private int GOST28147_mainStep(int n1, int key)
GOST28147Funcback to summary
private void GOST28147Func(int[] workingKey, byte[] in, int inOff, byte[] out, int outOff)
initback to summary
public void init(boolean forEncryption, CipherParameters params)

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

initialise an GOST28147 cipher.

Parameters
forEncryption:boolean

whether or not we are for encryption.

params:CipherParameters

the parameters required to set up the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
intTobytesback to summary
private void intTobytes(int num, byte[] out, int outOff)
processBlockback to summary
public int processBlock(byte[] in, int inOff, byte[] out, int outOff)

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.

resetback to summary
public void reset()

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

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

Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).