hOpenPGP-3.0.1.1: native Haskell implementation of OpenPGP (RFC9580)
Safe HaskellNone
LanguageHaskell2010

Codec.Encryption.OpenPGP.Encrypt

Synopsis

Documentation

recipientCapabilitiesFromSubpacketPayloads :: SomePKPayload -> [SigSubPacketPayload] -> RecipientCapabilities Source #

Extract encrypt-relevant recipient capabilities from effective self-signature subpackets.

RFC 9580 preferred AEAD ciphersuites are currently carried through OtherSigSub type 39 and decoded into AEAD preferences here.

data RecipientEncryptionTarget Source #

Constructors

RecipientEncryptionTarget 

Fields

encryptForRecipients :: forall m (v :: SEIPDVersion). MonadRandom m => RecipientEncryptRequest v -> m (Either PKESKEncryptError RecipientEncryptResult) Source #

Encrypt for recipient targets with capability negotiation enabled.

By default this negotiates a common symmetric and (for SEIPDv2) AEAD algorithm from recipient capabilities when available. Explicit request overrides still take precedence.

encryptForRecipientsLegacy :: forall m (v :: SEIPDVersion). MonadRandom m => RecipientEncryptRequest v -> m (Either PKESKEncryptError RecipientEncryptResult) Source #

Encrypt for recipient targets without recipient capability negotiation.

This preserves legacy behavior by using policy defaults unless request overrides are provided.

encryptForRecipientsWithCapabilityNegotiation :: forall m (v :: SEIPDVersion). MonadRandom m => RecipientCapabilityNegotiationMode -> RecipientEncryptRequest v -> m (Either PKESKEncryptError RecipientEncryptResult) Source #

Encrypt for recipient targets with an explicit capability-negotiation mode.

When negotiation is on, symmetric and AEAD selection use the common intersection of recipient preferences constrained by the active policy. When off, policy defaults are used.

encodeOpenPGPSessionMaterial :: SymmetricAlgorithm -> SessionKey -> Either PKESKEncryptError ByteString Source #

Encode the RFC 9580 PKESK/SKESK session-key material: one-octet algorithm ID, raw session key, then 16-bit checksum.

generateSessionKeyMaterial :: MonadRandom m => SymmetricAlgorithm -> m (Either PKESKEncryptError PKESKSessionMaterial) Source #

Generate a fresh session key and return both raw and encoded forms.

buildPKESKv3PayloadForRecipient :: MonadRandom m => SomePKPayload -> PKESKV3SessionMaterial -> m (Either PKESKEncryptError PKESKPayload) Source #

Build a legacy PKESKv3 payload for v4/v3 RSA recipient interop.

buildPKESKv3PktForRecipient :: MonadRandom m => SomePKPayload -> PKESKV3SessionMaterial -> m (Either PKESKEncryptError Pkt) Source #

Build a legacy PKESKv3 packet for v4/v3 RSA recipient interop.

buildPKESKPayloadForRecipient :: MonadRandom m => PKESKVersionPolicy -> SomePKPayload -> PKESKSessionMaterial -> m (Either PKESKEncryptError PKESKPayload) Source #

Build a v6 PKESK payload for one recipient key according to the selected version policy.

buildPKESKPktForRecipient :: MonadRandom m => PKESKVersionPolicy -> SomePKPayload -> PKESKSessionMaterial -> m (Either PKESKEncryptError Pkt) Source #

Build a PKESK packet for one recipient key according to the selected version policy.

encryptSEIPDv1Payload Source #

Arguments

:: SymmetricAlgorithm 
-> IV 
-> SessionKey 
-> ByteString

inner packet block plaintext

-> Either String ByteString 

Encrypt a plaintext block with OpenPGP CFB + MDC to produce a SEIPDv1 ciphertext.

composeMessageWithSEIPDv2 :: SymmetricAlgorithm -> AEADAlgorithm -> Word8 -> Salt -> S2K -> ByteString -> ByteString -> Maybe [Pkt] -> Either String [Pkt] Source #

Compose a complete AEAD-encrypted message with optional literal data and signature. Returns a packet list (SKESK, SEIPD v2, optional signature) ready for serialization.

Example: composeMessageWithSEIPDv2 AES256 OCB 6 (Salt 32 bytes) (SimpleS2K SHA256) passphrase payload Nothing returns [SKESK v6, SEIPD v2, ciphertext]

If the signature is provided, it will be included in the encrypted payload.