Crypto-4.2.5.1: Collects together existing Haskell cryptographic functions into a package

Copyright | (c) Dominic Steinitz 2003
License | BSD-style (see the file ReadMe.tex)
Maintainer | dominic.steinitz@blueyonder.co.uk
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Codec.Utils

Contents

- Types and Constants
- Octet Conversion Functions

Description

Utilities for coding and decoding.

Synopsis

- type Octet = Word8
- msb :: Int
- fromTwosComp :: Integral a => [Octet] -> a
- toTwosComp :: Integral a => a -> [Octet]
- toOctets :: (Integral a, Integral b) => a -> b -> [Octet]
- fromOctets :: (Integral a, Integral b) => a -> [Octet] -> b
- listFromOctets :: (Integral a, Bits a) => [Octet] -> [a]
- listToOctets :: (Bits a, Integral a) => [a] -> [Octet]
- i2osp :: Integral a => Int -> a -> [Octet]

# Types and Constants

type Octet = Word8 Source #

The basic type for encoding and decoding.

msb :: Int Source #

The most significant bit of an `Octet`.

# Octet Conversion Functions

fromTwosComp :: Integral a => [Octet] -> a Source #

Convert from twos complement.

toTwosComp :: Integral a => a -> [Octet] Source #

toOctets :: (Integral a, Integral b) => a -> b -> [Octet] Source #

Take a number a convert it to base n as a list of octets.

fromOctets :: (Integral a, Integral b) => a -> [Octet] -> b Source #

Take a list of octets (a number expressed in base n) and convert it to a number.

listFromOctets :: (Integral a, Bits a) => [Octet] -> [a] Source #

See `listToOctets`.

listToOctets :: (Bits a, Integral a) => [a] -> [Octet] Source #

Converts a list of numbers into a list of octets. The resultant list has nulls trimmed from the end to make this the dual of listFromOctets (except when the original octet list ended with nulls; see `trimNulls`).

i2osp :: Integral a => Int -> a -> [Octet] Source #

Take the length of the required number of octets and convert the number to base 256 padding it out to the required length. If the required length is less than the number of octets of the converted number then return the converted number. NB this is different from the standard ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf but mimics how replicate behaves.