-- ASCIIArmor/Decode.hs: OpenPGP (RFC9580) ASCII armor implementation
-- Copyright © 2012-2026  Clint Adams
-- This software is released under the terms of the Expat license.
-- (See the LICENSE file).

module Codec.Encryption.OpenPGP.ASCIIArmor.Types (
   Armor(..)
 , ArmorType(..)
 , ConformanceProfile(..)
 , DecodeOptions(..)
 , DecodeCRC24Validation(..)
 , DecodeCleartextHeaderPolicy(..)
 , defaultDecodeOptions
 , EncodeOptions(..)
 , EncodeCRC24Emission(..)
 , defaultEncodeOptions
) where

import Data.ByteString.Lazy (ByteString)

data Armor = Armor ArmorType [(String, String)] ByteString
   | ClearSigned [(String, String)] ByteString Armor
    deriving (Int -> Armor -> ShowS
[Armor] -> ShowS
Armor -> String
(Int -> Armor -> ShowS)
-> (Armor -> String) -> ([Armor] -> ShowS) -> Show Armor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Armor -> ShowS
showsPrec :: Int -> Armor -> ShowS
$cshow :: Armor -> String
show :: Armor -> String
$cshowList :: [Armor] -> ShowS
showList :: [Armor] -> ShowS
Show, Armor -> Armor -> Bool
(Armor -> Armor -> Bool) -> (Armor -> Armor -> Bool) -> Eq Armor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Armor -> Armor -> Bool
== :: Armor -> Armor -> Bool
$c/= :: Armor -> Armor -> Bool
/= :: Armor -> Armor -> Bool
Eq)

data ArmorType = ArmorMessage
               | ArmorPublicKeyBlock
               | ArmorPrivateKeyBlock -- RFC4880 legacy
               | ArmorSplitMessage ByteString ByteString -- RFC4880 legacy
               | ArmorSplitMessageIndefinite ByteString
               | ArmorSignature
    deriving (Int -> ArmorType -> ShowS
[ArmorType] -> ShowS
ArmorType -> String
(Int -> ArmorType -> ShowS)
-> (ArmorType -> String)
-> ([ArmorType] -> ShowS)
-> Show ArmorType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ArmorType -> ShowS
showsPrec :: Int -> ArmorType -> ShowS
$cshow :: ArmorType -> String
show :: ArmorType -> String
$cshowList :: [ArmorType] -> ShowS
showList :: [ArmorType] -> ShowS
Show, ArmorType -> ArmorType -> Bool
(ArmorType -> ArmorType -> Bool)
-> (ArmorType -> ArmorType -> Bool) -> Eq ArmorType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ArmorType -> ArmorType -> Bool
== :: ArmorType -> ArmorType -> Bool
$c/= :: ArmorType -> ArmorType -> Bool
/= :: ArmorType -> ArmorType -> Bool
Eq)

data ConformanceProfile = Strict_4880_AA
                        | Strict_9580_AA
                        | Postel_AA
    deriving (Int -> ConformanceProfile -> ShowS
[ConformanceProfile] -> ShowS
ConformanceProfile -> String
(Int -> ConformanceProfile -> ShowS)
-> (ConformanceProfile -> String)
-> ([ConformanceProfile] -> ShowS)
-> Show ConformanceProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ConformanceProfile -> ShowS
showsPrec :: Int -> ConformanceProfile -> ShowS
$cshow :: ConformanceProfile -> String
show :: ConformanceProfile -> String
$cshowList :: [ConformanceProfile] -> ShowS
showList :: [ConformanceProfile] -> ShowS
Show, ConformanceProfile -> ConformanceProfile -> Bool
(ConformanceProfile -> ConformanceProfile -> Bool)
-> (ConformanceProfile -> ConformanceProfile -> Bool)
-> Eq ConformanceProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ConformanceProfile -> ConformanceProfile -> Bool
== :: ConformanceProfile -> ConformanceProfile -> Bool
$c/= :: ConformanceProfile -> ConformanceProfile -> Bool
/= :: ConformanceProfile -> ConformanceProfile -> Bool
Eq)

