    -- Pkt.hs: OpenPGP (RFC4880) Pkt data types
    -- Copyright © 2012-2022  Clint Adams
    -- This software is released under the terms of the Expat license.
    -- (See the LICENSE file).
    {-# LANGUAGE DataKinds #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE ExistentialQuantification #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE TemplateHaskell #-}

    module Codec.Encryption.OpenPGP.Types.Internal.Pkt where

    import GHC.Generics (Generic)

    import Codec.Encryption.OpenPGP.Types.Internal.Base
    import Codec.Encryption.OpenPGP.Types.Internal.PKITypes

    import Codec.Encryption.OpenPGP.Types.Internal.PrettyUtils (prettyLBS)
    import Control.Lens (makeLenses)
    import Data.Aeson ((.=), object)
    import qualified Data.Aeson as A
    import Data.ByteString.Lazy (ByteString)
    import qualified Data.ByteString.Lazy as BL
    import Data.Data (Data)
    import Data.Hashable (Hashable(..))
    import Data.List.NonEmpty (NonEmpty)
    import qualified Data.List.NonEmpty as NE
    import Data.Ord (comparing)
    import Data.Text (Text)
    import qualified Data.Text as T
    import Data.Time.Clock (UTCTime)
    import Data.Typeable (Typeable)
    import Data.Word (Word8)
    import Prettyprinter (Pretty(..), (<+>))

    -- data Pkt = forall a. (Packet a, Show a, Eq a) => Pkt a
    data Pkt
      = PKESKPkt PacketVersion EightOctetKeyId PubKeyAlgorithm (NonEmpty MPI)
      | SignaturePkt SignaturePayload
      | SKESKPkt PacketVersion SymmetricAlgorithm S2K (Maybe BL.ByteString)
      | OnePassSignaturePkt
          PacketVersion
          SigType
          HashAlgorithm
          PubKeyAlgorithm
          EightOctetKeyId
          NestedFlag
      | SecretKeyPkt PKPayload SKAddendum
      | PublicKeyPkt PKPayload
      | SecretSubkeyPkt PKPayload SKAddendum
      | CompressedDataPkt CompressionAlgorithm CompressedDataPayload
      | SymEncDataPkt ByteString
      | MarkerPkt ByteString
      | LiteralDataPkt DataType FileName ThirtyTwoBitTimeStamp ByteString
      | TrustPkt ByteString
      | UserIdPkt Text
      | PublicSubkeyPkt PKPayload
      | UserAttributePkt [UserAttrSubPacket]
      | SymEncIntegrityProtectedDataPkt PacketVersion ByteString
      | ModificationDetectionCodePkt ByteString
      | OtherPacketPkt Word8 ByteString
      | BrokenPacketPkt String Word8 ByteString
      deriving (Typeable Pkt
    Typeable Pkt =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Pkt -> c Pkt)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Pkt)
    -> (Pkt -> Constr)
    -> (Pkt -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Pkt))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pkt))
    -> ((forall b. Data b => b -> b) -> Pkt -> Pkt)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Pkt -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Pkt -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> Pkt -> m Pkt)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Pkt -> m Pkt)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Pkt -> m Pkt)
    -> Data Pkt
    Pkt -> Constr
    Pkt -> DataType
    (forall b. Data b => b -> b) -> Pkt -> Pkt
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Pkt -> u
    forall u. (forall d. Data d => d -> u) -> Pkt -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pkt
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pkt -> c Pkt
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pkt)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pkt)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pkt -> c Pkt
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Pkt -> c Pkt
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pkt
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Pkt
    $ctoConstr :: Pkt -> Constr
    toConstr :: Pkt -> Constr
    $cdataTypeOf :: Pkt -> DataType
    dataTypeOf :: Pkt -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pkt)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Pkt)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pkt)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Pkt)
    $cgmapT :: (forall b. Data b => b -> b) -> Pkt -> Pkt
    gmapT :: (forall b. Data b => b -> b) -> Pkt -> Pkt
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Pkt -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Pkt -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Pkt -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pkt -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Pkt -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Pkt -> m Pkt
    Data, Pkt -> Pkt -> NestedFlag
    (Pkt -> Pkt -> NestedFlag) -> (Pkt -> Pkt -> NestedFlag) -> Eq Pkt
    forall a. (a -> a -> NestedFlag) -> (a -> a -> NestedFlag) -> Eq a
    $c== :: Pkt -> Pkt -> NestedFlag
    == :: Pkt -> Pkt -> NestedFlag
    $c/= :: Pkt -> Pkt -> NestedFlag
    /= :: Pkt -> Pkt -> NestedFlag
    Eq, (forall x. Pkt -> Rep Pkt x)
    -> (forall x. Rep Pkt x -> Pkt) -> Generic Pkt
    forall x. Rep Pkt x -> Pkt
    forall x. Pkt -> Rep Pkt x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Pkt -> Rep Pkt x
    from :: forall x. Pkt -> Rep Pkt x
    $cto :: forall x. Rep Pkt x -> Pkt
    to :: forall x. Rep Pkt x -> Pkt
    Generic, Int -> Pkt -> ShowS
    [Pkt] -> ShowS
    Pkt -> String
    (Int -> Pkt -> ShowS)
    -> (Pkt -> String) -> ([Pkt] -> ShowS) -> Show Pkt
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Pkt -> ShowS
    showsPrec :: Int -> Pkt -> ShowS
    $cshow :: Pkt -> String
    show :: Pkt -> String
    $cshowList :: [Pkt] -> ShowS
    showList :: [Pkt] -> ShowS
    Show, Typeable) -- FIXME

    instance Hashable Pkt

    instance Ord Pkt where
      compare :: Pkt -> Pkt -> Ordering
    compare = (Pkt -> Word8) -> Pkt -> Pkt -> Ordering
    forall a b. Ord a => (b -> a) -> b -> b -> Ordering
    comparing Pkt -> Word8
    pktTag (Pkt -> Pkt -> Ordering)
    -> (Pkt -> Pkt -> Ordering) -> Pkt -> Pkt -> Ordering
    forall a. Semigroup a => a -> a -> a
    <> (Pkt -> Int) -> Pkt -> Pkt -> Ordering
    forall a b. Ord a => (b -> a) -> b -> b -> Ordering
    comparing Pkt -> Int
    forall a. Hashable a => a -> Int
    hash -- FIXME: is there something saner?

    instance Pretty Pkt where
      pretty :: forall ann. Pkt -> Doc ann
    pretty (PKESKPkt Word8
    pv EightOctetKeyId
    eoki PubKeyAlgorithm
    pka NonEmpty MPI
    mpis) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "PKESK v" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Doc ann
    forall ann. Word8 -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Word8
    pv Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ':' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        EightOctetKeyId -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. EightOctetKeyId -> Doc ann
    pretty EightOctetKeyId
    eoki Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PubKeyAlgorithm -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PubKeyAlgorithm -> Doc ann
    pretty PubKeyAlgorithm
    pka Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> ([MPI] -> Doc ann
    forall ann. [MPI] -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty ([MPI] -> Doc ann)
    -> (NonEmpty MPI -> [MPI]) -> NonEmpty MPI -> Doc ann
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . NonEmpty MPI -> [MPI]
    forall a. NonEmpty a -> [a]
    NE.toList) NonEmpty MPI
    mpis
      pretty (SignaturePkt SignaturePayload
    sp) = SignaturePayload -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SignaturePayload -> Doc ann
    pretty SignaturePayload
    sp
      pretty (SKESKPkt Word8
    pv SymmetricAlgorithm
    sa S2K
    s2k Maybe ByteString
    mbs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "SKESK v" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Doc ann
    forall ann. Word8 -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Word8
    pv Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ':' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        SymmetricAlgorithm -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SymmetricAlgorithm -> Doc ann
    pretty SymmetricAlgorithm
    sa Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> S2K -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. S2K -> Doc ann
    pretty S2K
    s2k Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Maybe String -> Doc ann
    forall ann. Maybe String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty ((ByteString -> String) -> Maybe ByteString -> Maybe String
    forall a b. (a -> b) -> Maybe a -> Maybe b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap ByteString -> String
    bsToHexUpper Maybe ByteString
    mbs)
      pretty (OnePassSignaturePkt Word8
    pv SigType
    st HashAlgorithm
    ha PubKeyAlgorithm
    pka EightOctetKeyId
    eoki NestedFlag
    nestedflag) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "one-pass signature v" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Doc ann
    forall ann. Word8 -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Word8
    pv Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ':' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        SigType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SigType -> Doc ann
    pretty SigType
    st Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> HashAlgorithm -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. HashAlgorithm -> Doc ann
    pretty HashAlgorithm
    ha Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PubKeyAlgorithm -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PubKeyAlgorithm -> Doc ann
    pretty PubKeyAlgorithm
    pka Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> EightOctetKeyId -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. EightOctetKeyId -> Doc ann
    pretty EightOctetKeyId
    eoki Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> NestedFlag -> Doc ann
    forall ann. NestedFlag -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty NestedFlag
    nestedflag
      pretty (SecretKeyPkt PKPayload
    pkp SKAddendum
    ska) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "secret key:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PKPayload -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PKPayload -> Doc ann
    pretty PKPayload
    pkp Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SKAddendum -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SKAddendum -> Doc ann
    pretty SKAddendum
    ska
      pretty (PublicKeyPkt PKPayload
    pkp) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "public key:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PKPayload -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PKPayload -> Doc ann
    pretty PKPayload
    pkp
      pretty (SecretSubkeyPkt PKPayload
    pkp SKAddendum
    ska) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "secret subkey:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PKPayload -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PKPayload -> Doc ann
    pretty PKPayload
    pkp Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> SKAddendum -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. SKAddendum -> Doc ann
    pretty SKAddendum
    ska
      pretty (CompressedDataPkt CompressionAlgorithm
    ca ByteString
    cdp) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "compressed-data:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> CompressionAlgorithm -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. CompressionAlgorithm -> Doc ann
    pretty CompressionAlgorithm
    ca Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> ByteString -> Doc ann
    forall ann. ByteString -> Doc ann
    prettyLBS ByteString
    cdp
      pretty (SymEncDataPkt ByteString
    bs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "symmetrically-encrypted-data:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)
      pretty (MarkerPkt ByteString
    bs) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "marker:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)
      pretty (LiteralDataPkt DataType
    dt ByteString
    fn ThirtyTwoBitTimeStamp
    ts ByteString
    bs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "literal-data" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        DataType -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. DataType -> Doc ann
    pretty DataType
    dt Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> ByteString -> Doc ann
    forall ann. ByteString -> Doc ann
    prettyLBS ByteString
    fn Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> ThirtyTwoBitTimeStamp -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. ThirtyTwoBitTimeStamp -> Doc ann
    pretty ThirtyTwoBitTimeStamp
    ts Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)
      pretty (TrustPkt ByteString
    bs) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "trust:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [Word8] -> Doc ann
    forall ann. [Word8] -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> [Word8]
    BL.unpack ByteString
    bs)
      pretty (UserIdPkt Text
    u) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "user-ID:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> Text -> Doc ann
    forall ann. Text -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Text
    u
      pretty (PublicSubkeyPkt PKPayload
    pkp) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "public subkey:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> PKPayload -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    forall ann. PKPayload -> Doc ann
    pretty PKPayload
    pkp
      pretty (UserAttributePkt [UserAttrSubPacket]
    us) = String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "user-attribute:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> [UserAttrSubPacket] -> Doc ann
    forall ann. [UserAttrSubPacket] -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty [UserAttrSubPacket]
    us
      pretty (SymEncIntegrityProtectedDataPkt Word8
    pv ByteString
    bs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "symmetrically-encrypted-integrity-protected-data v" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Word8 -> Doc ann
    forall ann. Word8 -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Word8
    pv Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <>
        Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ':' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)
      pretty (ModificationDetectionCodePkt ByteString
    bs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "MDC:" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)
      pretty (OtherPacketPkt Word8
    t ByteString
    bs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "unknown packet type" Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        Word8 -> Doc ann
    forall ann. Word8 -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Word8
    t Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ':' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)
      pretty (BrokenPacketPkt String
    s Word8
    t ByteString
    bs) =
        String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    "BROKEN packet (" Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty String
    s Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ')' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+>
        Word8 -> Doc ann
    forall ann. Word8 -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Word8
    t Doc ann -> Doc ann -> Doc ann
    forall a. Semigroup a => a -> a -> a
    <> Char -> Doc ann
    forall ann. Char -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty Char
    ':' Doc ann -> Doc ann -> Doc ann
    forall ann. Doc ann -> Doc ann -> Doc ann
    <+> String -> Doc ann
    forall ann. String -> Doc ann
    forall a ann. Pretty a => a -> Doc ann
    pretty (ByteString -> String
    bsToHexUpper ByteString
    bs)

    instance A.ToJSON Pkt where
      toJSON :: Pkt -> Value
    toJSON (PKESKPkt Word8
    pv EightOctetKeyId
    eoki PubKeyAlgorithm
    pka NonEmpty MPI
    mpis) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "pkesk" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object
              [ String -> Key
    key String
    "version" Key -> Word8 -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Word8
    pv
              , String -> Key
    key String
    "keyid" Key -> EightOctetKeyId -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= EightOctetKeyId
    eoki
              , String -> Key
    key String
    "pkalgo" Key -> PubKeyAlgorithm -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= PubKeyAlgorithm
    pka
              , String -> Key
    key String
    "mpis" Key -> [MPI] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= NonEmpty MPI -> [MPI]
    forall a. NonEmpty a -> [a]
    NE.toList NonEmpty MPI
    mpis
              ]
          ]
      toJSON (SignaturePkt SignaturePayload
    sp) = [Pair] -> Value
    object [String -> Key
    key String
    "signature" Key -> SignaturePayload -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= SignaturePayload
    sp]
      toJSON (SKESKPkt Word8
    pv SymmetricAlgorithm
    sa S2K
    s2k Maybe ByteString
    mbs) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "skesk" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object
              [ String -> Key
    key String
    "version" Key -> Word8 -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Word8
    pv
              , String -> Key
    key String
    "symalgo" Key -> SymmetricAlgorithm -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= SymmetricAlgorithm
    sa
              , String -> Key
    key String
    "s2k" Key -> S2K -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= S2K
    s2k
              , String -> Key
    key String
    "data" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= [Word8] -> (ByteString -> [Word8]) -> Maybe ByteString -> [Word8]
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe [Word8]
    forall a. Monoid a => a
    mempty ByteString -> [Word8]
    BL.unpack Maybe ByteString
    mbs
              ]
          ]
      toJSON (OnePassSignaturePkt Word8
    pv SigType
    st HashAlgorithm
    ha PubKeyAlgorithm
    pka EightOctetKeyId
    eoki NestedFlag
    nestedflag) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "onepasssignature" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object
              [ String -> Key
    key String
    "version" Key -> Word8 -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Word8
    pv
              , String -> Key
    key String
    "sigtype" Key -> SigType -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= SigType
    st
              , String -> Key
    key String
    "hashalgo" Key -> HashAlgorithm -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= HashAlgorithm
    ha
              , String -> Key
    key String
    "pkalgo" Key -> PubKeyAlgorithm -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= PubKeyAlgorithm
    pka
              , String -> Key
    key String
    "keyid" Key -> EightOctetKeyId -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= EightOctetKeyId
    eoki
              , String -> Key
    key String
    "nested" Key -> NestedFlag -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= NestedFlag
    nestedflag
              ]
          ]
      toJSON (SecretKeyPkt PKPayload
    pkp SKAddendum
    ska) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "secretkey" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object [String -> Key
    key String
    "public" Key -> PKPayload -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= PKPayload
    pkp, String -> Key
    key String
    "secret" Key -> SKAddendum -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= SKAddendum
    ska]
          ]
      toJSON (PublicKeyPkt PKPayload
    pkp) = [Pair] -> Value
    object [String -> Key
    key String
    "publickey" Key -> PKPayload -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= PKPayload
    pkp]
      toJSON (SecretSubkeyPkt PKPayload
    pkp SKAddendum
    ska) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "secretsubkey" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object [String -> Key
    key String
    "public" Key -> PKPayload -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= PKPayload
    pkp, String -> Key
    key String
    "secret" Key -> SKAddendum -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= SKAddendum
    ska]
          ]
      toJSON (CompressedDataPkt CompressionAlgorithm
    ca ByteString
    cdp) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "compresseddata" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object [String -> Key
    key String
    "compressionalgo" Key -> CompressionAlgorithm -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= CompressionAlgorithm
    ca, String -> Key
    key String
    "data" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    cdp]
          ]
      toJSON (SymEncDataPkt ByteString
    bs) = [Pair] -> Value
    object [String -> Key
    key String
    "symencdata" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs]
      toJSON (MarkerPkt ByteString
    bs) = [Pair] -> Value
    object [String -> Key
    key String
    "marker" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs]
      toJSON (LiteralDataPkt DataType
    dt ByteString
    fn ThirtyTwoBitTimeStamp
    ts ByteString
    bs) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "literaldata" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object
              [ String -> Key
    key String
    "dt" Key -> DataType -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= DataType
    dt
              , String -> Key
    key String
    "filename" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    fn
              , String -> Key
    key String
    "ts" Key -> ThirtyTwoBitTimeStamp -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ThirtyTwoBitTimeStamp
    ts
              , String -> Key
    key String
    "data" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs
              ]
          ]
      toJSON (TrustPkt ByteString
    bs) = [Pair] -> Value
    object [String -> Key
    key String
    "trust" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs]
      toJSON (UserIdPkt Text
    u) = [Pair] -> Value
    object [String -> Key
    key String
    "userid" Key -> Text -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Text
    u]
      toJSON (PublicSubkeyPkt PKPayload
    pkp) = [Pair] -> Value
    object [String -> Key
    key String
    "publicsubkkey" Key -> PKPayload -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= PKPayload
    pkp]
      toJSON (UserAttributePkt [UserAttrSubPacket]
    us) = [Pair] -> Value
    object [String -> Key
    key String
    "userattribute" Key -> [UserAttrSubPacket] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= [UserAttrSubPacket]
    us]
      toJSON (SymEncIntegrityProtectedDataPkt Word8
    pv ByteString
    bs) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "symencipd" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object [String -> Key
    key String
    "version" Key -> Word8 -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Word8
    pv, String -> Key
    key String
    "data" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs]
          ]
      toJSON (ModificationDetectionCodePkt ByteString
    bs) =
        [Pair] -> Value
    object [String -> Key
    key String
    "mdc" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs]
      toJSON (OtherPacketPkt Word8
    t ByteString
    bs) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "otherpacket" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object [String -> Key
    key String
    "tag" Key -> Word8 -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Word8
    t, String -> Key
    key String
    "data" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs]
          ]
      toJSON (BrokenPacketPkt String
    s Word8
    t ByteString
    bs) =
        [Pair] -> Value
    object
          [ String -> Key
    key String
    "brokenpacket" Key -> Value -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .=
            [Pair] -> Value
    object
              [ String -> Key
    key String
    "error" Key -> String -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= String
    s
              , String -> Key
    key String
    "tag" Key -> Word8 -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= Word8
    t
              , String -> Key
    key String
    "data" Key -> [Word8] -> Pair
    forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
    forall v. ToJSON v => Key -> v -> Pair
    .= ByteString -> [Word8]
    BL.unpack ByteString
    bs
              ]
          ]

    pktTag :: Pkt -> Word8
    pktTag :: Pkt -> Word8
    pktTag PKESKPkt {} = Word8
    1
    pktTag (SignaturePkt SignaturePayload
    _) = Word8
    2
    pktTag SKESKPkt {} = Word8
    3
    pktTag OnePassSignaturePkt {} = Word8
    4
    pktTag SecretKeyPkt {} = Word8
    5
    pktTag (PublicKeyPkt PKPayload
    _) = Word8
    6
    pktTag SecretSubkeyPkt {} = Word8
    7
    pktTag CompressedDataPkt {} = Word8
    8
    pktTag (SymEncDataPkt ByteString
    _) = Word8
    9
    pktTag (MarkerPkt ByteString
    _) = Word8
    10
    pktTag LiteralDataPkt {} = Word8
    11
    pktTag (TrustPkt ByteString
    _) = Word8
    12
    pktTag (UserIdPkt Text
    _) = Word8
    13
    pktTag (PublicSubkeyPkt PKPayload
    _) = Word8
    14
    pktTag (UserAttributePkt [UserAttrSubPacket]
    _) = Word8
    17
    pktTag SymEncIntegrityProtectedDataPkt {} = Word8
    18
    pktTag (ModificationDetectionCodePkt ByteString
    _) = Word8
    19
    pktTag (OtherPacketPkt Word8
    t ByteString
    _) = Word8
    t
    pktTag (BrokenPacketPkt String
    _ Word8
    t ByteString
    _) = Word8
    t -- is this the right thing to do?

    data Verification =
      Verification
        { Verification -> PKPayload
    _verificationSigner :: PKPayload
        , Verification -> SignaturePayload
    _verificationSignature :: SignaturePayload
        }

    data SOPVVerification =
      SOPVVerification
        { SOPVVerification -> UTCTime
    _sopvvDateStamp :: UTCTime
        , SOPVVerification -> TwentyOctetFingerprint
    _sopvvFingerprint :: TwentyOctetFingerprint
        , SOPVVerification -> TwentyOctetFingerprint
    _sopvvPrimaryFingerprint :: TwentyOctetFingerprint
        , SOPVVerification -> String
    _sopvvMode :: String
        , SOPVVerification -> String
    _sopvvDescription :: String
        }

    $(makeLenses ''Verification)
    $(makeLenses ''SOPVVerification)