de.flexiprovider.core.rc5
Class RC5
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.BlockCipher
|
+--de.flexiprovider.core.rc5.RC5
- public class RC5
- extends BlockCipher
This class implements the RC5 block-cipher algorithm according to the RFC
2040. RC5 was invented by Ronald Rivest for RSA Security in 1994. Further
information can be found at RSA Security,
in RFC 2040 and in the Handbook of Applied Cryptography, Menezes, van
Oorschot, Vanstone, CRC Press, 1997, algorithm 7.115, 7.116 and 7.117.
The efficiency of this implementation has been tested on a AMD K6-III, 450
MHz, running Windows 2000 Prof., using jdk 1.2.2. The encryption/decryption
rate is about 8.9 MBits / second using wordSize 32, rounds 12, keySize 16.
- Author:
- Oliver Seiler
|
Field Summary |
static java.lang.String |
ALG_NAME
The algorithm name. |
|
Constructor Summary |
RC5()
|
|
Method Summary |
int |
getCipherBlockSize()
This method returns the block size, the algorithm uses. |
int |
getKeySize(Key key)
Returns the key size of the given key object. |
java.lang.String |
getName()
|
protected void |
initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec params)
Initialize the block cipher the given key for data decryption. |
protected void |
initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec params)
Initialize the block cipher with the given key for data encryption. |
protected void |
singleBlockDecrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
This method decrypts a single block of data, and may only be called, when
the block cipher is in decrytion mode. |
protected void |
singleBlockEncrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
This method encrypts a single block of data, and may only be called, when
the block cipher is in encrytion mode. |
| 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.
RC5
public RC5()
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 RC5Key or SecretKeySpec.
- 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()
throws java.lang.IllegalStateException
- This method returns the block size, the algorithm uses. This method will
usually be called by the padding scheme. Be sure not to call this before
initializing the cipher.
- Overrides:
getCipherBlockSize in class BlockCipher
- Returns:
- used block size in bytes
- Throws:
java.lang.IllegalStateException - if called before initializing the cipher.
initCipherEncrypt
protected void initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
- Initialize the block cipher with the given key for data encryption.
- Overrides:
initCipherEncrypt in class BlockCipher
- Parameters:
key - SecretKey to be used to encrypt dataparams - AlgorithmParamterSpec to be used with this algorithm- Throws:
InvalidKeyException - if the given key is illegal for this cipher.InvalidAlgorithmParameterException - if the given AlgorithmParameters are not appropriate for this
cipher.
initCipherDecrypt
protected void initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException,
InvalidAlgorithmParameterException
- Initialize the block cipher the given key for data decryption.
- Overrides:
initCipherDecrypt in class BlockCipher
- Parameters:
key - SecretKey to be used to decrypt dataparams - AlgorithmParamterSpec to be used with this algorithm- Throws:
InvalidKeyException - if the given key is illegal for this cipherInvalidAlgorithmParameterException - if the given AlgorithmParameters are not appropriate for this
cipher
singleBlockEncrypt
protected void singleBlockEncrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
- This method encrypts a single block of data, and may only be called, when
the block cipher is in encrytion mode. It has to be asured, too, that the
array in contains a whole block starting at inOffset
and that out is large enogh to hold an encrypted block starting
at outOffset
- Overrides:
singleBlockEncrypt in class BlockCipher
- Parameters:
in - byte[] containing the plaintext to be encrypted starting at
inOffsetinOffset - int index in the array in where the plaintext block startsout - byte[] which will contain the ciphertext startig at outOffsetoutOffset - int index in the 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, and may only be called, when
the block cipher is in decrytion mode. It has to be asured, too, that the
array in contains a whole block starting at inOffset
and that out is large enogh to hold an decrypted block starting
at outOffset
- Overrides:
singleBlockDecrypt in class BlockCipher
- Parameters:
in - byte[] containing the ciphertext to be decrypted starting at
inOffsetinOffset - int index in the array in where the ciphertext block startsout - byte[] which will contain the plaintext startig at outOffsetoutOffset - int index in the array out where the plaintext block will
start