RC5 Encryption Algorithm
publication in RSA CryptoBytes, Spring of 1995.
https://www.rsasecurity.com/rsalabs/cryptobytes.
This implementation is set to work with a 64 bit word size.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private long[] | |
| private static final int | |
| private boolean | |
| private static final long | |
| private static final long | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private long | |
| private int | |
| private int | encryptBlock(byte[]
in byte buffer containing data to encrypt in, int offset into src buffer inOff, byte[] out buffer where encrypted data is written out, int offset into out buffer outOff)Encrypt the given block starting at the given offset and place the result in the provided buffer starting at the given offset. |
| public String | getAlgorithmName()
Implements org. Return the name of the algorithm the cipher implements. |
| public int | getBlockSize()
Implements org. Return the block size for this cipher (in bytes). |
| public void | init(boolean
whether or not we are for encryption. forEncryption, CipherParameters the parameters required to set up the cipher. params)Implements org. initialise a RC5-64 cipher. |
| public int | processBlock(byte[]
the array containing the input data. in, int offset into the in array the data starts at. inOff, byte[] the array the output data will be copied into. out, int the offset into the out array the output will start at. outOff)Implements org. Process one block of input from the array in and write it to the out array. |
| public void | |
| private long | rotateLeft(long
word to rotate x, long number of bits to rotate % wordSize y)Perform a left "spin" of the word. |
| private long | rotateRight(long
word to rotate x, long number of bits to rotate % wordSize y)Perform a right "spin" of the word. |
| private void | |
| private void |
| _noRounds | back to summary |
|---|---|
| private int _noRounds | |
| _S | back to summary |
|---|---|
| private long[] _S | |
| bytesPerWord | back to summary |
|---|---|
| private static final int bytesPerWord | |
| forEncryption | back to summary |
|---|---|
| private boolean forEncryption | |
| P64 | back to summary |
|---|---|
| private static final long P64 | |
| Q64 | back to summary |
|---|---|
| private static final long Q64 | |
| wordSize | back to summary |
|---|---|
| private static final int wordSize | |
| RC564Engine | back to summary |
|---|---|
| public RC564Engine() Create an instance of the RC5 encryption algorithm and set some defaults | |
| bytesToWord | back to summary |
|---|---|
| private long bytesToWord(byte[] src, int srcOff) | |
| decryptBlock | back to summary |
|---|---|
| private int decryptBlock(byte[] in, int inOff, byte[] out, int outOff) | |
| encryptBlock | back to summary |
|---|---|
| private int encryptBlock(byte[] in, int inOff, byte[] out, int outOff) Encrypt the given block starting at the given offset and place the result in the provided buffer starting at the given offset.
| |
| getAlgorithmName | back to summary |
|---|---|
| public String getAlgorithmName() Implements org. Doc from org. Return the name of the algorithm the cipher implements.
| |
| getBlockSize | back to summary |
|---|---|
| public int getBlockSize() Implements org. Doc from org. Return the block size for this cipher (in bytes).
| |
| init | back to summary |
|---|---|
| public void init(boolean forEncryption, CipherParameters params) Implements org. initialise a RC5-64 cipher.
| |
| processBlock | back to summary |
|---|---|
| public int processBlock(byte[] in, int inOff, byte[] out, int outOff) Implements org. Doc from org. Process one block of input from the array in and write it to the out array.
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one). | |
| rotateLeft | back to summary |
|---|---|
| private long rotateLeft(long x, long y) Perform a left "spin" of the word. The rotation of the given word x is rotated left by y bits. Only the lg(wordSize) low-order bits of y are used to determine the rotation amount. Here it is assumed that the wordsize used is a power of 2.
| |
| rotateRight | back to summary |
|---|---|
| private long rotateRight(long x, long y) Perform a right "spin" of the word. The rotation of the given word x is rotated left by y bits. Only the lg(wordSize) low-order bits of y are used to determine the rotation amount. Here it is assumed that the wordsize used is a power of 2.
| |
| setKey | back to summary |
|---|---|
| private void setKey(byte[] key) Re-key the cipher.
| |
| wordToBytes | back to summary |
|---|---|
| private void wordToBytes(long word, byte[] dst, int dstOff) | |