cacophony: A library implementing the Noise protocol.

[ cryptography, library, public-domain ] [ Propose Tags ]
This version is deprecated.

This library implements the Noise protocol.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
llvmDisabled
Automatic Flags
NameDescriptionDefault
hlintEnabled
doctestEnabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 0.9.2, 0.10.0, 0.10.1 (info)
Change log changelog.md
Dependencies base (>=4.8 && <5), bytestring, cryptonite (>=0.13), free, lens, memory, mtl [details]
License LicenseRef-PublicDomain
Author John Galt
Maintainer jgalt@centromere.net
Category Cryptography
Home page https://github.com/centromere/cacophony
Bug tracker https://github.com/centromere/cacophony/issues
Source repo head: git clone https://github.com/centromere/cacophony.git
Uploaded by jgalt at 2016-02-22T08:46:52Z
Distributions LTSHaskell:0.10.1, Stackage:0.10.1
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 8043 total (47 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-02-22 [all 1 reports]

Readme for cacophony-0.5.0

[back to package description]

cacophony

Build Status Haskell

This library implements the Noise protocol.

Basic usage

  1. Define functions which will be called when protocol messages are to be read and written to the remote peer. The payloadIn and payloadOut functions are called when payloads are received and needed.

    writeMsg   :: ByteString -> IO ()
    readMsg    :: IO ByteString
    payloadIn  :: Plaintext -> IO ()
    payloadOut :: IO Plaintext
    -- If you don't need to use payloads, do the following:
    let hc = HandshakeCallbacks (writeMsg socket)
                                 (readMsg socket)
                                 (\_ -> return ())
                                 (return "")
    
  2. Create the handshake state: Select a handshake pattern to use. Patterns are defined in the Crypto.Noise.HandshakePatterns module. Ensure that you provide the keys which are required by the handshake pattern you choose. For example, the Noise_IK pattern requires that the initiator provides a local static key and a remote static key. Remote keys are communicated out-of-band.

    let hs = handshakeState $ HandshakeStateParams
       noiseIK
       ""
       -- ^ Prologue
       (Just "foo")
       -- ^ Pre-shared key
       (Just initStatic)
       -- ^ Local static key
       Nothing
       -- ^ Local ephemeral key
       (Just (snd respStatic))
       -- ^ Remote static key
       Nothing
       -- ^ Remote ephemeral key
       True
       -- ^ True if we are initiator
    
  3. Run the handshake:

    (encryptionCipherState, decryptionCipherState) <- runHandshake hs hc
    
  4. Send and receive transport messages:

    let (cipherText, encryptionCipherState') = encryptPayload "hello world" encryptionCipherState
    let (Plaintext pt, decryptionCipherState') = decryptPayload msg decryptionCipherState
    

    Ensure that you never re-use a cipher state with encryptPayload and decryptPayload.