data DecodeCRC24Validation = DecodeCRC24ValidationAuto
                           | DecodeCRC24ValidationStrict
                           | DecodeCRC24ValidationPermissive
    deriving (Int -> DecodeCRC24Validation -> ShowS
[DecodeCRC24Validation] -> ShowS
DecodeCRC24Validation -> String
(Int -> DecodeCRC24Validation -> ShowS)
-> (DecodeCRC24Validation -> String)
-> ([DecodeCRC24Validation] -> ShowS)
-> Show DecodeCRC24Validation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DecodeCRC24Validation -> ShowS
showsPrec :: Int -> DecodeCRC24Validation -> ShowS
$cshow :: DecodeCRC24Validation -> String
show :: DecodeCRC24Validation -> String
$cshowList :: [DecodeCRC24Validation] -> ShowS
showList :: [DecodeCRC24Validation] -> ShowS
Show, DecodeCRC24Validation -> DecodeCRC24Validation -> Bool
(DecodeCRC24Validation -> DecodeCRC24Validation -> Bool)
-> (DecodeCRC24Validation -> DecodeCRC24Validation -> Bool)
-> Eq DecodeCRC24Validation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DecodeCRC24Validation -> DecodeCRC24Validation -> Bool
== :: DecodeCRC24Validation -> DecodeCRC24Validation -> Bool
$c/= :: DecodeCRC24Validation -> DecodeCRC24Validation -> Bool
/= :: DecodeCRC24Validation -> DecodeCRC24Validation -> Bool
Eq)

data DecodeCleartextHeaderPolicy = DecodeCleartextHeaderPolicyAuto
                                 | DecodeCleartextHeaderPolicyLegacy
                                 | DecodeCleartextHeaderPolicyHashOnly
    deriving (Int -> DecodeCleartextHeaderPolicy -> ShowS
[DecodeCleartextHeaderPolicy] -> ShowS
DecodeCleartextHeaderPolicy -> String
(Int -> DecodeCleartextHeaderPolicy -> ShowS)
-> (DecodeCleartextHeaderPolicy -> String)
-> ([DecodeCleartextHeaderPolicy] -> ShowS)
-> Show DecodeCleartextHeaderPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DecodeCleartextHeaderPolicy -> ShowS
showsPrec :: Int -> DecodeCleartextHeaderPolicy -> ShowS
$cshow :: DecodeCleartextHeaderPolicy -> String
show :: DecodeCleartextHeaderPolicy -> String
$cshowList :: [DecodeCleartextHeaderPolicy] -> ShowS
showList :: [DecodeCleartextHeaderPolicy] -> ShowS
Show, DecodeCleartextHeaderPolicy -> DecodeCleartextHeaderPolicy -> Bool
(DecodeCleartextHeaderPolicy
 -> DecodeCleartextHeaderPolicy -> Bool)
-> (DecodeCleartextHeaderPolicy
    -> DecodeCleartextHeaderPolicy -> Bool)
-> Eq DecodeCleartextHeaderPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DecodeCleartextHeaderPolicy -> DecodeCleartextHeaderPolicy -> Bool
== :: DecodeCleartextHeaderPolicy -> DecodeCleartextHeaderPolicy -> Bool
$c/= :: DecodeCleartextHeaderPolicy -> DecodeCleartextHeaderPolicy -> Bool
/= :: DecodeCleartextHeaderPolicy -> DecodeCleartextHeaderPolicy -> Bool
Eq)

data DecodeOptions = DecodeOptions {
    DecodeOptions -> ConformanceProfile
decodeConformanceProfile :: ConformanceProfile
  , DecodeOptions -> DecodeCRC24Validation
decodeCRC24Validation :: DecodeCRC24Validation
  , DecodeOptions -> DecodeCleartextHeaderPolicy
decodeCleartextHeaderPolicy :: DecodeCleartextHeaderPolicy
} deriving (Int -> DecodeOptions -> ShowS
[DecodeOptions] -> ShowS
DecodeOptions -> String
(Int -> DecodeOptions -> ShowS)
-> (DecodeOptions -> String)
-> ([DecodeOptions] -> ShowS)
-> Show DecodeOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DecodeOptions -> ShowS
showsPrec :: Int -> DecodeOptions -> ShowS
$cshow :: DecodeOptions -> String
show :: DecodeOptions -> String
$cshowList :: [DecodeOptions] -> ShowS
showList :: [DecodeOptions] -> ShowS
Show, DecodeOptions -> DecodeOptions -> Bool
(DecodeOptions -> DecodeOptions -> Bool)
-> (DecodeOptions -> DecodeOptions -> Bool) -> Eq DecodeOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DecodeOptions -> DecodeOptions -> Bool
== :: DecodeOptions -> DecodeOptions -> Bool
$c/= :: DecodeOptions -> DecodeOptions -> Bool
/= :: DecodeOptions -> DecodeOptions -> Bool
Eq)

