ciphersaber2-0.1.1.2: Implementation of CipherSaber2 RC4 cryptography.

Safe HaskellNone
LanguageHaskell2010

Data.CipherSaber2

Description

Implementation of the CipherSaber-2 RC4 encryption format. Also provides a raw RC4 keystream generator.

This work is licensed under the "MIT License". Please see the file LICENSE in the source distribution of this software for license terms.

Synopsis

Documentation

data ByteString :: *

A space-efficient representation of a Word8 vector, supporting many efficient operations.

A ByteString contains 8-bit bytes, or by using the operations from Data.ByteString.Char8 it can be interpreted as containing 8-bit characters.

rc4 :: Int -> Int -> ByteString -> ByteString Source

Generate an RC4 keystream. CipherSaber recommends a key of less than 54 bytes for best mixing. At most, the first 256 bytes of the key are even used.

This function takes a parameter for the number of times to repeat the key mixing loop ala CipherSaber-2. It should probably be set to at least 20.

This function takes a length of keystream to generate, which is un-Haskellike but hard to avoid given the strictness of STUArray. An alternative would be to pass the plaintext in and combine it here, but this interface was chosen as "simpler". Another choice would be to leave whole rc4 function in the ST monad, but that seemed obnoxious. The performance and usability implications of these choices need to be explored.

encrypt :: Int -> ByteString -> ByteString -> ByteString -> ByteString Source

CipherSaber requires using a 10-byte initial value (IV) to protect against keystream recovery. Given the key and IV, this code will turn a a sequence of plaintext message bytes into a sequence of ciphertext bytes.

decrypt :: Int -> ByteString -> ByteString -> ByteString Source

CipherSaber recovers the 10-byte IV from the start of the ciphertext. Given the key, this code will turn a sequence of ciphertext bytes into a sequence of plaintext bytes.

ivLength :: Int Source

Number of bytes of IV to use in CipherSaber encryption/decryption below. The standard CipherSaber IV size is 10 bytes.