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

Codec.Encryption.OpenPGP.Policy

Synopsis

Documentation

data SomeOpenPGPRFCW where Source #

Constructors

SomeOpenPGPRFCW :: forall (rfc :: OpenPGPRFC). OpenPGPRFCW rfc -> SomeOpenPGPRFCW 

type HashAlgoAllowedFor (rfc :: OpenPGPRFC) (h :: HashAlgorithm) = AssertHashAllowed (HashAlgoStatusFor rfc h) Source #

type HashAlgoVerifiableFor (rfc :: OpenPGPRFC) (h :: HashAlgorithm) = AssertHashVerifiable (HashAlgoStatusFor rfc h) Source #

data DecryptPolicy Source #

Per-message decrypt-side enforcement policy.

defaultDecryptPolicy applies RFC9580-strict rules: no unauthenticated (SED) ciphertext, modern symmetric algorithms only, and rejection of deprecated S2K specifiers in SKESK. Use lenientDecryptPolicy when interoperating with older RFC4880 or RFC2440 messages.

Constructors

DecryptPolicy 

Fields

  • decryptAllowSEDNoIntegrity :: Bool

    When False (RFC9580 default), receiving a Symmetrically Encrypted Data packet (SED, tag 9) is a hard error. RFC9580 §5.9 says implementations SHOULD reject unauthenticated ciphertext.

  • decryptAllowSEIPDv1 :: Bool

    When False, receiving a SEIPDv1 (MDC-protected) packet is rejected. Defaults to True for interoperability with RFC4880 senders.

  • decryptAllowedSymmetricAlgos :: Maybe [SymmetricAlgorithm]

    Allowed symmetric algorithms for session keys. Nothing means unrestricted. The RFC9580 default restricts to AES-128192256.

  • decryptAllowedAEADAlgos :: Maybe [AEADAlgorithm]

    Allowed AEAD algorithms for SEIPDv2 payloads. Nothing means unrestricted. The RFC9580 default allows EAX, OCB, and GCM.

  • decryptRejectDeprecatedSKESK :: Bool

    When True (RFC9580 default), reject SKESK packets that use Simple or Salted S2K specifiers (both deprecated since RFC9580).

  • decryptRejectTrailingData :: Bool

    When True (RFC9580 default), any packet received after the message-integrity boundary (MDC for SEIPDv1, final AEAD tag for SEIPDv2, or the outer encrypted-data packet for SED) is a hard error. RFC9580 §5.13.2 requires that implementations detect and reject data appended after the authenticated payload. Set to False only when interoperating with legacy implementations that emit trailing garbage (implies lenientDecryptPolicy).

  • decryptRejectESKVersionMismatch :: Bool

    When True (RFC9580 default), a payload with no version-aligned ESK is a hard error even when misaligned ESKs are present. This is a distinct concern from trailing-data rejection: a message could have correct framing yet still carry only v6 PKESKs before a SEIPDv1 payload (or only v4 SKESKs before a SEIPDv2 payload), which indicates a mis-assembled message rather than an integrity violation. Set to False only when salvaging malformed legacy messages.

defaultDecryptPolicy :: DecryptPolicy Source #

RFC9580-strict decrypt policy. Rejects unauthenticated SED ciphertext, restricts session-key symmetric algorithms to AES-128192256 and AEAD to EAXOCBGCM, and rejects SKESK packets carrying deprecated Simple or Salted S2K specifiers. SEIPDv1 (MDC-protected) is still accepted for interoperability with RFC4880 senders.

lenientDecryptPolicy :: DecryptPolicy Source #

Permissive decrypt policy for interoperability with RFC4880 and RFC2440 messages. No algorithm or integrity restrictions are applied.

Signature context validation (RFC9580/RFC4880)

isAllowedPrimaryKeySig :: SignaturePayload -> Bool Source #

RFC9580 §3.2: Primary key can only have KeyRevocationSig or SignatureDirectlyOnAKey

isAllowedSubkeySig :: SignaturePayload -> Bool Source #

RFC9580 §3.3: Subkey can only have SubkeyBindingSig or SubkeyRevocationSig

isAllowedUIDSig :: SignaturePayload -> Bool Source #

RFC9580 §3.4: User ID can only have various certification types or CertRevocationSig

Signature type validation helpers (for parser use)

isAllowedPrimaryKeySigType :: SigType -> Bool Source #

Test if a SigType is allowed on a primary key

isAllowedSubkeySigType :: SigType -> Bool Source #

Test if a SigType is allowed on a subkey

isAllowedUIDSigType :: SigType -> Bool Source #

Test if a SigType is allowed on a User ID