org.clazzes.optional.sec
Interface BlockCipher

All Known Subinterfaces:
AEADBlockCipher
All Known Implementing Classes:
AESCipher, CBCCipher, GCMCipher

public interface BlockCipher

An interface, which encapsulates symmetric ciphers like 3-DES or AES.


Method Summary
 java.lang.String getAlgorithmName()
          Return the name of the algorithm the cipher implements.
 int getBlockSize()
           
 BlockCipher getUnderlyingCipher()
          return the underlying block cipher that we are wrapping or null, if we do wrap another cipher.
 void init(byte[] key, boolean forEncryption)
          Initialize the block cipher.
 int processBlock(byte[] in, int in_off, byte[] out, int out_off)
          Proceed the next block of getBlockSize() bytes from the input.
 void reset()
          Reset this cipher to state of the last call to #init(byte[], byte[], boolean).
 

Method Detail

getAlgorithmName

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

Returns:
the name of the algorithm the cipher implements.

getBlockSize

int getBlockSize()
Returns:
The block size used for the processBlock(byte[], int, byte[], int) operation.

init

void init(byte[] key,
          boolean forEncryption)
Initialize the block cipher.

Parameters:
key - The key for basic ciphers or initialization vector for cipher modes or null, if no key or initialization vector is needed.
forEncryption - Whether we want to encrypt. false means to set up this cipher for decryption.

processBlock

int processBlock(byte[] in,
                 int in_off,
                 byte[] out,
                 int out_off)
Proceed the next block of getBlockSize() bytes from the input.

Parameters:
in - The buffer where the input is stored. getBlockSize() bytes starting with in_off will be consumed.
in_off - The offset at which the input data starts.
out - The buffer where the output is stored. getBlockSize() bytes starting with out_off will be written.
out_off - The offset at which the output will be stored.
Returns:
The block size aka the number of bytes written.

reset

void reset()
Reset this cipher to state of the last call to #init(byte[], byte[], boolean).


getUnderlyingCipher

BlockCipher getUnderlyingCipher()
return the underlying block cipher that we are wrapping or null, if we do wrap another cipher.

Returns:
the underlying block cipher that we are wrapping.


Copyright © 2010. All Rights Reserved.