de.flexiprovider.core.saferplusplus
Class SAFERPlusPlus
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.BlockCipher
|
+--de.flexiprovider.core.saferplusplus.SAFERPlusPlus
- public class SAFERPlusPlus
- extends BlockCipher
This class implements the SAFER++ block cipher as specified in 'Nomination of
SAFER++ as Candidate Algorithm for the new European Schemes for Signatures,
Integrity and Encryption (NESSIE)' (26 September 2000)
SAFER++ is a cipher based on the existing SAFER family of ciphers. It
provides for a standard block size of 128 bits and allows user-selected-keys
to be either 128 or 256 bits long. The SAFER class of ciphers is are not
Feistel network based but they rather are transformation/substitution
ciphers. SAFER++ operates on a per byte basis. The most significant change to
the SAFER+ cipher is the replacement of the invertible 16x16 matrix being
previously used for diffusion by four 4x4 Pseudo-Hadamard- Transformation
matrices.
The legacy version of SAFER++ supporting a block size of 64 bits together
with 128 bit keys is currently not supported.
- Author:
- Ralf-Philipp Weinmann
|
Field Summary |
static java.lang.String |
ALG_NAME
The algorithm name. |
| Methods inherited from class de.flexiprovider.api.BlockCipher |
doFinal, doFinal, engineInit, getBlockSize, getIV, getOutputSize, getParameters, initDecrypt, initDecrypt, initDecrypt, initEncrypt, initEncrypt, initEncrypt, initEncrypt, setMode, setPadding, update, update |
| Methods inherited from class de.flexiprovider.api.Cipher |
doFinal, doFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, update |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ALG_NAME
public static final java.lang.String ALG_NAME
- The algorithm name.
SAFERPlusPlus
public SAFERPlusPlus()
- Default constructor
getName
public java.lang.String getName()
- Overrides:
getName in class Cipher
- Returns:
- the name of this cipher
getKeySize
public int getKeySize(Key key)
throws InvalidKeyException
- Returns the key size of the given key object. Checks whether the key
object is an instance of SAFERPlusPlusKey or
SecretKeySpec and whether the key size is within the specified
range for SAFER++. 128 and 256 bit keys are allowed.
- Overrides:
getKeySize in class Cipher
- Parameters:
key - the key object- Returns:
- the key size of the given key object.
- Throws:
InvalidKeyException - if key is invalid.
getCipherBlockSize
public int getCipherBlockSize()
- Return the blocksize the algorithm uses. It is usually called by the
padding scheme.
- Overrides:
getCipherBlockSize in class BlockCipher
- Returns:
- the used blocksize in bytes
initCipherEncrypt
protected void initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec paramSpec)
throws InvalidKeyException
- Dummy method to stay compatible with the API. the
AlgorithmParameterSpec argument is not actually used here.
- Overrides:
initCipherEncrypt in class BlockCipher
- Parameters:
key - - the SecretKey which has to be used to decrypt data.paramSpec - - algorithmParameterSpec, not used for here- Throws:
InvalidKeyException - if the given key is inappropriate for initialising this
cipher.
initCipherDecrypt
protected void initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- Dummy method to stay compatible with the API. the
AlgorithmParameterSpec argument is not actually used here.
- Overrides:
initCipherDecrypt in class BlockCipher
- Parameters:
key - - the SecretKey which has to be used to decrypt data.params - - algorithmParameterSpec, not used for here- Throws:
InvalidKeyException - if the given key is inappropriate for initialising this
cipher.
singleBlockEncrypt
protected void singleBlockEncrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
- This method encrypts a single block of data. The array in must
contain a whole block starting at inOffset and out must
be large enough to hold an encrypted block starting at outOffset
.
- Overrides:
singleBlockEncrypt in class BlockCipher
- Parameters:
in - array of bytes containing the plaintext to be encryptedinOffset - index in array in where the plaintext block startsout - array of bytes which will contain the ciphertext starting at
outOffsetoutOffset - index in array out where the ciphertext block will
start
singleBlockDecrypt
protected void singleBlockDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
- This method decrypts a single block of data. The array input
must contain a whole block starting at inOff and output
must be large enough to hold an encrypted block starting at
outOff.
- Overrides:
singleBlockDecrypt in class BlockCipher
- Parameters:
input - array of bytes containig the ciphertext to be decryptedinOff - index in array in where the ciphertext block startsoutput - array of bytes which will contain the plaintext starting at
outOffsetoutOff - index in array out where the plaintext block will
start