cryptonite-0.29: Cryptography Primitives sink
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilitystable
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

Crypto.Cipher.RC4

Description

Simple implementation of the RC4 stream cipher. http://en.wikipedia.org/wiki/RC4

Initial FFI implementation by Peter White peter@janrain.com

Reorganized and simplified to have an opaque context.

Synopsis

Documentation

initialize #

Arguments

:: ByteArrayAccess key 
=> key

The key

-> State

The RC4 context with the key mixed in

RC4 context initialization.

seed the context with an initial key. the key size need to be adequate otherwise security takes a hit.

combine #

Arguments

:: ByteArray ba 
=> State

rc4 context

-> ba

input

-> (State, ba)

new rc4 context, and the output

RC4 xor combination of the rc4 stream with an input

generate :: ByteArray ba => State -> Int -> (State, ba) #

generate the next len bytes of the rc4 stream without combining it to anything.

data State #

The encryption state for RC4

This type is an instance of ByteArrayAccess for debugging purpose. Internal layout is architecture dependent, may contain uninitialized data fragments, and change in future versions. The bytearray should not be used as input to cryptographic algorithms.

Instances

Instances details
NFData State # 
Instance details

Defined in Crypto.Cipher.RC4

Methods

rnf :: State -> () #

ByteArrayAccess State # 
Instance details

Defined in Crypto.Cipher.RC4

Methods

length :: State -> Int #

withByteArray :: State -> (Ptr p -> IO a) -> IO a #

copyByteArrayToPtr :: State -> Ptr p -> IO () #