|
For the latest news and information visit The GNU Crypto project |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gnu.crypto.cipher.BaseCipher
A basic abstract class to facilitate implementing symmetric key block ciphers.
Field Summary | |
protected int |
currentBlockSize
The current block size, in bytes. |
protected java.lang.Object |
currentKey
The session key for this instance. |
protected int |
defaultBlockSize
The default block size, in bytes. |
protected int |
defaultKeySize
The default key size, in bytes. |
protected java.lang.Object |
lock
The instance lock. |
protected java.lang.String |
name
The canonical name prefix of the cipher. |
Fields inherited from interface gnu.crypto.cipher.IBlockCipher |
CIPHER_BLOCK_SIZE, KEY_MATERIAL |
Constructor Summary | |
protected |
BaseCipher(java.lang.String name,
int defaultBlockSize,
int defaultKeySize)
Trivial constructor for use by concrete subclasses. |
Method Summary | |
abstract java.lang.Object |
clone()
Returns a clone of this instance. |
int |
currentBlockSize()
Returns the currently set block size for this instance. |
void |
decryptBlock(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Decrypts exactly one block of ciphertext. |
int |
defaultBlockSize()
Returns the default value, in bytes, of the algorithm's block size. |
int |
defaultKeySize()
Returns the default value, in bytes, of the algorithm's key size. |
void |
encryptBlock(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Encrypts exactly one block of plaintext. |
void |
init(java.util.Map attributes)
Initialises the algorithm with designated attributes. |
java.lang.String |
name()
Returns the canonical name of this instance. |
void |
reset()
Resets the algorithm instance for re-initialisation and use with other characteristics. |
boolean |
selfTest()
A correctness test that consists of basic symmetric encryption / decryption test(s) for all supported block and key sizes, as well as one (1) variable key Known Answer Test (KAT). |
protected boolean |
testKat(byte[] kb,
byte[] ct)
|
Methods inherited from class java.lang.Object |
|
Methods inherited from interface gnu.crypto.cipher.IBlockCipher |
blockSizes, keySizes |
Methods inherited from interface gnu.crypto.cipher.IBlockCipherSpi |
blockSizes, decrypt, encrypt, keySizes, makeKey |
Field Detail |
protected java.lang.String name
protected int defaultBlockSize
protected int defaultKeySize
protected int currentBlockSize
protected transient java.lang.Object currentKey
protected java.lang.Object lock
Constructor Detail |
protected BaseCipher(java.lang.String name, int defaultBlockSize, int defaultKeySize)
Trivial constructor for use by concrete subclasses.
name
- the canonical name prefix of this instance.defaultBlockSize
- the default block size in bytes.defaultKeySize
- the default key size in bytes.Method Detail |
public abstract java.lang.Object clone()
IBlockCipher
Returns a clone of this instance.
clone
in interface IBlockCipher
clone
in class java.lang.Object
gnu.crypto.cipher.IBlockCipher
public java.lang.String name()
IBlockCipher
Returns the canonical name of this instance.
name
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
public int defaultBlockSize()
IBlockCipher
Returns the default value, in bytes, of the algorithm's block size.
defaultBlockSize
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
public int defaultKeySize()
IBlockCipher
Returns the default value, in bytes, of the algorithm's key size.
defaultKeySize
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
public void init(java.util.Map attributes) throws java.security.InvalidKeyException
IBlockCipher
Initialises the algorithm with designated attributes. Permissible names and values are described in the class documentation above.
init
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
attributes
- a set of name-value pairs that describes the desired
future behaviour of this instance.java.security.InvalidKeyException
- if the key data is invalid.java.lang.IllegalStateException
- if the instance is already initialised.IBlockCipher.KEY_MATERIAL
,
IBlockCipher.CIPHER_BLOCK_SIZE
public int currentBlockSize()
IBlockCipher
Returns the currently set block size for this instance.
currentBlockSize
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
java.lang.IllegalStateException
- if the instance is not initialised.public void reset()
IBlockCipher
Resets the algorithm instance for re-initialisation and use with other characteristics. This method always succeeds.
reset
in interface IBlockCipher
public void encryptBlock(byte[] in, int inOffset, byte[] out, int outOffset) throws java.lang.IllegalStateException
IBlockCipher
Encrypts exactly one block of plaintext.
encryptBlock
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
in
- the plaintext.inOffset
- index of in
from which to start considering
data.out
- the ciphertext.outOffset
- index of out
from which to store result.java.lang.IllegalStateException
- if the instance is not initialised.public void decryptBlock(byte[] in, int inOffset, byte[] out, int outOffset) throws java.lang.IllegalStateException
IBlockCipher
Decrypts exactly one block of ciphertext.
decryptBlock
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
in
- the plaintext.inOffset
- index of in
from which to start considering
data.out
- the ciphertext.outOffset
- index of out
from which to store result.java.lang.IllegalStateException
- if the instance is not initialised.public boolean selfTest()
IBlockCipher
A correctness test that consists of basic symmetric encryption / decryption test(s) for all supported block and key sizes, as well as one (1) variable key Known Answer Test (KAT).
selfTest
in interface IBlockCipher
gnu.crypto.cipher.IBlockCipher
true
if the implementation passes simple
correctness tests. Returns false
otherwise.protected boolean testKat(byte[] kb, byte[] ct)
|
For the latest news and information visit The GNU Crypto project |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |