commsec-0.1: Communications security description: A basic communications security package that provides confidentiallity, integrity and replay detection.

Safe HaskellNone

Network.CommSec

Contents

Description

CommSec, for communications security.

Synopsis

Types

data OutContext Source

A context useful for sending data.

Constructors

Out 

Fields

aesCtr :: !Word64
 
saltOut :: !Word32
 
outKey :: AESKey
 

data InContext Source

A context useful for receiving data.

Constructors

In 

Fields

base :: !Word64
 
mask :: !Word64
 
saltIn :: !Word32
 
inKey :: AESKey
 

Build contexts for use sending and receiving

newInContext :: ByteString -> InContextSource

Given at least 24 bytes of entropy, produce an in context that can communicate with an identically initialized out context.

newOutContext :: ByteString -> OutContextSource

Given at least 24 bytes of entropy, produce an out context that can communicate with an identically initialized in context.

recv :: InContext -> ByteString -> Either String (ByteString, InContext)Source

Use an InContext to decrypt a message, verifying the ICV and sequence number. Message format: [ctr, ct, padding, tag].

send :: OutContext -> ByteString -> (ByteString, OutContext)Source

Use an OutContext to protect a message for transport. Message format: [ctr, ct, padding, tag].