defaultDecodeOptions :: DecodeOptions
defaultDecodeOptions :: DecodeOptions
defaultDecodeOptions = DecodeOptions {
    decodeConformanceProfile :: ConformanceProfile
decodeConformanceProfile = ConformanceProfile
Postel_AA
  , decodeCRC24Validation :: DecodeCRC24Validation
decodeCRC24Validation = DecodeCRC24Validation
DecodeCRC24ValidationAuto
  , decodeCleartextHeaderPolicy :: DecodeCleartextHeaderPolicy
decodeCleartextHeaderPolicy = DecodeCleartextHeaderPolicy
DecodeCleartextHeaderPolicyAuto
}

data EncodeCRC24Emission = EncodeCRC24EmissionAuto
                         | EncodeCRC24EmissionAlways
                         | EncodeCRC24EmissionNever
    deriving (Int -> EncodeCRC24Emission -> ShowS
[EncodeCRC24Emission] -> ShowS
EncodeCRC24Emission -> String
(Int -> EncodeCRC24Emission -> ShowS)
-> (EncodeCRC24Emission -> String)
-> ([EncodeCRC24Emission] -> ShowS)
-> Show EncodeCRC24Emission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EncodeCRC24Emission -> ShowS
showsPrec :: Int -> EncodeCRC24Emission -> ShowS
$cshow :: EncodeCRC24Emission -> String
show :: EncodeCRC24Emission -> String
$cshowList :: [EncodeCRC24Emission] -> ShowS
showList :: [EncodeCRC24Emission] -> ShowS
Show, EncodeCRC24Emission -> EncodeCRC24Emission -> Bool
(EncodeCRC24Emission -> EncodeCRC24Emission -> Bool)
-> (EncodeCRC24Emission -> EncodeCRC24Emission -> Bool)
-> Eq EncodeCRC24Emission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EncodeCRC24Emission -> EncodeCRC24Emission -> Bool
== :: EncodeCRC24Emission -> EncodeCRC24Emission -> Bool
$c/= :: EncodeCRC24Emission -> EncodeCRC24Emission -> Bool
/= :: EncodeCRC24Emission -> EncodeCRC24Emission -> Bool
Eq)

data EncodeOptions = EncodeOptions {
    EncodeOptions -> ConformanceProfile
encodeConformanceProfile :: ConformanceProfile
  , EncodeOptions -> EncodeCRC24Emission
encodeCRC24Emission :: EncodeCRC24Emission
} deriving (Int -> EncodeOptions -> ShowS
[EncodeOptions] -> ShowS
EncodeOptions -> String
(Int -> EncodeOptions -> ShowS)
-> (EncodeOptions -> String)
-> ([EncodeOptions] -> ShowS)
-> Show EncodeOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EncodeOptions -> ShowS
showsPrec :: Int -> EncodeOptions -> ShowS
$cshow :: EncodeOptions -> String
show :: EncodeOptions -> String
$cshowList :: [EncodeOptions] -> ShowS
showList :: [EncodeOptions] -> ShowS
Show, EncodeOptions -> EncodeOptions -> Bool
(EncodeOptions -> EncodeOptions -> Bool)
-> (EncodeOptions -> EncodeOptions -> Bool) -> Eq EncodeOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EncodeOptions -> EncodeOptions -> Bool
== :: EncodeOptions -> EncodeOptions -> Bool
$c/= :: EncodeOptions -> EncodeOptions -> Bool
/= :: EncodeOptions -> EncodeOptions -> Bool
Eq)

defaultEncodeOptions :: EncodeOptions
defaultEncodeOptions :: EncodeOptions
defaultEncodeOptions = EncodeOptions {
    encodeConformanceProfile :: ConformanceProfile
encodeConformanceProfile = ConformanceProfile
Strict_9580_AA
  , encodeCRC24Emission :: EncodeCRC24Emission
encodeCRC24Emission = EncodeCRC24Emission
EncodeCRC24EmissionAuto
}