cipher-rc5-0.1.0.1: Pure RC5 implementation

PortabilityGood
Stabilitystable
MaintainerFinn Espen Gundersen <finn@gundersen.net>
Safe HaskellSafe-Inferred

Crypto.Cipher.RC5

Description

Pure implementation of the RC5 variable size block cipher. http://en.wikipedia.org/wiki/RC5

You need to select a block size and number of rounds. If you are unsure, the most common settings are 32bit blocks with 12 rounds.

This implementation supports all the standard block lengths of 32, 64 & 128 bits. It also includes support for non-standard (not recommended) 16bit blocks.

In addition to being useful when required for e.g. legacy integration, this cipher's option of short block lengths makes it useful for encrypting small data such as database primary keys before display.

Introduced in 1994, RC5 has withstood the tests of time remarkably well.

Synopsis

Documentation

encryptSource

Arguments

:: Int

Blocksize in bits (16, 32, 64 or 128)

-> Int

Number of rounds (0 - 256)

-> [Word8]

Key (max length 256)

-> [Word8]

Plaintext

-> [Word8]

Ciphertext

RC5 Cipher

Using the given blocksize, number of rounds and key, encrypts the plaintext.

  • Valid blocksizes are 16 (not standard), 32, 64, 128
  • Valid rounds are 0 - 256

If in doubt, 64bit blocks and 12 rounds is the most common combination. This is called RC5-32/12 (32 is the word size, which is half the block size). 128bit blocks and 18 rounds is also quite common. This is called RC5-64/18

encrypt 64 12 [1,2,3,4] [0xFE,0x13,0x37,0x00]

Encrypts the plaintext [0xFE,0x13,0x37,0x00] with a blocksize of 64 bits, 12 rounds and key [1,2,3,4]

Maximum key length is 256. A common (and sufficient) length is 16 bytes. The length of the result is divisible by the block size (i.e. 2, 4, 8, 16) On invalid input, the empty list is returned.

decryptSource

Arguments

:: Int

Blocksize in bits

-> Int

Number of rounds

-> [Word8]

Key

-> [Word8]

Ciphertext

-> [Word8]

Recovered plaintext

RC5 decryption

All parameters must match those used for encryption The length of the result is equal to the length of the input