au.net.aba.crypto.provider
Class RC5

java.lang.Object
  |
  +--javax.crypto.CipherSpi
        |
        +--au.net.aba.crypto.provider.BlockCipher
              |
              +--au.net.aba.crypto.provider.RC5

public class RC5
extends BlockCipher

The specification for RC5 came from the RC5 Encryption Algorithm publication in RSA CryptoBytes, Spring of 1995. http://www.rsasecurity.com/rsalabs/cryptobytes.

The current implementation is set up to work by default with a 32-bit word size and 12 rounds.


Fields inherited from class au.net.aba.crypto.provider.BlockCipher
BLOCK_SIZE, buffer, bufferPos, CBC, cbcNextV, cbcV, ECB, firstBlock, ident, ivec, ivEncrypted, ivInline, key, mode, paddedStream, random, streamMode
 
Fields inherited from class javax.crypto.CipherSpi
ident
 
Constructor Summary
RC5()
          Create an instance of the RC5 encryption algorithm and set some defaults
 
Method Summary
protected  int decryptBlock(byte[] src, int srcIdx, int length, byte[] dst, int dstIdx)
          Decrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset.
protected  int encryptBlock(byte[] src, int srcIdx, int length, byte[] dst, int dstIdx)
          Encrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset.
protected  void engineInit(int opmode, java.security.Key key, java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
          Initialises this cipher with a key, a set of algorithm parameters, and a source of randomness.
protected  void setKey(java.security.Key inKey)
          Re-key the cipher.
 
Methods inherited from class au.net.aba.crypto.provider.BlockCipher
engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RC5

public RC5()
Create an instance of the RC5 encryption algorithm and set some defaults
Method Detail

engineInit

protected void engineInit(int opmode,
                          java.security.Key key,
                          java.security.spec.AlgorithmParameterSpec params,
                          java.security.SecureRandom random)
                   throws java.security.InvalidKeyException,
                          java.security.InvalidAlgorithmParameterException
Initialises this cipher with a key, a set of algorithm parameters, and a source of randomness.

We overwrite the parent routine so we can extract the parameters.

Overrides:
engineInit in class BlockCipher
Parameters:
opmode - the operation mode of this cipher (this is either ENCRYPT_MODE or DECRYPT_MODE)
key - the encryption key
params - the algorithm parameters
random - the source of randomness
Throws:
java.security.InvalidKeyException - if the given key is inappropriate for initialising this cipher
java.security.InvalidAlgorithmParameterException - if the given algorithm parameters are inappropriate for this cipher, or if this cipher is being initialised fro decryption and requires algorithm parameters and params is null

setKey

protected void setKey(java.security.Key inKey)
               throws java.security.InvalidKeyException
Re-key the cipher.

Overrides:
setKey in class BlockCipher
Parameters:
inKey - the key to be used
Throws:
java.security.InvalidKeyException - if the key given is not of this type

encryptBlock

protected int encryptBlock(byte[] src,
                           int srcIdx,
                           int length,
                           byte[] dst,
                           int dstIdx)
                    throws IllegalBlockSizeException
Encrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset. The input will be an exact multiple of our block size (in ABA, this is defined as 8 in BlockCipher).

Overrides:
encryptBlock in class BlockCipher
Parameters:
src - src byte buffer containing data to encrypt
srcIdx - offset into src buffer
len - length of data to encrypt
dst - dst buffer where encrypted data is written
dstIdx - offset into dst buffer

decryptBlock

protected int decryptBlock(byte[] src,
                           int srcIdx,
                           int length,
                           byte[] dst,
                           int dstIdx)
                    throws BadPaddingException
Decrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset. The input will be an exact multiple of our block size (in ABA, this is defined as 8 in BlockCipher).

Overrides:
decryptBlock in class BlockCipher
Parameters:
src - src byte buffer containing data to encrypt
srcIdx - offset into src buffer
len - length of data to encrypt
dst - dst buffer where encrypted data is written
dstIdx - offset into dst buffer