com.digt.trusted.crypto.engines
Class GOST28147Engine

java.lang.Object
  extended by com.digt.trusted.crypto.engines.GOST28147Engine
All Implemented Interfaces:
BlockCipher

public class GOST28147Engine
extends java.lang.Object
implements BlockCipher

a class that provides a basic GOST28147 engine.


Constructor Summary
GOST28147Engine()
           
 
Method Summary
 void destroy()
           
protected  void finalize()
           
 java.lang.String getAlgorithmName()
          Return the name of the algorithm the cipher implements.
 int getBlockSize()
          Return the block size for this cipher (in bytes).
 java.lang.String getMode()
           
 void init(boolean forEncryption, CipherParameters params)
          Initialise the cipher.
 void init(boolean forEncryption, GOSTSessionKey seskey)
           
 void init(int i, java.security.Key key, java.security.AlgorithmParameters ap, java.security.SecureRandom sr)
           
 int processBlock(byte[] in, int inOff, byte[] out, int outOff)
          Process one block of input from the array in and write it to the out array.
 int processBlock(byte[] in, int inOff, int length, byte[] out, int outOff)
          Deprecated. Replaced by processBytes(byte[], int, int, byte[], int) since 2.0.
 int processBlocks(byte[] in, int inOff, byte[] out, int outOff, int blocks)
          Process the number of blocks of input from the array in and write it to the out array.
 void processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
          Process an array of bytes from in putting the result into out.
 void reset()
          Reset the cipher.
 void setMode(java.lang.String mode)
          Set mode chipher indirect
 void setMode(java.lang.String mode, byte[] IV)
          Set mode chipher with initial vector
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GOST28147Engine

public GOST28147Engine()
Method Detail

init

public void init(int i,
                 java.security.Key key,
                 java.security.AlgorithmParameters ap,
                 java.security.SecureRandom sr)
          throws java.security.InvalidKeyException,
                 java.security.InvalidAlgorithmParameterException
Throws:
java.security.InvalidKeyException
java.security.InvalidAlgorithmParameterException

init

public void init(boolean forEncryption,
                 CipherParameters params)
          throws java.lang.IllegalArgumentException
Initialise the cipher.

Specified by:
init in interface BlockCipher
Parameters:
forEncryption - if true the cipher is initialised for encryption, if false for decryption.
params - the key and other data required by the cipher.
Throws:
java.lang.IllegalArgumentException - if the params argument is inappropriate.

init

public void init(boolean forEncryption,
                 GOSTSessionKey seskey)
          throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

processBlock

public int processBlock(byte[] in,
                        int inOff,
                        byte[] out,
                        int outOff)
                 throws DataLengthException,
                        java.lang.IllegalStateException
Process one block of input from the array in and write it to the out array.

Specified by:
processBlock in interface BlockCipher
Parameters:
in - the array containing the input data.
inOff - offset into the in array the data starts at.
out - the array the output data will be copied into.
outOff - the offset into the out array the output will start at.
Returns:
the number of bytes processed and produced.
Throws:
DataLengthException - if there isn't enough data in in, or space in out.
java.lang.IllegalStateException - if the cipher isn't initialised.

processBlock

public int processBlock(byte[] in,
                        int inOff,
                        int length,
                        byte[] out,
                        int outOff)
                 throws DataLengthException,
                        java.lang.IllegalStateException
Deprecated. Replaced by processBytes(byte[], int, int, byte[], int) since 2.0.

Process an array of bytes, producing output if necessary.

Throws:
DataLengthException
java.lang.IllegalStateException

processBlocks

public int processBlocks(byte[] in,
                         int inOff,
                         byte[] out,
                         int outOff,
                         int blocks)
                  throws DataLengthException,
                         java.lang.IllegalStateException
Process the number of blocks of input from the array in and write it to the out array.

Specified by:
processBlocks in interface BlockCipher
Parameters:
in - the array containing the input data.
inOff - offset into the in array the data starts at.
out - the array the output data will be copied into.
outOff - the offset into the out array the output will start at.
blocks - the number of blocks to process.
Returns:
the number of bytes processed and produced.
Throws:
DataLengthException - if there isn't enough data in in, or space in out.
java.lang.IllegalStateException - if the cipher isn't initialised.
Since:
2.0

processBytes

public void processBytes(byte[] in,
                         int inOff,
                         int len,
                         byte[] out,
                         int outOff)
                  throws DataLengthException,
                         java.lang.IllegalStateException,
                         RuntimeCryptoException
Process an array of bytes from in putting the result into out.

Parameters:
in - the input byte array.
inOff - the offset into the in array where the data to be processed starts.
len - the number of bytes to be processed.
out - the output buffer the processed bytes go into.
outOff - the offset into the output byte array the processed data stars at.
Throws:
DataLengthException - if the output buffer is too small.
java.lang.IllegalStateException - if the cipher isn't initialised.
RuntimeCryptoException - on other crypto operation errors.
Since:
2.0

getAlgorithmName

public java.lang.String getAlgorithmName()
Return the name of the algorithm the cipher implements.

Specified by:
getAlgorithmName in interface BlockCipher
Returns:
the name of the algorithm the cipher implements.

setMode

public void setMode(java.lang.String mode)
Set mode chipher indirect


setMode

public void setMode(java.lang.String mode,
                    byte[] IV)
Set mode chipher with initial vector


getMode

public java.lang.String getMode()

getBlockSize

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

Specified by:
getBlockSize in interface BlockCipher
Returns:
the block size for this cipher in bytes.

reset

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

Specified by:
reset in interface BlockCipher

destroy

public void destroy()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable