Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- encrypt :: Key -> Nonce -> PlainText -> Either CryptoError CipherText
- decrypt :: Key -> CipherText -> Either CryptoError (PlainText, Nonce)
- newtype PlainText = PlainText ByteString
- newtype CipherText = CipherText ByteString
- deriveKeyFromPurpose :: Purpose -> Key -> ByteString
- data Purpose
- data CryptoError
- = BadNonce Text
- | CouldNotDecrypt Text
- | KeyGenError Text
Documentation
encrypt :: Key -> Nonce -> PlainText -> Either CryptoError CipherText Source #
encrypt the given chunk with the given secretbox key and nonce. Saltine's nonce seem represented as a big endian bytestring. However, to interop with the wormhole python client, we need to use and send nonce as a little endian bytestring.
decrypt :: Key -> CipherText -> Either CryptoError (PlainText, Nonce) Source #
decrypt the bytestring representing ciphertext block with the given key. It is assumed that the ciphertext bytestring is nonce followed by the actual encrypted data.
Type for representing unencrypted plain text
PlainText ByteString |
newtype CipherText Source #
Type for representing encrypted cipher text.
CipherText ByteString |
Instances
Eq CipherText Source # | |
Defined in Transit.Internal.Crypto (==) :: CipherText -> CipherText -> Bool (/=) :: CipherText -> CipherText -> Bool |
deriveKeyFromPurpose :: Purpose -> Key -> ByteString Source #
derive a new purpose-specific key from a master key.
Various purpose types for key derivation.
Normally used with deriveKeyFromPurpose
.
SenderHandshake | Purpose type to be used by transit sender. |
ReceiverHandshake | Purpose type to be used by transit receiver. |
SenderRecord | Purpose type to be used for encrypting records. |
ReceiverRecord | Purpose type to be used for decrypting records. |
RelayHandshake | Purpose type to be used for transit relay handshake. |
data CryptoError Source #
Error Type for exceptions thrown by the Crypto module
BadNonce Text | The nonce value in the received message is invalid. |
CouldNotDecrypt Text | We could not decrypt the incoming encrypted record. |
KeyGenError Text | Could not generate transit keys. |
Instances
Eq CryptoError Source # | |
Defined in Transit.Internal.Crypto (==) :: CryptoError -> CryptoError -> Bool (/=) :: CryptoError -> CryptoError -> Bool | |
Show CryptoError Source # | |
Defined in Transit.Internal.Crypto showsPrec :: Int -> CryptoError -> ShowS show :: CryptoError -> String showList :: [CryptoError] -> ShowS | |
Exception CryptoError Source # | |
Defined in Transit.Internal.Crypto toException :: CryptoError -> SomeException fromException :: SomeException -> Maybe CryptoError displayException :: CryptoError -> String |