| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Crypto.Age.Conduit
Description
Streaming encryption and decryption of age files.
Synopsis
- data EncryptError
- data EncryptPayloadError = EncryptPayloadPlaintextPayloadChunkParseError !ParseError
- conduitEncrypt :: forall (m :: Type -> Type). MonadIO m => Recipients -> ConduitT ByteString ByteString (ExceptT EncryptError m) ()
- conduitEncryptEither :: forall (m :: Type -> Type). MonadIO m => Recipients -> ConduitT ByteString (Either EncryptError ByteString) m ()
- conduitEncryptEitherPure :: forall (m :: Type -> Type). Monad m => RecipientEncryptionParams -> FileKey -> PayloadKeyNonce -> ConduitT ByteString (Either EncryptError ByteString) m ()
- sinkEncrypt :: forall (m :: Type -> Type) o. MonadIO m => Recipients -> ConduitT ByteString o (ExceptT EncryptError m) ByteString
- sinkEncryptEither :: forall (m :: Type -> Type) o. MonadIO m => Recipients -> ConduitT ByteString o m (Either EncryptError ByteString)
- encryptPayloadChunk :: PayloadKey -> PayloadChunkCounter -> PlaintextPayloadChunk -> CiphertextPayloadChunk
- data RecipientEncryptionParams
- mkRecipientEncryptionParams :: Recipients -> IO RecipientEncryptionParams
- data DecryptError
- data DecryptPayloadError
- data DecryptPayloadChunkError
- conduitDecrypt :: forall (m :: Type -> Type). Monad m => NonEmpty Identity -> ConduitT ByteString ByteString (ExceptT DecryptError m) ()
- conduitDecryptEither :: forall (m :: Type -> Type). Monad m => NonEmpty Identity -> ConduitT ByteString (Either DecryptError ByteString) m ()
- sinkDecrypt :: forall (m :: Type -> Type) o. Monad m => NonEmpty Identity -> ConduitT ByteString o (ExceptT DecryptError m) ByteString
- sinkDecryptEither :: forall (m :: Type -> Type) o. Monad m => NonEmpty Identity -> ConduitT ByteString o m (Either DecryptError ByteString)
- decryptPayloadChunk :: PayloadKey -> PayloadChunkCounter -> CiphertextPayloadChunk -> Either DecryptPayloadChunkError PlaintextPayloadChunk
Encryption
data EncryptError Source #
Error encrypting an age file.
Constructors
| EncryptWrapX25519StanzaFileKeyError !WrapX25519StanzaFileKeyError | Error wrapping a file key in an X25519 recipient stanza. |
| EncryptEncryptPayloadError !EncryptPayloadError | Error encrypting an age file payload. |
Instances
| Show EncryptError Source # | |
Defined in Crypto.Age.Conduit Methods showsPrec :: Int -> EncryptError -> ShowS # show :: EncryptError -> String # showList :: [EncryptError] -> ShowS # | |
data EncryptPayloadError Source #
Error encrypting an age file payload.
Constructors
| EncryptPayloadPlaintextPayloadChunkParseError !ParseError | Error parsing a plaintext payload chunk. |
Instances
| Show EncryptPayloadError Source # | |
Defined in Crypto.Age.Conduit Methods showsPrec :: Int -> EncryptPayloadError -> ShowS # show :: EncryptPayloadError -> String # showList :: [EncryptPayloadError] -> ShowS # | |
conduitEncrypt :: forall (m :: Type -> Type). MonadIO m => Recipients -> ConduitT ByteString ByteString (ExceptT EncryptError m) () Source #
Stream and age encrypt a byte string.
Errors are returned after the pipeline is run. For a variant that includes
errors in the stream, see conduitEncryptEither.
conduitEncryptEither :: forall (m :: Type -> Type). MonadIO m => Recipients -> ConduitT ByteString (Either EncryptError ByteString) m () Source #
Stream and age encrypt a byte string.
Errors are returned in the stream. For a variant that only returns errors
after the pipeline is run, see conduitEncrypt.
conduitEncryptEitherPure Source #
Arguments
| :: forall (m :: Type -> Type). Monad m | |
| => RecipientEncryptionParams | Recipient-specific encryption parameters. It is recommended to construct this using |
| -> FileKey | Symmetric file key. It is recommended to generate this from the operating system's CSPRNG
using |
| -> PayloadKeyNonce | Payload key nonce. It is recommended to generate this from the operating system's CSPRNG
using |
| -> ConduitT ByteString (Either EncryptError ByteString) m () |
Pure variant of conduitEncryptEither.
For typical usage, please use conduitEncryptEither.
sinkEncrypt :: forall (m :: Type -> Type) o. MonadIO m => Recipients -> ConduitT ByteString o (ExceptT EncryptError m) ByteString Source #
Stream and age encrypt a byte string.
Errors are returned after the pipeline is run. For a variant that includes
errors in the stream, see sinkEncryptEither.
sinkEncryptEither :: forall (m :: Type -> Type) o. MonadIO m => Recipients -> ConduitT ByteString o m (Either EncryptError ByteString) Source #
Stream and age encrypt a byte string.
Errors are returned in the stream. For a variant that only returns errors
after the pipeline is run, see sinkEncrypt.
Buffered
Arguments
| :: PayloadKey | Payload key. |
| -> PayloadChunkCounter | Payload chunk counter (used in constructing the |
| -> PlaintextPayloadChunk | Payload chunk to be encrypted. |
| -> CiphertextPayloadChunk |
Encrypt a chunk of an age file payload.
Parameters
data RecipientEncryptionParams Source #
Recipient-specific encryption parameters.
Constructors
| RecipientEncryptionParamsScrypt !ScryptRecipient | |
| RecipientEncryptionParamsX25519 !(NonEmpty (X25519Recipient, X25519Identity)) |
Instances
| Show RecipientEncryptionParams Source # | |
Defined in Crypto.Age.Conduit Methods showsPrec :: Int -> RecipientEncryptionParams -> ShowS # show :: RecipientEncryptionParams -> String # showList :: [RecipientEncryptionParams] -> ShowS # | |
| Eq RecipientEncryptionParams Source # | |
Defined in Crypto.Age.Conduit Methods (==) :: RecipientEncryptionParams -> RecipientEncryptionParams -> Bool # (/=) :: RecipientEncryptionParams -> RecipientEncryptionParams -> Bool # | |
mkRecipientEncryptionParams :: Recipients -> IO RecipientEncryptionParams Source #
Construct RecipientEncryptionParams for the provided Recipients.
Decryption
data DecryptError Source #
Error decrypting an age file.
Constructors
| DecryptHeaderParseError !ParseError | Error parsing the file header. |
| DecryptScryptStanzaNotAloneError |
As noted in the
age specification,
no other stanzas can be specified in the header when there is an
|
| DecryptUnwrapStanzaError !UnwrapStanzaError | Error unwrapping a recipient stanza. |
| DecryptNoMatchingRecipientError | Error finding any recipient stanza which corresponds to any of the provided identities. |
| DecryptInvalidHeaderMacError | Invalid header MAC. |
| DecryptDecryptPayloadError !DecryptPayloadError | Error decrypting the file payload. |
Instances
| Show DecryptError Source # | |
Defined in Crypto.Age.Conduit Methods showsPrec :: Int -> DecryptError -> ShowS # show :: DecryptError -> String # showList :: [DecryptError] -> ShowS # | |
data DecryptPayloadError Source #
Error decrypting an age file payload.
Constructors
| DecryptPayloadKeyNonceParseError !ParseError | Error parsing the |
| DecryptPayloadNullPayloadError | Ciphertext payload is null (i.e. end of input was reached without consuming any ciphertext bytes). "Streaming decryption MUST signal an error if the end of file is reached without successfully decrypting a final chunk." See the age specification for more information. |
| DecryptPayloadCiphertextPayloadChunkParseError !ParseError | Error parsing a ciphertext payload chunk. |
| DecryptPayloadNonEmptyPayloadEmptyFinalChunk | Encountered an empty final ciphertext payload chunk for a non-empty payload. "The final chunk MAY be shorter than 64 KiB but MUST NOT be empty unless the whole payload is empty." See the age specification for more information. Note that "empty" here refers to the result of encrypting an empty
byte string with |
| DecryptPayloadDecryptPayloadChunkError !PayloadChunkCounter !DecryptPayloadChunkError | Error decrypting a payload chunk. |
Instances
| Show DecryptPayloadError Source # | |
Defined in Crypto.Age.Conduit Methods showsPrec :: Int -> DecryptPayloadError -> ShowS # show :: DecryptPayloadError -> String # showList :: [DecryptPayloadError] -> ShowS # | |
data DecryptPayloadChunkError Source #
Error decrypting an age file payload chunk.
Constructors
| DecryptPayloadChunkInvalidAuthenticationTagSizeError !Int | Invalid |
| DecryptPayloadChunkInvalidAuthenticationTagError | Invalid |
Fields
| |
Instances
| Show DecryptPayloadChunkError Source # | |
Defined in Crypto.Age.Conduit Methods showsPrec :: Int -> DecryptPayloadChunkError -> ShowS # show :: DecryptPayloadChunkError -> String # showList :: [DecryptPayloadChunkError] -> ShowS # | |
| Eq DecryptPayloadChunkError Source # | |
Defined in Crypto.Age.Conduit Methods (==) :: DecryptPayloadChunkError -> DecryptPayloadChunkError -> Bool # (/=) :: DecryptPayloadChunkError -> DecryptPayloadChunkError -> Bool # | |
conduitDecrypt :: forall (m :: Type -> Type). Monad m => NonEmpty Identity -> ConduitT ByteString ByteString (ExceptT DecryptError m) () Source #
Stream and decrypt an age file.
Errors are returned after the pipeline is run. For a variant that includes
errors in the stream, see conduitDecryptEither.
conduitDecryptEither :: forall (m :: Type -> Type). Monad m => NonEmpty Identity -> ConduitT ByteString (Either DecryptError ByteString) m () Source #
Stream and decrypt an age file.
Errors are returned in the stream. For a variant that only returns errors
after the pipeline is run, see conduitDecrypt.
sinkDecrypt :: forall (m :: Type -> Type) o. Monad m => NonEmpty Identity -> ConduitT ByteString o (ExceptT DecryptError m) ByteString Source #
Stream and decrypt an age file to a byte string.
Errors are returned after the pipeline is run. For a variant that includes
errors in the stream, see sinkDecryptEither.
sinkDecryptEither :: forall (m :: Type -> Type) o. Monad m => NonEmpty Identity -> ConduitT ByteString o m (Either DecryptError ByteString) Source #
Stream and decrypt an age file to a byte string.
Errors are returned in the stream. For a variant that only returns errors
after the pipeline is run, see sinkDecrypt.
Buffered
Arguments
| :: PayloadKey | Payload key. |
| -> PayloadChunkCounter | Payload chunk counter (used in constructing the |
| -> CiphertextPayloadChunk | Payload chunk to be decrypted. |
| -> Either DecryptPayloadChunkError PlaintextPayloadChunk |
Decrypt a chunk of an age file payload.