age-0.0.1.0: Actually Good Encryption
Safe HaskellNone
LanguageHaskell2010

Crypto.Age.Conduit

Description

Streaming encryption and decryption of age files.

Synopsis

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

Instances details
Show EncryptError Source # 
Instance details

Defined in Crypto.Age.Conduit

data EncryptPayloadError Source #

Error encrypting an age file payload.

Constructors

EncryptPayloadPlaintextPayloadChunkParseError !ParseError

Error parsing a plaintext payload chunk.

Instances

Instances details
Show EncryptPayloadError Source # 
Instance details

Defined in Crypto.Age.Conduit

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 mkRecipientEncryptionParams.

-> FileKey

Symmetric file key.

It is recommended to generate this from the operating system's CSPRNG using generateFileKey.

-> PayloadKeyNonce

Payload key nonce.

It is recommended to generate this from the operating system's CSPRNG using generatePayloadKeyNonce.

-> 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

encryptPayloadChunk Source #

Arguments

:: PayloadKey

Payload key.

-> PayloadChunkCounter

Payload chunk counter (used in constructing the ChaCha20-Poly1305 nonce).

-> PlaintextPayloadChunk

Payload chunk to be encrypted.

-> CiphertextPayloadChunk 

Encrypt a chunk of an age file payload.

Parameters

Decryption

data DecryptError Source #

Error decrypting an age file.

Constructors

DecryptHeaderParseError !ParseError

Error parsing the file header.

DecryptScryptStanzaNotAloneError

scrypt recipient stanza is not the only stanza in the file header.

As noted in the age specification, no other stanzas can be specified in the header when there is an scrypt stanza. This is to uphold an expectation of authentication that is implicit in password-based encryption.

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.

Fields

DecryptDecryptPayloadError !DecryptPayloadError

Error decrypting the file payload.

Instances

Instances details
Show DecryptError Source # 
Instance details

Defined in Crypto.Age.Conduit

data DecryptPayloadError Source #

Error decrypting an age file payload.

Constructors

DecryptPayloadKeyNonceParseError !ParseError

Error parsing the PayloadKeyNonce.

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 ChaCha20-Poly1305. Meaning that this final chunk only consists of a 16-byte Poly1305 authentication tag, but no ChaCha20 ciphertext.

DecryptPayloadDecryptPayloadChunkError !PayloadChunkCounter !DecryptPayloadChunkError

Error decrypting a payload chunk.

Instances

Instances details
Show DecryptPayloadError Source # 
Instance details

Defined in Crypto.Age.Conduit

data DecryptPayloadChunkError Source #

Error decrypting an age file payload chunk.

Constructors

DecryptPayloadChunkInvalidAuthenticationTagSizeError !Int

Invalid Poly1305 authentication tag size.

DecryptPayloadChunkInvalidAuthenticationTagError

Invalid Poly1305 authentication tag.

Fields

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

decryptPayloadChunk Source #

Arguments

:: PayloadKey

Payload key.

-> PayloadChunkCounter

Payload chunk counter (used in constructing the ChaCha20-Poly1305 nonce).

-> CiphertextPayloadChunk

Payload chunk to be decrypted.

-> Either DecryptPayloadChunkError PlaintextPayloadChunk 

Decrypt a chunk of an age file payload.