-- 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 (Show, Eq)

data ArmorType = ArmorMessage
               | ArmorPublicKeyBlock
               | ArmorPrivateKeyBlock -- RFC4880 legacy
               | ArmorSplitMessage ByteString ByteString -- RFC4880 legacy
               | ArmorSplitMessageIndefinite ByteString
               | ArmorSignature
    deriving (Show, Eq)

data ConformanceProfile = Strict_4880_AA
                        | Strict_9580_AA
                        | Postel_AA
    deriving (Show, Eq)

data DecodeCRC24Validation = DecodeCRC24ValidationAuto
                           | DecodeCRC24ValidationStrict
                           | DecodeCRC24ValidationPermissive
    deriving (Show, Eq)

data DecodeCleartextHeaderPolicy = DecodeCleartextHeaderPolicyAuto
                                 | DecodeCleartextHeaderPolicyLegacy
                                 | DecodeCleartextHeaderPolicyHashOnly
    deriving (Show, Eq)

data DecodeOptions = DecodeOptions {
    decodeConformanceProfile :: ConformanceProfile
  , decodeCRC24Validation :: DecodeCRC24Validation
  , decodeCleartextHeaderPolicy :: DecodeCleartextHeaderPolicy
} deriving (Show, Eq)

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

data EncodeCRC24Emission = EncodeCRC24EmissionAuto
                         | EncodeCRC24EmissionAlways
                         | EncodeCRC24EmissionNever
    deriving (Show, Eq)

data EncodeOptions = EncodeOptions {
    encodeConformanceProfile :: ConformanceProfile
  , encodeCRC24Emission :: EncodeCRC24Emission
} deriving (Show, Eq)

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