de.flexiprovider.core.mars
Class MARS
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.BlockCipher
|
+--de.flexiprovider.core.mars.MARS
- public class MARS
- extends BlockCipher
MARSBlockCipher implements the MARS Cipher. For more information see:
http://csrc.nist.gov/encryption/aes/round2/AESAlgs/MARS/mars.pdf For more
information about this implementation see: Thesis 'Implementierung von
symmetrischen Verschluesselungsverfahren' by Katja Rauch MARS uses a
blocksize of 16 bytes. The key length can be 16, 24, 32, 40, 48 or 56 bytes.
Encryption/decryption takes 32 rounds. Performance tests on an Intel Pentium
Celeron processor with 400 MHz, 64 MB main storage and Windows 98 running on
it, achieved an encryption/decryption time of approximately 28,5 Mbit/s.
- Author:
- Katja Rauch
|
Field Summary |
static java.lang.String |
ALG_NAME
The algorithm name. |
|
Constructor Summary |
MARS()
|
| 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.
MARS
public MARS()
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 MARSKey or SecretKeySpec and
whether the key size is within the specified range for MARS. Any key size
between 128 and 448 bits that is divisible by 8 is fine.
- 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()
- This method returns the blocksize the algorithm uses. It will be called
by the padding scheme.
- Overrides:
getCipherBlockSize in class BlockCipher
- Returns:
- the used blocksize in bytes
initCipherEncrypt
protected void initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- This method guarantees the AlgorithmParameterSpec compatibility. As these
are not used here it just calls the origin InitDecrypt method.
- Overrides:
initCipherEncrypt 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.
initCipherDecrypt
protected void initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- This method guarantees the AlgorithmParameterSpec compatibility. As these
are not used here it just calls the origin InitDecrypt method.
- 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[] in,
int inoffset,
byte[] out,
int outoffset)
- This method decrypts 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:
singleBlockDecrypt in class BlockCipher
- Parameters:
in - array of bytes containig the ciphertext to be decryptedinoffset - index in array in, where the ciphertext block startsout - array of bytes which will contain the plaintext starting at
outOffsetoutoffset - index in array out, where the plaintext block will start