hOpenPGP-3.5: 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 CipherError ByteString 

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

composeMessageWithSEIPDv2 :: SymmetricAlgorithm -> AEADAlgorithm -> Word8 -> Salt -> S2K -> Passphrase -> ByteString -> Maybe [Pkt] -> Either SEIPDv2Failure [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.

data NestedFlag Source #

Instances

Instances details
FromJSON NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

ToJSON NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Data NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NestedFlag -> c NestedFlag Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NestedFlag Source #

toConstr :: NestedFlag -> Constr Source #

dataTypeOf :: NestedFlag -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NestedFlag) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NestedFlag) Source #

gmapT :: (forall b. Data b => b -> b) -> NestedFlag -> NestedFlag Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NestedFlag -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NestedFlag -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> NestedFlag -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> NestedFlag -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> NestedFlag -> m NestedFlag Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NestedFlag -> m NestedFlag Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NestedFlag -> m NestedFlag Source #

Generic NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Associated Types

type Rep NestedFlag 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

type Rep NestedFlag = D1 ('MetaData "NestedFlag" "Codec.Encryption.OpenPGP.Types.Internal.Base" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'True) (C1 ('MetaCons "NestedFlag" 'PrefixI 'True) (S1 ('MetaSel ('Just "unNestedFlag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
Show NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Eq NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Ord NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Hashable NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Wrapped NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Associated Types

type Unwrapped NestedFlag 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

type Unwrapped NestedFlag = GUnwrapped (Rep NestedFlag)
Pretty NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

Methods

pretty :: NestedFlag -> Doc ann

prettyList :: [NestedFlag] -> Doc ann

type Rep NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

type Rep NestedFlag = D1 ('MetaData "NestedFlag" "Codec.Encryption.OpenPGP.Types.Internal.Base" "hOpenPGP-3.5-H4QBbxh6ZI1Fo0Apmu90CQ" 'True) (C1 ('MetaCons "NestedFlag" 'PrefixI 'True) (S1 ('MetaSel ('Just "unNestedFlag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool)))
type Unwrapped NestedFlag Source # 
Instance details

Defined in Codec.Encryption.OpenPGP.Types.Internal.Base

type Unwrapped NestedFlag = GUnwrapped (Rep NestedFlag)