| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Codec.Encryption.OpenPGP.Subpackets
Synopsis
- data SafeSubpacket
- mkSafeSubpacket :: Bool -> SigSubPacketPayload -> Either String SafeSubpacket
- safePayload :: SafeSubpacket -> SigSubPacketPayload
- safeSubpacket :: SafeSubpacket -> SigSubPacket
- data CriticalSubpacket
- mkCritical :: SigSubPacketPayload -> Either String CriticalSubpacket
- canBeCritical :: SigSubPacketPayload -> Bool
- data TextNormalizationMode
- data SigBuilder hashedness v (algo :: PubKeyAlgorithm)
- data LegalSubpacket h v where
- legalSubpacket :: LegalSubpacket h v -> SigSubPacket
- singleLegalSub :: LegalSubpacket h v -> SubpacketList h v
- consLegalSub :: LegalSubpacket h v -> SubpacketList h v -> SubpacketList h v
- listToLegalSubs :: [LegalSubpacket h v] -> SubpacketList h v
- sbSigType :: SigBuilder hashedness v algo -> SigType
- sbPubKeyAlgo :: forall hashedness v (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigBuilder hashedness v algo -> PubKeyAlgorithm
- sbHashAlgo :: SigBuilder hashedness v algo -> HashAlgorithm
- sbHashedSubs :: SigBuilder hashedness v algo -> [SigSubPacket]
- sbUnhashedSubs :: SigBuilder hashedness v algo -> [SigSubPacket]
- sbSalt :: SigBuilder hashedness v algo -> BuilderSalt v
- sbTextNormMode :: SigBuilder hashedness v algo -> TextNormalizationMode
- buildSigV4 :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigBuilder Unhashed V4Sig algo -> Word16 -> NonEmpty MPI -> SignaturePayload
- buildSigV6 :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigBuilder Unhashed V6Sig algo -> Word16 -> NonEmpty MPI -> SignaturePayload
- sigBuilderInit :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigType -> HashAlgorithm -> SigBuilder Hashed V4Sig algo
- sigBuilderInitTyped :: forall (algo :: PubKeyAlgorithm) (rfc :: OpenPGPRFC) (h :: HashAlgorithm). (KnownPubKeyAlgorithm algo, HashAlgoAllowedFor rfc h) => OpenPGPRFCW rfc -> SigType -> HashAlgorithmW h -> SigBuilder Hashed V4Sig algo
- sigBuilderInitRuntime :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => OpenPGPRFC -> SigType -> HashAlgorithm -> Either String (SigBuilder Hashed V4Sig algo)
- sigBuilderInitV6 :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigType -> HashAlgorithm -> SignatureSalt -> SigBuilder Hashed V6Sig algo
- sigBuilderInitV6Typed :: forall (algo :: PubKeyAlgorithm) (rfc :: OpenPGPRFC) (h :: HashAlgorithm). (KnownPubKeyAlgorithm algo, HashAlgoAllowedFor rfc h) => OpenPGPRFCW rfc -> SigType -> HashAlgorithmW h -> SignatureSalt -> SigBuilder Hashed V6Sig algo
- sigBuilderInitV6Runtime :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => OpenPGPRFC -> SigType -> HashAlgorithm -> SignatureSalt -> Either String (SigBuilder Hashed V6Sig algo)
- addHashedSubs :: forall v (algo :: PubKeyAlgorithm). HashedSubpackets v -> SigBuilder Hashed v algo -> SigBuilder Unhashed v algo
- addUnhashedSubs :: forall v (algo :: PubKeyAlgorithm). UnhashedSubpackets v -> SigBuilder Unhashed v algo -> SigBuilder Unhashed v algo
- class KnownPubKeyAlgorithm (algo :: PubKeyAlgorithm) where
- demotePubKeyAlgorithmT :: Proxy algo -> PubKeyAlgorithm
- data PrivateKeyFor (algo :: PubKeyAlgorithm) where
- RSAPrivateKey :: PrivateKey -> PrivateKeyFor 'RSA
- Ed25519PrivateKey :: SecretKey -> PrivateKeyFor 'Ed25519
- Ed448PrivateKey :: SecretKey -> PrivateKeyFor 'Ed448
- DSAPrivateKey :: PrivateKey -> PrivateKeyFor 'DSA
- ECDSAPrivateKey :: PrivateKey -> PrivateKeyFor 'ECDSA
- type HashedSubpackets v = SubpacketList Hashed v
- type UnhashedSubpackets v = SubpacketList Unhashed v
- consHashedSub :: SigSubPacket -> HashedSubpackets v -> HashedSubpackets v
- singleHashedSub :: SigSubPacket -> HashedSubpackets v
- singleUnhashedSub :: SigSubPacket -> UnhashedSubpackets v
- listToHashedSubs :: [SigSubPacket] -> HashedSubpackets v
- listToUnhashedSubs :: [SigSubPacket] -> UnhashedSubpackets v
Safe subpacket construction
data SafeSubpacket Source #
A subpacket that has passed basic safety checks (does not guarantee it's critical-safe; use CriticalSubpacket for that)
Instances
| Show SafeSubpacket Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets | |
| Eq SafeSubpacket Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods (==) :: SafeSubpacket -> SafeSubpacket -> Bool Source # (/=) :: SafeSubpacket -> SafeSubpacket -> Bool Source # | |
| Ord SafeSubpacket Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods compare :: SafeSubpacket -> SafeSubpacket -> Ordering Source # (<) :: SafeSubpacket -> SafeSubpacket -> Bool Source # (<=) :: SafeSubpacket -> SafeSubpacket -> Bool Source # (>) :: SafeSubpacket -> SafeSubpacket -> Bool Source # (>=) :: SafeSubpacket -> SafeSubpacket -> Bool Source # max :: SafeSubpacket -> SafeSubpacket -> SafeSubpacket Source # min :: SafeSubpacket -> SafeSubpacket -> SafeSubpacket Source # | |
mkSafeSubpacket :: Bool -> SigSubPacketPayload -> Either String SafeSubpacket Source #
Create a safe subpacket from a payload and criticality flag Basic validation that the payload is well-formed
safePayload :: SafeSubpacket -> SigSubPacketPayload Source #
Extract the payload from a safe subpacket
safeSubpacket :: SafeSubpacket -> SigSubPacket Source #
Extract the underlying SigSubPacket from a safe subpacket
Critical subpacket handling
data CriticalSubpacket Source #
A subpacket that is guaranteed to be both well-formed AND can be safely marked critical Used to prevent accidentally marking non-critical-safe types as critical
Instances
| Show CriticalSubpacket Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets | |
| Eq CriticalSubpacket Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods (==) :: CriticalSubpacket -> CriticalSubpacket -> Bool Source # (/=) :: CriticalSubpacket -> CriticalSubpacket -> Bool Source # | |
| Ord CriticalSubpacket Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods compare :: CriticalSubpacket -> CriticalSubpacket -> Ordering Source # (<) :: CriticalSubpacket -> CriticalSubpacket -> Bool Source # (<=) :: CriticalSubpacket -> CriticalSubpacket -> Bool Source # (>) :: CriticalSubpacket -> CriticalSubpacket -> Bool Source # (>=) :: CriticalSubpacket -> CriticalSubpacket -> Bool Source # max :: CriticalSubpacket -> CriticalSubpacket -> CriticalSubpacket Source # min :: CriticalSubpacket -> CriticalSubpacket -> CriticalSubpacket Source # | |
mkCritical :: SigSubPacketPayload -> Either String CriticalSubpacket Source #
Create a critical subpacket only if the payload type allows it RFC9580 section 5.2.3.5: only certain subpacket types can be marked critical
canBeCritical :: SigSubPacketPayload -> Bool Source #
RFC9580 §5.2.3.5 lists which subpacket types can be marked critical
Text normalization mode
data TextNormalizationMode Source #
Controls how text payload is normalized for CanonicalTextSig.
RFC 9580 §5.2.1.2 requires only CRLF normalization for type 0x01
signatures. Trailing-whitespace stripping is only mandated by
§7 (Cleartext Signature Framework). Use CleartextCompat for
GnuPG-compatible behaviour when producing cleartext-armored
signatures; use RFC9580Strict for inline text signatures.
Constructors
| RFC9580Strict | CRLF normalization only; no trailing-whitespace stripping. Correct for inline type 0x01 document signatures. |
| CleartextCompat | CRLF normalization *plus* per-line trailing-whitespace stripping. Required by the Cleartext Signature Framework (RFC 9580 §7). |
Instances
| Show TextNormalizationMode Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets | |
| Eq TextNormalizationMode Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods (==) :: TextNormalizationMode -> TextNormalizationMode -> Bool Source # (/=) :: TextNormalizationMode -> TextNormalizationMode -> Bool Source # | |
Builder API for signature composition
data SigBuilder hashedness v (algo :: PubKeyAlgorithm) Source #
Staged signature builder that enforces completion order
Usage pattern: builder <- sigBuilderInit SigTypeBinary RSA SHA256 builder' <- addHashedSubs hashedList builder finalPayload <- buildSigV4 sigMPIs (addUnhashedSubs unhashedList builder')
data LegalSubpacket h v where Source #
Legal subpackets encoded by placement and signature-version constraints. This expands compile-time legality beyond bare hashed/unhashed staging.
Constructors
legalSubpacket :: LegalSubpacket h v -> SigSubPacket Source #
singleLegalSub :: LegalSubpacket h v -> SubpacketList h v Source #
consLegalSub :: LegalSubpacket h v -> SubpacketList h v -> SubpacketList h v Source #
listToLegalSubs :: [LegalSubpacket h v] -> SubpacketList h v Source #
sbSigType :: SigBuilder hashedness v algo -> SigType Source #
sbPubKeyAlgo :: forall hashedness v (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigBuilder hashedness v algo -> PubKeyAlgorithm Source #
sbHashAlgo :: SigBuilder hashedness v algo -> HashAlgorithm Source #
sbHashedSubs :: SigBuilder hashedness v algo -> [SigSubPacket] Source #
sbUnhashedSubs :: SigBuilder hashedness v algo -> [SigSubPacket] Source #
sbSalt :: SigBuilder hashedness v algo -> BuilderSalt v Source #
sbTextNormMode :: SigBuilder hashedness v algo -> TextNormalizationMode Source #
Normalization mode for CanonicalTextSig payloads.
Defaults to CleartextCompat for backward compatibility.
buildSigV4 :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigBuilder Unhashed V4Sig algo -> Word16 -> NonEmpty MPI -> SignaturePayload Source #
Build a v4 signature from a completed builder and MPI values
buildSigV6 :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigBuilder Unhashed V6Sig algo -> Word16 -> NonEmpty MPI -> SignaturePayload Source #
Build a v6 signature from a completed builder and MPI values
sigBuilderInit :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigType -> HashAlgorithm -> SigBuilder Hashed V4Sig algo Source #
Initialize a builder for a v4 signature Starts with no subpackets and must call addHashedSubs and addUnhashedSubs
sigBuilderInitTyped :: forall (algo :: PubKeyAlgorithm) (rfc :: OpenPGPRFC) (h :: HashAlgorithm). (KnownPubKeyAlgorithm algo, HashAlgoAllowedFor rfc h) => OpenPGPRFCW rfc -> SigType -> HashAlgorithmW h -> SigBuilder Hashed V4Sig algo Source #
Initialize a builder for a v4 signature with compile-time RFC/hash policy enforcement.
sigBuilderInitRuntime :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => OpenPGPRFC -> SigType -> HashAlgorithm -> Either String (SigBuilder Hashed V4Sig algo) Source #
Initialize a v4 builder from runtime RFC/hash inputs with policy validation and witness promotion at the API boundary.
sigBuilderInitV6 :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => SigType -> HashAlgorithm -> SignatureSalt -> SigBuilder Hashed V6Sig algo Source #
Initialize a builder for a v6 signature
sigBuilderInitV6Typed :: forall (algo :: PubKeyAlgorithm) (rfc :: OpenPGPRFC) (h :: HashAlgorithm). (KnownPubKeyAlgorithm algo, HashAlgoAllowedFor rfc h) => OpenPGPRFCW rfc -> SigType -> HashAlgorithmW h -> SignatureSalt -> SigBuilder Hashed V6Sig algo Source #
Initialize a builder for a v6 signature with compile-time RFC/hash policy enforcement.
sigBuilderInitV6Runtime :: forall (algo :: PubKeyAlgorithm). KnownPubKeyAlgorithm algo => OpenPGPRFC -> SigType -> HashAlgorithm -> SignatureSalt -> Either String (SigBuilder Hashed V6Sig algo) Source #
Initialize a v6 builder from runtime RFC/hash inputs with policy validation and witness promotion at the API boundary.
addHashedSubs :: forall v (algo :: PubKeyAlgorithm). HashedSubpackets v -> SigBuilder Hashed v algo -> SigBuilder Unhashed v algo Source #
Add hashed subpackets to a builder Must be called before addUnhashedSubs
addUnhashedSubs :: forall v (algo :: PubKeyAlgorithm). UnhashedSubpackets v -> SigBuilder Unhashed v algo -> SigBuilder Unhashed v algo Source #
Add unhashed subpackets to a builder Must be called after addHashedSubs
class KnownPubKeyAlgorithm (algo :: PubKeyAlgorithm) where Source #
Methods
demotePubKeyAlgorithmT :: Proxy algo -> PubKeyAlgorithm Source #
Instances
| KnownPubKeyAlgorithm 'DSA Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods demotePubKeyAlgorithmT :: Proxy 'DSA -> PubKeyAlgorithm Source # | |
| KnownPubKeyAlgorithm 'ECDSA Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods demotePubKeyAlgorithmT :: Proxy 'ECDSA -> PubKeyAlgorithm Source # | |
| KnownPubKeyAlgorithm 'EdDSA Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods demotePubKeyAlgorithmT :: Proxy 'EdDSA -> PubKeyAlgorithm Source # | |
| KnownPubKeyAlgorithm 'RSA Source # | |
Defined in Codec.Encryption.OpenPGP.Subpackets Methods demotePubKeyAlgorithmT :: Proxy 'RSA -> PubKeyAlgorithm Source # | |
Private key wrapper (algorithm-specific)
data PrivateKeyFor (algo :: PubKeyAlgorithm) where Source #
Wrapper GADT for algorithm-specific private keys Encodes the algorithm at the type level to ensure type-safe key/builder matching
Constructors
| RSAPrivateKey :: PrivateKey -> PrivateKeyFor 'RSA | |
| Ed25519PrivateKey :: SecretKey -> PrivateKeyFor 'Ed25519 | |
| Ed448PrivateKey :: SecretKey -> PrivateKeyFor 'Ed448 | |
| DSAPrivateKey :: PrivateKey -> PrivateKeyFor 'DSA | |
| ECDSAPrivateKey :: PrivateKey -> PrivateKeyFor 'ECDSA |
Subpacket list utilities
type HashedSubpackets v = SubpacketList Hashed v Source #
Type alias for readability: hashed subpacket list
type UnhashedSubpackets v = SubpacketList Unhashed v Source #
Type alias for readability: unhashed subpacket list
consHashedSub :: SigSubPacket -> HashedSubpackets v -> HashedSubpackets v Source #
Prepend a subpacket to a hashed subpacket list
singleHashedSub :: SigSubPacket -> HashedSubpackets v Source #
Construct a single hashed subpacket into a hashed subpacket list
singleUnhashedSub :: SigSubPacket -> UnhashedSubpackets v Source #
Construct a single unhashed subpacket into an unhashed subpacket list
listToHashedSubs :: [SigSubPacket] -> HashedSubpackets v Source #
Convert a list to a hashed subpacket list Used to bridge between list-based and phantom-typed APIs
listToUnhashedSubs :: [SigSubPacket] -> UnhashedSubpackets v Source #
Convert a list to an unhashed subpacket list Used to bridge between list-based and phantom-typed APIs