raaz-0.3.2: Fast and type safe cryptography.
Copyright(c) Piyush P Kurur 2019
LicenseApache-2.0 OR BSD-3-Clause
MaintainerPiyush P Kurur <ppk@iitpkd.ac.in>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Raaz.Primitive.Poly1305.Internal

Description

 
Synopsis

The Poly1305 MAC

This module exposes the types required to implement the the poly1305 message authenticator. The poly1305 is a function that takes two parameters r and s and for an input message m computes the function.

Poly1305(m, r,s) = (M(r) mod 2^130 - 5) + s mod 2^128

In the original publication, r is selected pseudo-randomly and s is generated by encrypting (using AES) a nonce n with a secret key k, i.e. r = random; s = AES(k,n). The secret that needs to be shared by the two parties is r and the key k. Actual protocols should never repeat the nonce n for otherwise there will be compromise in the security. The RFC7539 uses a variant that uses the chacha20 cipher instead of AES.

As can be seen from the above discussion the actual mechanism for selecting the r and s differs depending on the situation. Hence, this module only provide the "raw" Poly1305 implementation leaving out the details of the selection of r and s for some latter stage. Thus this module is not of direct use but is used by actual protocols to implement message authentication.

newtype Poly1305 Source #

The datatype that captures the Poly1305 authenticator tag.

Constructors

Poly1305 WORD 

Instances

Instances details
Eq Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Show Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

IsString Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Storable Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Equality Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

eq :: Poly1305 -> Poly1305 -> Result Source #

EndianStore Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Encodable Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Primitive Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Associated Types

type WordType Poly1305 Source #

type WordsPerBlock Poly1305 :: Nat Source #

Show (Key Poly1305) Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

data Key Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

data Key Poly1305 = Key R S
type WordType Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

type WordsPerBlock Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

newtype R Source #

The r component of the secret.

Constructors

R WORD 

Instances

Instances details
Eq R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

(==) :: R -> R -> Bool #

(/=) :: R -> R -> Bool #

Show R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

showsPrec :: Int -> R -> ShowS #

show :: R -> String #

showList :: [R] -> ShowS #

IsString R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

fromString :: String -> R #

Storable R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

sizeOf :: R -> Int #

alignment :: R -> Int #

peekElemOff :: Ptr R -> Int -> IO R #

pokeElemOff :: Ptr R -> Int -> R -> IO () #

peekByteOff :: Ptr b -> Int -> IO R #

pokeByteOff :: Ptr b -> Int -> R -> IO () #

peek :: Ptr R -> IO R #

poke :: Ptr R -> R -> IO () #

Equality R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

eq :: R -> R -> Result Source #

EndianStore R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

store :: Ptr R -> R -> IO () Source #

load :: Ptr R -> IO R Source #

adjustEndian :: Ptr R -> Int -> IO () Source #

Encodable R Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

newtype S Source #

The s component of the secret.

Constructors

S WORD 

Instances

Instances details
Eq S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

(==) :: S -> S -> Bool #

(/=) :: S -> S -> Bool #

Show S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

showsPrec :: Int -> S -> ShowS #

show :: S -> String #

showList :: [S] -> ShowS #

IsString S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

fromString :: String -> S #

Storable S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

sizeOf :: S -> Int #

alignment :: S -> Int #

peekElemOff :: Ptr S -> Int -> IO S #

pokeElemOff :: Ptr S -> Int -> S -> IO () #

peekByteOff :: Ptr b -> Int -> IO S #

pokeByteOff :: Ptr b -> Int -> S -> IO () #

peek :: Ptr S -> IO S #

poke :: Ptr S -> S -> IO () #

Equality S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

eq :: S -> S -> Result Source #

EndianStore S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

Methods

store :: Ptr S -> S -> IO () Source #

load :: Ptr S -> IO S Source #

adjustEndian :: Ptr S -> Int -> IO () Source #

Encodable S Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

type WORD = Tuple 2 (LE Word64) Source #

A Poly1305 word is a 128-bit numbers in little-endian.

data family Key p :: Type Source #

The type family that captures the key of a keyed primitive.

Instances

Instances details
Initialisable ChaCha20Mem (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Eq (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Show (Key XChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Show (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Show (Key (Keyed prim)) Source # 
Instance details

Defined in Raaz.Primitive.Keyed.Internal

Methods

showsPrec :: Int -> Key (Keyed prim) -> ShowS #

show :: Key (Keyed prim) -> String #

showList :: [Key (Keyed prim)] -> ShowS #

Show (Key Poly1305) Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

IsString (Key XChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

IsString (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

IsString (Key (Keyed prim)) Source # 
Instance details

Defined in Raaz.Primitive.Keyed.Internal

Methods

fromString :: String -> Key (Keyed prim) #

Storable (Key XChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Storable (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Equality (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

EndianStore (Key XChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

EndianStore (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Encodable (Key XChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Encodable (Key ChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

Encodable (Key (Keyed prim)) Source # 
Instance details

Defined in Raaz.Primitive.Keyed.Internal

Initialisable (MemoryCell (Key ChaCha20)) (Key XChaCha20) Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

newtype Key XChaCha20 Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

newtype Key XChaCha20 = XKey KEY
newtype Key ChaCha20 Source # 
Instance details

Defined in Raaz.Primitive.ChaCha20.Internal

newtype Key ChaCha20 = Key KEY
data Key Poly1305 Source # 
Instance details

Defined in Raaz.Primitive.Poly1305.Internal

data Key Poly1305 = Key R S
newtype Key (Keyed prim) Source # 
Instance details

Defined in Raaz.Primitive.Keyed.Internal

newtype Key (Keyed prim) = Key ByteString