hwormhole-0.2.0.1: magic-wormhole client

Safe HaskellNone
LanguageHaskell2010

Transit.Internal.Pipeline

Contents

Description

 
Synopsis

Documentation

sendPipeline :: MonadResource m => FilePath -> TransitEndpoint -> ConduitM a c m (Text, ()) Source #

Given the peer network socket and the file path to be sent, this Conduit pipeline reads the file, encrypts and send it over the network. A sha256 sum is calculated on the input before encryption to compare with the receiver's decrypted copy.

receivePipeline :: MonadResource m => FilePath -> Int -> TransitEndpoint -> ConduitM a c m (Text, ()) Source #

Receive the encrypted bytestream from a network socket, decrypt it and write it into a file, also calculating the sha256 sum of the decrypted output along the way.

for tests

assembleRecordC :: Monad m => ConduitT ByteString ByteString m () Source #

The decryption conduit computation would succeed only if a complete bytestream that represents an encrypted block of data is given to it. However, the upstream elements may chunk the data for which one may not have control of. The encrypted packet on the wire has a 4-byte length header, so we could first read it and assemble a complete encrypted block into downstream.

decryptC :: MonadIO m => Key -> ConduitT ByteString ByteString m () Source #

A conduit function to decrypt the incoming byte stream with the given key

encryptC :: MonadIO m => Key -> ConduitT ByteString ByteString m () Source #

A conduit function to encrypt the incoming byte stream with the given key