de.flexiprovider.core.rc2
Class RC2
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.BlockCipher
|
+--de.flexiprovider.core.rc2.RC2
- Direct Known Subclasses:
- RC2.RC2_CBC
- public class RC2
- extends BlockCipher
This class implements the RC2 block-cipher algorithm according to RFC 2268.
RC2 was invented by Ronald Rivest for RSA Security in 1987. Further
information can be found at RSA Security
and in RFC 2268.
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 xxx.x MBits.
- Author:
- Oliver Seiler
|
Field Summary |
static java.lang.String |
ALG_NAME
The algorithm name. |
|
Constructor Summary |
RC2()
|
|
Method Summary |
int |
getCipherBlockSize()
This method returns the blocksize 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)
This method guarantees the AlgorithmParameterSpec compatibility. |
protected void |
initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec params)
This method guarantees the AlgorithmParameterSpec compatibility. |
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.
RC2
public RC2()
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 RC2Key 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()
- This method returns the blocksize the algorithm uses. This method will
normally be called by the padding scheme.
- Overrides:
getCipherBlockSize in class BlockCipher
- Returns:
- 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, 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