package cryptokit

  1. Overview
  2. Docs

The Stream module provides classes that implement the ARCfour stream cipher, and the wrapping of a stream cipher as a general transform. The classes can be composed in a Lego-like fashion, facilitating the integration of new stream ciphers.

class type stream_cipher = object ... end

Abstract interface for a stream cipher.

Wraps an arbitrary stream cipher as a transform. The transform has input and output block size of 1.

class arcfour : string -> stream_cipher

The ARCfour (``alleged RC4'') stream cipher. The argument is the key, and must be of length 1 to 256. This stream cipher works by xor-ing the input with the output of a key-dependent pseudo random number generator. Thus, decryption is the same function as encryption.

class chacha20 : ?iv:string -> ?ctr:int64 -> string -> stream_cipher

The Chacha20 strea cipher. The string argument is the key, and must be of length 16 or 32. The optional iv argument is the initialization vector (also known as the nonce). If present, it must be 8 bytes long. If absent, it is taken to be eight zero bytes. The optional ctr argument is the initial value of the internal counter. If absent, it is taken to be 0. This stream cipher works by xor-ing the input with the output of a key-dependent pseudo random number generator. Thus, decryption is the same function as encryption.

OCaml

Innovation. Community. Security.