-- PKITypes.hs: OpenPGP (RFC9580) data types for public/secret keys
-- Copyright © 2012-2026  Clint Adams
-- This software is released under the terms of the Expat license.
-- (See the LICENSE file).

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell #-}

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

import GHC.Generics (Generic)

import Codec.Encryption.OpenPGP.Types.Internal.Base hiding (Ed25519, Ed448)
import Codec.Encryption.OpenPGP.Types.Internal.CryptonNewtypes

import qualified Data.Aeson as A
import qualified Data.ByteString as B
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BL
import Data.Data (Data(..))
import qualified Data.Data as DData
import Data.Hashable (Hashable(..))
import Data.Ord (comparing)
import Data.Typeable (Typeable)
import Data.Word (Word16)
import Prettyprinter (Pretty(..), (<+>))

data EdSigningCurve =
  Ed25519
  | Ed448
  deriving (Typeable EdSigningCurve
Typeable EdSigningCurve =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> EdSigningCurve -> c EdSigningCurve)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EdSigningCurve)
-> (EdSigningCurve -> Constr)
-> (EdSigningCurve -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EdSigningCurve))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c EdSigningCurve))
-> ((forall b. Data b => b -> b)
    -> EdSigningCurve -> EdSigningCurve)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> EdSigningCurve -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> EdSigningCurve -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> EdSigningCurve -> m EdSigningCurve)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> EdSigningCurve -> m EdSigningCurve)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> EdSigningCurve -> m EdSigningCurve)
-> Data EdSigningCurve
EdSigningCurve -> Constr
EdSigningCurve -> DataType
(forall b. Data b => b -> b) -> EdSigningCurve -> EdSigningCurve
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) -> EdSigningCurve -> u
forall u. (forall d. Data d => d -> u) -> EdSigningCurve -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EdSigningCurve
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EdSigningCurve -> c EdSigningCurve
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EdSigningCurve)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EdSigningCurve)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EdSigningCurve -> c EdSigningCurve
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EdSigningCurve -> c EdSigningCurve
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EdSigningCurve
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EdSigningCurve
$ctoConstr :: EdSigningCurve -> Constr
toConstr :: EdSigningCurve -> Constr
$cdataTypeOf :: EdSigningCurve -> DataType
dataTypeOf :: EdSigningCurve -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EdSigningCurve)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EdSigningCurve)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EdSigningCurve)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EdSigningCurve)
$cgmapT :: (forall b. Data b => b -> b) -> EdSigningCurve -> EdSigningCurve
gmapT :: (forall b. Data b => b -> b) -> EdSigningCurve -> EdSigningCurve
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EdSigningCurve -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EdSigningCurve -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> EdSigningCurve -> [u]
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> EdSigningCurve -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> EdSigningCurve -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> EdSigningCurve -> m EdSigningCurve
Data, EdSigningCurve -> EdSigningCurve -> Bool
(EdSigningCurve -> EdSigningCurve -> Bool)
-> (EdSigningCurve -> EdSigningCurve -> Bool) -> Eq EdSigningCurve
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EdSigningCurve -> EdSigningCurve -> Bool
== :: EdSigningCurve -> EdSigningCurve -> Bool
$c/= :: EdSigningCurve -> EdSigningCurve -> Bool
/= :: EdSigningCurve -> EdSigningCurve -> Bool
Eq, (forall x. EdSigningCurve -> Rep EdSigningCurve x)
-> (forall x. Rep EdSigningCurve x -> EdSigningCurve)
-> Generic EdSigningCurve
forall x. Rep EdSigningCurve x -> EdSigningCurve
forall x. EdSigningCurve -> Rep EdSigningCurve x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EdSigningCurve -> Rep EdSigningCurve x
from :: forall x. EdSigningCurve -> Rep EdSigningCurve x
$cto :: forall x. Rep EdSigningCurve x -> EdSigningCurve
to :: forall x. Rep EdSigningCurve x -> EdSigningCurve
Generic, Eq EdSigningCurve
Eq EdSigningCurve =>
(EdSigningCurve -> EdSigningCurve -> Ordering)
-> (EdSigningCurve -> EdSigningCurve -> Bool)
-> (EdSigningCurve -> EdSigningCurve -> Bool)
-> (EdSigningCurve -> EdSigningCurve -> Bool)
-> (EdSigningCurve -> EdSigningCurve -> Bool)
-> (EdSigningCurve -> EdSigningCurve -> EdSigningCurve)
-> (EdSigningCurve -> EdSigningCurve -> EdSigningCurve)
-> Ord EdSigningCurve
EdSigningCurve -> EdSigningCurve -> Bool
EdSigningCurve -> EdSigningCurve -> Ordering
EdSigningCurve -> EdSigningCurve -> EdSigningCurve
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: EdSigningCurve -> EdSigningCurve -> Ordering
compare :: EdSigningCurve -> EdSigningCurve -> Ordering
$c< :: EdSigningCurve -> EdSigningCurve -> Bool
< :: EdSigningCurve -> EdSigningCurve -> Bool
$c<= :: EdSigningCurve -> EdSigningCurve -> Bool
<= :: EdSigningCurve -> EdSigningCurve -> Bool
$c> :: EdSigningCurve -> EdSigningCurve -> Bool
> :: EdSigningCurve -> EdSigningCurve -> Bool
$c>= :: EdSigningCurve -> EdSigningCurve -> Bool
>= :: EdSigningCurve -> EdSigningCurve -> Bool
$cmax :: EdSigningCurve -> EdSigningCurve -> EdSigningCurve
max :: EdSigningCurve -> EdSigningCurve -> EdSigningCurve
$cmin :: EdSigningCurve -> EdSigningCurve -> EdSigningCurve
min :: EdSigningCurve -> EdSigningCurve -> EdSigningCurve
Ord, Int -> EdSigningCurve -> ShowS
[EdSigningCurve] -> ShowS
EdSigningCurve -> String
(Int -> EdSigningCurve -> ShowS)
-> (EdSigningCurve -> String)
-> ([EdSigningCurve] -> ShowS)
-> Show EdSigningCurve
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EdSigningCurve -> ShowS
showsPrec :: Int -> EdSigningCurve -> ShowS
$cshow :: EdSigningCurve -> String
show :: EdSigningCurve -> String
$cshowList :: [EdSigningCurve] -> ShowS
showList :: [EdSigningCurve] -> ShowS
Show, Typeable)

instance Hashable EdSigningCurve

instance Pretty EdSigningCurve where
  pretty :: forall ann. EdSigningCurve -> Doc ann
pretty EdSigningCurve
Ed25519 = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"Ed25519"
  pretty EdSigningCurve
Ed448 = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"Ed448"

instance A.FromJSON EdSigningCurve

instance A.ToJSON EdSigningCurve

newtype EPoint =
  EPoint
    { EPoint -> Integer
unEPoint :: Integer
    }
  deriving (Typeable EPoint
Typeable EPoint =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> EPoint -> c EPoint)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EPoint)
-> (EPoint -> Constr)
-> (EPoint -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EPoint))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EPoint))
-> ((forall b. Data b => b -> b) -> EPoint -> EPoint)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EPoint -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EPoint -> r)
-> (forall u. (forall d. Data d => d -> u) -> EPoint -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> EPoint -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EPoint -> m EPoint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EPoint -> m EPoint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EPoint -> m EPoint)
-> Data EPoint
EPoint -> Constr
EPoint -> DataType
(forall b. Data b => b -> b) -> EPoint -> EPoint
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) -> EPoint -> u
forall u. (forall d. Data d => d -> u) -> EPoint -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EPoint -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EPoint -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EPoint
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EPoint -> c EPoint
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EPoint)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EPoint)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EPoint -> c EPoint
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EPoint -> c EPoint
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EPoint
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EPoint
$ctoConstr :: EPoint -> Constr
toConstr :: EPoint -> Constr
$cdataTypeOf :: EPoint -> DataType
dataTypeOf :: EPoint -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EPoint)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EPoint)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EPoint)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EPoint)
$cgmapT :: (forall b. Data b => b -> b) -> EPoint -> EPoint
gmapT :: (forall b. Data b => b -> b) -> EPoint -> EPoint
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EPoint -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EPoint -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EPoint -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EPoint -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EPoint -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> EPoint -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EPoint -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EPoint -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EPoint -> m EPoint
Data, EPoint -> EPoint -> Bool
(EPoint -> EPoint -> Bool)
-> (EPoint -> EPoint -> Bool) -> Eq EPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EPoint -> EPoint -> Bool
== :: EPoint -> EPoint -> Bool
$c/= :: EPoint -> EPoint -> Bool
/= :: EPoint -> EPoint -> Bool
Eq, (forall x. EPoint -> Rep EPoint x)
-> (forall x. Rep EPoint x -> EPoint) -> Generic EPoint
forall x. Rep EPoint x -> EPoint
forall x. EPoint -> Rep EPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EPoint -> Rep EPoint x
from :: forall x. EPoint -> Rep EPoint x
$cto :: forall x. Rep EPoint x -> EPoint
to :: forall x. Rep EPoint x -> EPoint
Generic, Eq EPoint
Eq EPoint =>
(EPoint -> EPoint -> Ordering)
-> (EPoint -> EPoint -> Bool)
-> (EPoint -> EPoint -> Bool)
-> (EPoint -> EPoint -> Bool)
-> (EPoint -> EPoint -> Bool)
-> (EPoint -> EPoint -> EPoint)
-> (EPoint -> EPoint -> EPoint)
-> Ord EPoint
EPoint -> EPoint -> Bool
EPoint -> EPoint -> Ordering
EPoint -> EPoint -> EPoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: EPoint -> EPoint -> Ordering
compare :: EPoint -> EPoint -> Ordering
$c< :: EPoint -> EPoint -> Bool
< :: EPoint -> EPoint -> Bool
$c<= :: EPoint -> EPoint -> Bool
<= :: EPoint -> EPoint -> Bool
$c> :: EPoint -> EPoint -> Bool
> :: EPoint -> EPoint -> Bool
$c>= :: EPoint -> EPoint -> Bool
>= :: EPoint -> EPoint -> Bool
$cmax :: EPoint -> EPoint -> EPoint
max :: EPoint -> EPoint -> EPoint
$cmin :: EPoint -> EPoint -> EPoint
min :: EPoint -> EPoint -> EPoint
Ord, (forall ann. EPoint -> Doc ann)
-> (forall ann. [EPoint] -> Doc ann) -> Pretty EPoint
forall ann. [EPoint] -> Doc ann
forall ann. EPoint -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. EPoint -> Doc ann
pretty :: forall ann. EPoint -> Doc ann
$cprettyList :: forall ann. [EPoint] -> Doc ann
prettyList :: forall ann. [EPoint] -> Doc ann
Pretty, Int -> EPoint -> ShowS
[EPoint] -> ShowS
EPoint -> String
(Int -> EPoint -> ShowS)
-> (EPoint -> String) -> ([EPoint] -> ShowS) -> Show EPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EPoint -> ShowS
showsPrec :: Int -> EPoint -> ShowS
$cshow :: EPoint -> String
show :: EPoint -> String
$cshowList :: [EPoint] -> ShowS
showList :: [EPoint] -> ShowS
Show, Typeable)

instance Hashable EPoint

instance A.FromJSON EPoint

instance A.ToJSON EPoint

data EdPoint
  = PrefixedNativeEPoint EPoint
  | NativeEPoint EPoint
  deriving (Typeable EdPoint
Typeable EdPoint =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> EdPoint -> c EdPoint)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c EdPoint)
-> (EdPoint -> Constr)
-> (EdPoint -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c EdPoint))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EdPoint))
-> ((forall b. Data b => b -> b) -> EdPoint -> EdPoint)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> EdPoint -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> EdPoint -> r)
-> (forall u. (forall d. Data d => d -> u) -> EdPoint -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> EdPoint -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> EdPoint -> m EdPoint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EdPoint -> m EdPoint)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> EdPoint -> m EdPoint)
-> Data EdPoint
EdPoint -> Constr
EdPoint -> DataType
(forall b. Data b => b -> b) -> EdPoint -> EdPoint
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) -> EdPoint -> u
forall u. (forall d. Data d => d -> u) -> EdPoint -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EdPoint -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EdPoint -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EdPoint
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EdPoint -> c EdPoint
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EdPoint)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EdPoint)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EdPoint -> c EdPoint
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EdPoint -> c EdPoint
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EdPoint
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EdPoint
$ctoConstr :: EdPoint -> Constr
toConstr :: EdPoint -> Constr
$cdataTypeOf :: EdPoint -> DataType
dataTypeOf :: EdPoint -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EdPoint)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EdPoint)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EdPoint)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EdPoint)
$cgmapT :: (forall b. Data b => b -> b) -> EdPoint -> EdPoint
gmapT :: (forall b. Data b => b -> b) -> EdPoint -> EdPoint
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EdPoint -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EdPoint -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EdPoint -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EdPoint -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EdPoint -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> EdPoint -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EdPoint -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EdPoint -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EdPoint -> m EdPoint
Data, EdPoint -> EdPoint -> Bool
(EdPoint -> EdPoint -> Bool)
-> (EdPoint -> EdPoint -> Bool) -> Eq EdPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EdPoint -> EdPoint -> Bool
== :: EdPoint -> EdPoint -> Bool
$c/= :: EdPoint -> EdPoint -> Bool
/= :: EdPoint -> EdPoint -> Bool
Eq, (forall x. EdPoint -> Rep EdPoint x)
-> (forall x. Rep EdPoint x -> EdPoint) -> Generic EdPoint
forall x. Rep EdPoint x -> EdPoint
forall x. EdPoint -> Rep EdPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EdPoint -> Rep EdPoint x
from :: forall x. EdPoint -> Rep EdPoint x
$cto :: forall x. Rep EdPoint x -> EdPoint
to :: forall x. Rep EdPoint x -> EdPoint
Generic, Eq EdPoint
Eq EdPoint =>
(EdPoint -> EdPoint -> Ordering)
-> (EdPoint -> EdPoint -> Bool)
-> (EdPoint -> EdPoint -> Bool)
-> (EdPoint -> EdPoint -> Bool)
-> (EdPoint -> EdPoint -> Bool)
-> (EdPoint -> EdPoint -> EdPoint)
-> (EdPoint -> EdPoint -> EdPoint)
-> Ord EdPoint
EdPoint -> EdPoint -> Bool
EdPoint -> EdPoint -> Ordering
EdPoint -> EdPoint -> EdPoint
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: EdPoint -> EdPoint -> Ordering
compare :: EdPoint -> EdPoint -> Ordering
$c< :: EdPoint -> EdPoint -> Bool
< :: EdPoint -> EdPoint -> Bool
$c<= :: EdPoint -> EdPoint -> Bool
<= :: EdPoint -> EdPoint -> Bool
$c> :: EdPoint -> EdPoint -> Bool
> :: EdPoint -> EdPoint -> Bool
$c>= :: EdPoint -> EdPoint -> Bool
>= :: EdPoint -> EdPoint -> Bool
$cmax :: EdPoint -> EdPoint -> EdPoint
max :: EdPoint -> EdPoint -> EdPoint
$cmin :: EdPoint -> EdPoint -> EdPoint
min :: EdPoint -> EdPoint -> EdPoint
Ord, Int -> EdPoint -> ShowS
[EdPoint] -> ShowS
EdPoint -> String
(Int -> EdPoint -> ShowS)
-> (EdPoint -> String) -> ([EdPoint] -> ShowS) -> Show EdPoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EdPoint -> ShowS
showsPrec :: Int -> EdPoint -> ShowS
$cshow :: EdPoint -> String
show :: EdPoint -> String
$cshowList :: [EdPoint] -> ShowS
showList :: [EdPoint] -> ShowS
Show, Typeable)

instance Hashable EdPoint

instance Pretty EdPoint where
  pretty :: forall ann. EdPoint -> Doc ann
pretty (PrefixedNativeEPoint EPoint
ep) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"prefixed-native" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> EPoint -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. EPoint -> Doc ann
pretty EPoint
ep
  pretty (NativeEPoint EPoint
ep) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"native" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> EPoint -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. EPoint -> Doc ann
pretty EPoint
ep

instance A.FromJSON EdPoint

instance A.ToJSON EdPoint

data PKey
  = RSAPubKey RSA_PublicKey
  | DSAPubKey DSA_PublicKey
  | ElGamalPubKey Integer Integer Integer
  | ECDHPubKey PKey HashAlgorithm SymmetricAlgorithm
  | ECDSAPubKey ECDSA_PublicKey
  | EdDSAPubKey EdSigningCurve EdPoint
  | UnknownPKey ByteString
  deriving (Typeable PKey
Typeable PKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> PKey -> c PKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PKey)
-> (PKey -> Constr)
-> (PKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PKey))
-> ((forall b. Data b => b -> b) -> PKey -> PKey)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r)
-> (forall u. (forall d. Data d => d -> u) -> PKey -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> PKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PKey -> m PKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PKey -> m PKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PKey -> m PKey)
-> Data PKey
PKey -> Constr
PKey -> DataType
(forall b. Data b => b -> b) -> PKey -> PKey
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) -> PKey -> u
forall u. (forall d. Data d => d -> u) -> PKey -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PKey -> c PKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PKey -> c PKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PKey -> c PKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PKey
$ctoConstr :: PKey -> Constr
toConstr :: PKey -> Constr
$cdataTypeOf :: PKey -> DataType
dataTypeOf :: PKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c PKey)
$cgmapT :: (forall b. Data b => b -> b) -> PKey -> PKey
gmapT :: (forall b. Data b => b -> b) -> PKey -> PKey
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PKey -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PKey -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PKey -> m PKey
Data, PKey -> PKey -> Bool
(PKey -> PKey -> Bool) -> (PKey -> PKey -> Bool) -> Eq PKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PKey -> PKey -> Bool
== :: PKey -> PKey -> Bool
$c/= :: PKey -> PKey -> Bool
/= :: PKey -> PKey -> Bool
Eq, (forall x. PKey -> Rep PKey x)
-> (forall x. Rep PKey x -> PKey) -> Generic PKey
forall x. Rep PKey x -> PKey
forall x. PKey -> Rep PKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PKey -> Rep PKey x
from :: forall x. PKey -> Rep PKey x
$cto :: forall x. Rep PKey x -> PKey
to :: forall x. Rep PKey x -> PKey
Generic, Eq PKey
Eq PKey =>
(PKey -> PKey -> Ordering)
-> (PKey -> PKey -> Bool)
-> (PKey -> PKey -> Bool)
-> (PKey -> PKey -> Bool)
-> (PKey -> PKey -> Bool)
-> (PKey -> PKey -> PKey)
-> (PKey -> PKey -> PKey)
-> Ord PKey
PKey -> PKey -> Bool
PKey -> PKey -> Ordering
PKey -> PKey -> PKey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PKey -> PKey -> Ordering
compare :: PKey -> PKey -> Ordering
$c< :: PKey -> PKey -> Bool
< :: PKey -> PKey -> Bool
$c<= :: PKey -> PKey -> Bool
<= :: PKey -> PKey -> Bool
$c> :: PKey -> PKey -> Bool
> :: PKey -> PKey -> Bool
$c>= :: PKey -> PKey -> Bool
>= :: PKey -> PKey -> Bool
$cmax :: PKey -> PKey -> PKey
max :: PKey -> PKey -> PKey
$cmin :: PKey -> PKey -> PKey
min :: PKey -> PKey -> PKey
Ord, Int -> PKey -> ShowS
[PKey] -> ShowS
PKey -> String
(Int -> PKey -> ShowS)
-> (PKey -> String) -> ([PKey] -> ShowS) -> Show PKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PKey -> ShowS
showsPrec :: Int -> PKey -> ShowS
$cshow :: PKey -> String
show :: PKey -> String
$cshowList :: [PKey] -> ShowS
showList :: [PKey] -> ShowS
Show, Typeable)

instance Hashable PKey

instance Pretty PKey where
  pretty :: forall ann. PKey -> Doc ann
pretty (RSAPubKey RSA_PublicKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"RSA" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> RSA_PublicKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. RSA_PublicKey -> Doc ann
pretty RSA_PublicKey
p
  pretty (DSAPubKey DSA_PublicKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"DSA" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> DSA_PublicKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. DSA_PublicKey -> Doc ann
pretty DSA_PublicKey
p
  pretty (ElGamalPubKey Integer
p Integer
g Integer
y) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"Elgamal" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
p Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
g Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
y
  pretty (ECDHPubKey PKey
p HashAlgorithm
ha SymmetricAlgorithm
sa) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"ECDH" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> PKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. PKey -> Doc ann
pretty PKey
p 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
<+> SymmetricAlgorithm -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. SymmetricAlgorithm -> Doc ann
pretty SymmetricAlgorithm
sa
  pretty (ECDSAPubKey ECDSA_PublicKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"ECDSA" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ECDSA_PublicKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ECDSA_PublicKey -> Doc ann
pretty ECDSA_PublicKey
p
  pretty (EdDSAPubKey EdSigningCurve
c EdPoint
ep) = EdSigningCurve -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. EdSigningCurve -> Doc ann
pretty EdSigningCurve
c Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> EdPoint -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. EdPoint -> Doc ann
pretty EdPoint
ep
  pretty (UnknownPKey ByteString
bs) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"<unknown>" 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 PKey where
  toJSON :: PKey -> Value
toJSON (RSAPubKey RSA_PublicKey
p) = RSA_PublicKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON RSA_PublicKey
p
  toJSON (DSAPubKey DSA_PublicKey
p) = DSA_PublicKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON DSA_PublicKey
p
  toJSON (ElGamalPubKey Integer
p Integer
g Integer
y) = (Integer, Integer, Integer) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (Integer
p, Integer
g, Integer
y)
  toJSON (ECDHPubKey PKey
p HashAlgorithm
ha SymmetricAlgorithm
sa) = (PKey, HashAlgorithm, SymmetricAlgorithm) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (PKey
p, HashAlgorithm
ha, SymmetricAlgorithm
sa)
  toJSON (ECDSAPubKey ECDSA_PublicKey
p) = ECDSA_PublicKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON ECDSA_PublicKey
p
  toJSON (EdDSAPubKey EdSigningCurve
c EdPoint
ep) = (EdSigningCurve, EdPoint) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (EdSigningCurve
c, EdPoint
ep)
  toJSON (UnknownPKey ByteString
bs) = [Word8] -> Value
forall a. ToJSON a => a -> Value
A.toJSON (ByteString -> [Word8]
BL.unpack ByteString
bs)

data SKey
  = RSAPrivateKey RSA_PrivateKey
  | DSAPrivateKey DSA_PrivateKey
  | ElGamalPrivateKey Integer
  | ECDHPrivateKey ECDSA_PrivateKey
  | ECDSAPrivateKey ECDSA_PrivateKey
  | EdDSAPrivateKey EdSigningCurve B.ByteString
  | X25519PrivateKey B.ByteString
  | X448PrivateKey B.ByteString
  | UnknownSKey ByteString
  deriving (Typeable SKey
Typeable SKey =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> SKey -> c SKey)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SKey)
-> (SKey -> Constr)
-> (SKey -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SKey))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKey))
-> ((forall b. Data b => b -> b) -> SKey -> SKey)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r)
-> (forall u. (forall d. Data d => d -> u) -> SKey -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> SKey -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SKey -> m SKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SKey -> m SKey)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SKey -> m SKey)
-> Data SKey
SKey -> Constr
SKey -> DataType
(forall b. Data b => b -> b) -> SKey -> SKey
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) -> SKey -> u
forall u. (forall d. Data d => d -> u) -> SKey -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SKey
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SKey -> c SKey
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SKey)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKey)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SKey -> c SKey
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SKey -> c SKey
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SKey
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SKey
$ctoConstr :: SKey -> Constr
toConstr :: SKey -> Constr
$cdataTypeOf :: SKey -> DataType
dataTypeOf :: SKey -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SKey)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SKey)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKey)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKey)
$cgmapT :: (forall b. Data b => b -> b) -> SKey -> SKey
gmapT :: (forall b. Data b => b -> b) -> SKey -> SKey
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SKey -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SKey -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> SKey -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SKey -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SKey -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKey -> m SKey
Data, SKey -> SKey -> Bool
(SKey -> SKey -> Bool) -> (SKey -> SKey -> Bool) -> Eq SKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SKey -> SKey -> Bool
== :: SKey -> SKey -> Bool
$c/= :: SKey -> SKey -> Bool
/= :: SKey -> SKey -> Bool
Eq, (forall x. SKey -> Rep SKey x)
-> (forall x. Rep SKey x -> SKey) -> Generic SKey
forall x. Rep SKey x -> SKey
forall x. SKey -> Rep SKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SKey -> Rep SKey x
from :: forall x. SKey -> Rep SKey x
$cto :: forall x. Rep SKey x -> SKey
to :: forall x. Rep SKey x -> SKey
Generic, Int -> SKey -> ShowS
[SKey] -> ShowS
SKey -> String
(Int -> SKey -> ShowS)
-> (SKey -> String) -> ([SKey] -> ShowS) -> Show SKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SKey -> ShowS
showsPrec :: Int -> SKey -> ShowS
$cshow :: SKey -> String
show :: SKey -> String
$cshowList :: [SKey] -> ShowS
showList :: [SKey] -> ShowS
Show, Typeable)

instance Hashable SKey

instance Ord SKey where
  compare :: SKey -> SKey -> Ordering
compare (RSAPrivateKey RSA_PrivateKey
rsa1) (RSAPrivateKey RSA_PrivateKey
rsa2) = RSA_PrivateKey -> RSA_PrivateKey -> Ordering
forall a. Ord a => a -> a -> Ordering
compare RSA_PrivateKey
rsa1 RSA_PrivateKey
rsa2
  compare (DSAPrivateKey DSA_PrivateKey
dsa1) (DSAPrivateKey DSA_PrivateKey
dsa2) = DSA_PrivateKey -> DSA_PrivateKey -> Ordering
forall a. Ord a => a -> a -> Ordering
compare DSA_PrivateKey
dsa1 DSA_PrivateKey
dsa2
  compare (ElGamalPrivateKey Integer
x1) (ElGamalPrivateKey Integer
x2) = Integer -> Integer -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Integer
x1 Integer
x2
  compare (ECDHPrivateKey ECDSA_PrivateKey
ecdsa1) (ECDHPrivateKey ECDSA_PrivateKey
ecdsa2) = ECDSA_PrivateKey -> ECDSA_PrivateKey -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ECDSA_PrivateKey
ecdsa1 ECDSA_PrivateKey
ecdsa2
  compare (ECDSAPrivateKey ECDSA_PrivateKey
ecdsa1) (ECDSAPrivateKey ECDSA_PrivateKey
ecdsa2) = ECDSA_PrivateKey -> ECDSA_PrivateKey -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ECDSA_PrivateKey
ecdsa1 ECDSA_PrivateKey
ecdsa2
  compare (EdDSAPrivateKey EdSigningCurve
curve1 ByteString
bs1) (EdDSAPrivateKey EdSigningCurve
curve2 ByteString
bs2) =
    EdSigningCurve -> EdSigningCurve -> Ordering
forall a. Ord a => a -> a -> Ordering
compare EdSigningCurve
curve1 EdSigningCurve
curve2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (X25519PrivateKey ByteString
bs1) (X25519PrivateKey ByteString
bs2) = ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (X448PrivateKey ByteString
bs1) (X448PrivateKey ByteString
bs2) = ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (UnknownSKey ByteString
bs1) (UnknownSKey ByteString
bs2) = ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare RSAPrivateKey {} DSAPrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} ElGamalPrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} ECDHPrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} ECDSAPrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} EdDSAPrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} X25519PrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} X448PrivateKey {} = Ordering
LT
  compare RSAPrivateKey {} UnknownSKey {} = Ordering
LT
  compare DSAPrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare DSAPrivateKey {} ElGamalPrivateKey {} = Ordering
LT
  compare DSAPrivateKey {} ECDHPrivateKey {} = Ordering
LT
  compare DSAPrivateKey {} ECDSAPrivateKey {} = Ordering
LT
  compare DSAPrivateKey {} EdDSAPrivateKey {} = Ordering
LT
  compare DSAPrivateKey {} X25519PrivateKey {} = Ordering
LT
  compare DSAPrivateKey {} X448PrivateKey {} = Ordering
LT
  compare DSAPrivateKey {} UnknownSKey {} = Ordering
LT
  compare ElGamalPrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare ElGamalPrivateKey {} DSAPrivateKey {} = Ordering
GT
  compare ElGamalPrivateKey {} ECDHPrivateKey {} = Ordering
LT
  compare ElGamalPrivateKey {} ECDSAPrivateKey {} = Ordering
LT
  compare ElGamalPrivateKey {} EdDSAPrivateKey {} = Ordering
LT
  compare ElGamalPrivateKey {} X25519PrivateKey {} = Ordering
LT
  compare ElGamalPrivateKey {} X448PrivateKey {} = Ordering
LT
  compare ElGamalPrivateKey {} UnknownSKey {} = Ordering
LT
  compare ECDHPrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare ECDHPrivateKey {} DSAPrivateKey {} = Ordering
GT
  compare ECDHPrivateKey {} ElGamalPrivateKey {} = Ordering
GT
  compare ECDHPrivateKey {} ECDSAPrivateKey {} = Ordering
LT
  compare ECDHPrivateKey {} EdDSAPrivateKey {} = Ordering
LT
  compare ECDHPrivateKey {} X25519PrivateKey {} = Ordering
LT
  compare ECDHPrivateKey {} X448PrivateKey {} = Ordering
LT
  compare ECDHPrivateKey {} UnknownSKey {} = Ordering
LT
  compare ECDSAPrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare ECDSAPrivateKey {} DSAPrivateKey {} = Ordering
GT
  compare ECDSAPrivateKey {} ElGamalPrivateKey {} = Ordering
GT
  compare ECDSAPrivateKey {} ECDHPrivateKey {} = Ordering
GT
  compare ECDSAPrivateKey {} EdDSAPrivateKey {} = Ordering
LT
  compare ECDSAPrivateKey {} X25519PrivateKey {} = Ordering
LT
  compare ECDSAPrivateKey {} X448PrivateKey {} = Ordering
LT
  compare ECDSAPrivateKey {} UnknownSKey {} = Ordering
LT
  compare EdDSAPrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare EdDSAPrivateKey {} DSAPrivateKey {} = Ordering
GT
  compare EdDSAPrivateKey {} ElGamalPrivateKey {} = Ordering
GT
  compare EdDSAPrivateKey {} ECDHPrivateKey {} = Ordering
GT
  compare EdDSAPrivateKey {} ECDSAPrivateKey {} = Ordering
GT
  compare EdDSAPrivateKey {} X25519PrivateKey {} = Ordering
LT
  compare EdDSAPrivateKey {} X448PrivateKey {} = Ordering
LT
  compare EdDSAPrivateKey {} UnknownSKey {} = Ordering
LT
  compare X25519PrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare X25519PrivateKey {} DSAPrivateKey {} = Ordering
GT
  compare X25519PrivateKey {} ElGamalPrivateKey {} = Ordering
GT
  compare X25519PrivateKey {} ECDHPrivateKey {} = Ordering
GT
  compare X25519PrivateKey {} ECDSAPrivateKey {} = Ordering
GT
  compare X25519PrivateKey {} EdDSAPrivateKey {} = Ordering
GT
  compare X25519PrivateKey {} X448PrivateKey {} = Ordering
LT
  compare X25519PrivateKey {} UnknownSKey {} = Ordering
LT
  compare X448PrivateKey {} RSAPrivateKey {} = Ordering
GT
  compare X448PrivateKey {} DSAPrivateKey {} = Ordering
GT
  compare X448PrivateKey {} ElGamalPrivateKey {} = Ordering
GT
  compare X448PrivateKey {} ECDHPrivateKey {} = Ordering
GT
  compare X448PrivateKey {} ECDSAPrivateKey {} = Ordering
GT
  compare X448PrivateKey {} EdDSAPrivateKey {} = Ordering
GT
  compare X448PrivateKey {} X25519PrivateKey {} = Ordering
GT
  compare X448PrivateKey {} UnknownSKey {} = Ordering
LT
  compare UnknownSKey {} SKey
_ = Ordering
GT

instance Pretty SKey where
  pretty :: forall ann. SKey -> Doc ann
pretty (RSAPrivateKey RSA_PrivateKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"RSA" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> RSA_PrivateKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. RSA_PrivateKey -> Doc ann
pretty RSA_PrivateKey
p
  pretty (DSAPrivateKey DSA_PrivateKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"DSA" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> DSA_PrivateKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. DSA_PrivateKey -> Doc ann
pretty DSA_PrivateKey
p
  pretty (ElGamalPrivateKey Integer
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"Elgamal" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
p
  pretty (ECDHPrivateKey ECDSA_PrivateKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"ECDH" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ECDSA_PrivateKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ECDSA_PrivateKey -> Doc ann
pretty ECDSA_PrivateKey
p
  pretty (ECDSAPrivateKey ECDSA_PrivateKey
p) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"ECDSA" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> ECDSA_PrivateKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. ECDSA_PrivateKey -> Doc ann
pretty ECDSA_PrivateKey
p
  pretty (EdDSAPrivateKey EdSigningCurve
c ByteString
bs) =
    EdSigningCurve -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. EdSigningCurve -> Doc ann
pretty EdSigningCurve
c 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 -> ByteString
BL.fromStrict ByteString
bs))
  pretty (X25519PrivateKey ByteString
bs) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"X25519" 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 -> ByteString
BL.fromStrict ByteString
bs))
  pretty (X448PrivateKey ByteString
bs) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"X448" 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 -> ByteString
BL.fromStrict ByteString
bs))
  pretty (UnknownSKey ByteString
bs) = String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"<unknown>" 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 SKey where
  toJSON :: SKey -> Value
toJSON (RSAPrivateKey RSA_PrivateKey
k) = RSA_PrivateKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON RSA_PrivateKey
k
  toJSON (DSAPrivateKey DSA_PrivateKey
k) = DSA_PrivateKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON DSA_PrivateKey
k
  toJSON (ElGamalPrivateKey Integer
k) = Integer -> Value
forall a. ToJSON a => a -> Value
A.toJSON Integer
k
  toJSON (ECDHPrivateKey ECDSA_PrivateKey
k) = ECDSA_PrivateKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON ECDSA_PrivateKey
k
  toJSON (ECDSAPrivateKey ECDSA_PrivateKey
k) = ECDSA_PrivateKey -> Value
forall a. ToJSON a => a -> Value
A.toJSON ECDSA_PrivateKey
k
  toJSON (EdDSAPrivateKey EdSigningCurve
c ByteString
bs) = (EdSigningCurve, [Word8]) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (EdSigningCurve
c, ByteString -> [Word8]
B.unpack ByteString
bs)
  toJSON (X25519PrivateKey ByteString
bs) = [Word8] -> Value
forall a. ToJSON a => a -> Value
A.toJSON (ByteString -> [Word8]
B.unpack ByteString
bs)
  toJSON (X448PrivateKey ByteString
bs) = [Word8] -> Value
forall a. ToJSON a => a -> Value
A.toJSON (ByteString -> [Word8]
B.unpack ByteString
bs)
  toJSON (UnknownSKey ByteString
bs) = [Word8] -> Value
forall a. ToJSON a => a -> Value
A.toJSON (ByteString -> [Word8]
BL.unpack ByteString
bs)

data PKPayload (v :: KeyVersion) where
  PKPayloadV3 ::
       ThirtyTwoBitTimeStamp
    -> V3Expiration
    -> PubKeyAlgorithm
    -> PKey
    -> PKPayload 'DeprecatedV3
  PKPayloadV4 ::
       ThirtyTwoBitTimeStamp
    -> PubKeyAlgorithm
    -> PKey
    -> PKPayload 'V4
  PKPayloadV6 ::
       ThirtyTwoBitTimeStamp
    -> PubKeyAlgorithm
    -> PKey
    -> PKPayload 'V6

deriving instance Eq (PKPayload v)
deriving instance Ord (PKPayload v)
deriving instance Show (PKPayload v)

instance Hashable (PKPayload v) where
  hashWithSalt :: Int -> PKPayload v -> Int
hashWithSalt Int
s = Int
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
-> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
s ((KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
 -> Int)
-> (PKPayload v
    -> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
        PKey))
-> PKPayload v
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
forall (v :: KeyVersion).
PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
pkPayloadFields

instance Pretty (PKPayload v) where
  pretty :: forall ann. PKPayload v -> Doc ann
pretty PKPayload v
pkp =
    let (KeyVersion
kv, ThirtyTwoBitTimeStamp
ts, Word16
v3e, PubKeyAlgorithm
pka, PKey
p) = PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
forall (v :: KeyVersion).
PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
pkPayloadFields PKPayload v
pkp
     in KeyVersion -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. KeyVersion -> Doc ann
pretty KeyVersion
kv 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
<+> Word16 -> Doc ann
forall ann. Word16 -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Word16
v3e 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
<+> PKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. PKey -> Doc ann
pretty PKey
p

instance A.ToJSON (PKPayload v) where
  toJSON :: PKPayload v -> Value
toJSON = (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
-> Value
forall a. ToJSON a => a -> Value
A.toJSON ((KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
 -> Value)
-> (PKPayload v
    -> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
        PKey))
-> PKPayload v
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
forall (v :: KeyVersion).
PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
pkPayloadFields

data SomePKPayload where
  SomePKPayload :: PKPayload v -> SomePKPayload

deriving instance Show SomePKPayload
deriving instance Typeable SomePKPayload

pkPayloadDataType :: DData.DataType
pkPayloadDataType :: DataType
pkPayloadDataType =
  String -> [Constr] -> DataType
DData.mkDataType
    String
"Codec.Encryption.OpenPGP.Types.Internal.PKITypes.SomePKPayload"
    [Constr
pkPayloadConstr]

pkPayloadConstr :: DData.Constr
pkPayloadConstr :: Constr
pkPayloadConstr = DataType -> String -> [String] -> Fixity -> Constr
DData.mkConstr DataType
pkPayloadDataType String
"PKPayload" [] Fixity
DData.Prefix

instance Data SomePKPayload where
  gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SomePKPayload -> c SomePKPayload
gfoldl forall d b. Data d => c (d -> b) -> d -> c b
f forall g. g -> c g
z (PKPayload KeyVersion
kv ThirtyTwoBitTimeStamp
ts Word16
v3e PubKeyAlgorithm
pka PKey
p) =
    (KeyVersion
 -> ThirtyTwoBitTimeStamp
 -> Word16
 -> PubKeyAlgorithm
 -> PKey
 -> SomePKPayload)
-> c (KeyVersion
      -> ThirtyTwoBitTimeStamp
      -> Word16
      -> PubKeyAlgorithm
      -> PKey
      -> SomePKPayload)
forall g. g -> c g
z KeyVersion
-> ThirtyTwoBitTimeStamp
-> Word16
-> PubKeyAlgorithm
-> PKey
-> SomePKPayload
PKPayload c (KeyVersion
   -> ThirtyTwoBitTimeStamp
   -> Word16
   -> PubKeyAlgorithm
   -> PKey
   -> SomePKPayload)
-> KeyVersion
-> c (ThirtyTwoBitTimeStamp
      -> Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
forall d b. Data d => c (d -> b) -> d -> c b
`f` KeyVersion
kv c (ThirtyTwoBitTimeStamp
   -> Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
-> ThirtyTwoBitTimeStamp
-> c (Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
forall d b. Data d => c (d -> b) -> d -> c b
`f` ThirtyTwoBitTimeStamp
ts c (Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
-> Word16 -> c (PubKeyAlgorithm -> PKey -> SomePKPayload)
forall d b. Data d => c (d -> b) -> d -> c b
`f` Word16
v3e c (PubKeyAlgorithm -> PKey -> SomePKPayload)
-> PubKeyAlgorithm -> c (PKey -> SomePKPayload)
forall d b. Data d => c (d -> b) -> d -> c b
`f` PubKeyAlgorithm
pka c (PKey -> SomePKPayload) -> PKey -> c SomePKPayload
forall d b. Data d => c (d -> b) -> d -> c b
`f` PKey
p
  gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SomePKPayload
gunfold forall b r. Data b => c (b -> r) -> c r
k forall r. r -> c r
z Constr
c
    | Constr
c Constr -> Constr -> Bool
forall a. Eq a => a -> a -> Bool
== Constr
pkPayloadConstr = c (PKey -> SomePKPayload) -> c SomePKPayload
forall b r. Data b => c (b -> r) -> c r
k (c (PubKeyAlgorithm -> PKey -> SomePKPayload)
-> c (PKey -> SomePKPayload)
forall b r. Data b => c (b -> r) -> c r
k (c (Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
-> c (PubKeyAlgorithm -> PKey -> SomePKPayload)
forall b r. Data b => c (b -> r) -> c r
k (c (ThirtyTwoBitTimeStamp
   -> Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
-> c (Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
forall b r. Data b => c (b -> r) -> c r
k (c (KeyVersion
   -> ThirtyTwoBitTimeStamp
   -> Word16
   -> PubKeyAlgorithm
   -> PKey
   -> SomePKPayload)
-> c (ThirtyTwoBitTimeStamp
      -> Word16 -> PubKeyAlgorithm -> PKey -> SomePKPayload)
forall b r. Data b => c (b -> r) -> c r
k ((KeyVersion
 -> ThirtyTwoBitTimeStamp
 -> Word16
 -> PubKeyAlgorithm
 -> PKey
 -> SomePKPayload)
-> c (KeyVersion
      -> ThirtyTwoBitTimeStamp
      -> Word16
      -> PubKeyAlgorithm
      -> PKey
      -> SomePKPayload)
forall r. r -> c r
z KeyVersion
-> ThirtyTwoBitTimeStamp
-> Word16
-> PubKeyAlgorithm
-> PKey
-> SomePKPayload
PKPayload)))))
    | Bool
otherwise = String -> c SomePKPayload
forall a. HasCallStack => String -> a
error String
"gunfold: invalid constructor for SomePKPayload"
  toConstr :: SomePKPayload -> Constr
toConstr SomePKPayload
_ = Constr
pkPayloadConstr
  dataTypeOf :: SomePKPayload -> DataType
dataTypeOf SomePKPayload
_ = DataType
pkPayloadDataType

instance Eq SomePKPayload where
  SomePKPayload
a == :: SomePKPayload -> SomePKPayload -> Bool
== SomePKPayload
b = SomePKPayload
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
somePKPayloadFields SomePKPayload
a (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
-> Bool
forall a. Eq a => a -> a -> Bool
== SomePKPayload
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
somePKPayloadFields SomePKPayload
b

instance Ord SomePKPayload where
  compare :: SomePKPayload -> SomePKPayload -> Ordering
compare = (SomePKPayload
 -> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
     PKey))
-> SomePKPayload -> SomePKPayload -> Ordering
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing SomePKPayload
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
somePKPayloadFields

instance Hashable SomePKPayload where
  hashWithSalt :: Int -> SomePKPayload -> Int
hashWithSalt Int
s = Int
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
-> Int
forall a. Hashable a => Int -> a -> Int
hashWithSalt Int
s ((KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
 -> Int)
-> (SomePKPayload
    -> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
        PKey))
-> SomePKPayload
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomePKPayload
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
somePKPayloadFields

instance Pretty SomePKPayload where
  pretty :: forall ann. SomePKPayload -> Doc ann
pretty (PKPayload KeyVersion
kv ThirtyTwoBitTimeStamp
ts Word16
v3e PubKeyAlgorithm
pka PKey
p) =
    KeyVersion -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. KeyVersion -> Doc ann
pretty KeyVersion
kv 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
<+> Word16 -> Doc ann
forall ann. Word16 -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Word16
v3e 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
<+> PKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. PKey -> Doc ann
pretty PKey
p

instance A.ToJSON SomePKPayload where
  toJSON :: SomePKPayload -> Value
toJSON = (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
-> Value
forall a. ToJSON a => a -> Value
A.toJSON ((KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm, PKey)
 -> Value)
-> (SomePKPayload
    -> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
        PKey))
-> SomePKPayload
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomePKPayload
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
somePKPayloadFields

pkPayloadFields ::
     PKPayload v
  -> (KeyVersion, ThirtyTwoBitTimeStamp, V3Expiration, PubKeyAlgorithm, PKey)
pkPayloadFields :: forall (v :: KeyVersion).
PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
pkPayloadFields (PKPayloadV3 ThirtyTwoBitTimeStamp
ts Word16
v3e PubKeyAlgorithm
pka PKey
p) = (KeyVersion
DeprecatedV3, ThirtyTwoBitTimeStamp
ts, Word16
v3e, PubKeyAlgorithm
pka, PKey
p)
pkPayloadFields (PKPayloadV4 ThirtyTwoBitTimeStamp
ts PubKeyAlgorithm
pka PKey
p) = (KeyVersion
V4, ThirtyTwoBitTimeStamp
ts, Word16
0, PubKeyAlgorithm
pka, PKey
p)
pkPayloadFields (PKPayloadV6 ThirtyTwoBitTimeStamp
ts PubKeyAlgorithm
pka PKey
p) = (KeyVersion
V6, ThirtyTwoBitTimeStamp
ts, Word16
0, PubKeyAlgorithm
pka, PKey
p)

somePKPayloadFields ::
     SomePKPayload
  -> (KeyVersion, ThirtyTwoBitTimeStamp, V3Expiration, PubKeyAlgorithm, PKey)
somePKPayloadFields :: SomePKPayload
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
somePKPayloadFields (SomePKPayload PKPayload v
pkp) = PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
forall (v :: KeyVersion).
PKPayload v
-> (KeyVersion, ThirtyTwoBitTimeStamp, Word16, PubKeyAlgorithm,
    PKey)
pkPayloadFields PKPayload v
pkp

pattern PKPayload ::
     KeyVersion
  -> ThirtyTwoBitTimeStamp
  -> V3Expiration
  -> PubKeyAlgorithm
  -> PKey
  -> SomePKPayload
pattern $mPKPayload :: forall {r}.
SomePKPayload
-> (KeyVersion
    -> ThirtyTwoBitTimeStamp -> Word16 -> PubKeyAlgorithm -> PKey -> r)
-> ((# #) -> r)
-> r
$bPKPayload :: KeyVersion
-> ThirtyTwoBitTimeStamp
-> Word16
-> PubKeyAlgorithm
-> PKey
-> SomePKPayload
PKPayload kv ts v3e pka p <- (somePKPayloadFields -> (kv, ts, v3e, pka, p))
  where
    PKPayload KeyVersion
DeprecatedV3 ThirtyTwoBitTimeStamp
ts Word16
v3e PubKeyAlgorithm
pka PKey
p = PKPayload 'DeprecatedV3 -> SomePKPayload
forall (v :: KeyVersion). PKPayload v -> SomePKPayload
SomePKPayload (ThirtyTwoBitTimeStamp
-> Word16 -> PubKeyAlgorithm -> PKey -> PKPayload 'DeprecatedV3
PKPayloadV3 ThirtyTwoBitTimeStamp
ts Word16
v3e PubKeyAlgorithm
pka PKey
p)
    PKPayload KeyVersion
V4 ThirtyTwoBitTimeStamp
ts Word16
_ PubKeyAlgorithm
pka PKey
p = PKPayload 'V4 -> SomePKPayload
forall (v :: KeyVersion). PKPayload v -> SomePKPayload
SomePKPayload (ThirtyTwoBitTimeStamp -> PubKeyAlgorithm -> PKey -> PKPayload 'V4
PKPayloadV4 ThirtyTwoBitTimeStamp
ts PubKeyAlgorithm
pka PKey
p)
    PKPayload KeyVersion
V6 ThirtyTwoBitTimeStamp
ts Word16
_ PubKeyAlgorithm
pka PKey
p = PKPayload 'V6 -> SomePKPayload
forall (v :: KeyVersion). PKPayload v -> SomePKPayload
SomePKPayload (ThirtyTwoBitTimeStamp -> PubKeyAlgorithm -> PKey -> PKPayload 'V6
PKPayloadV6 ThirtyTwoBitTimeStamp
ts PubKeyAlgorithm
pka PKey
p)

{-# COMPLETE PKPayload #-}

_keyVersion :: SomePKPayload -> KeyVersion
_keyVersion :: SomePKPayload -> KeyVersion
_keyVersion (PKPayload KeyVersion
kv ThirtyTwoBitTimeStamp
_ Word16
_ PubKeyAlgorithm
_ PKey
_) = KeyVersion
kv

_timestamp :: SomePKPayload -> ThirtyTwoBitTimeStamp
_timestamp :: SomePKPayload -> ThirtyTwoBitTimeStamp
_timestamp (PKPayload KeyVersion
_ ThirtyTwoBitTimeStamp
ts Word16
_ PubKeyAlgorithm
_ PKey
_) = ThirtyTwoBitTimeStamp
ts

_v3exp :: SomePKPayload -> V3Expiration
_v3exp :: SomePKPayload -> Word16
_v3exp (PKPayload KeyVersion
_ ThirtyTwoBitTimeStamp
_ Word16
v3e PubKeyAlgorithm
_ PKey
_) = Word16
v3e

_pkalgo :: SomePKPayload -> PubKeyAlgorithm
_pkalgo :: SomePKPayload -> PubKeyAlgorithm
_pkalgo (PKPayload KeyVersion
_ ThirtyTwoBitTimeStamp
_ Word16
_ PubKeyAlgorithm
pka PKey
_) = PubKeyAlgorithm
pka

_pubkey :: SomePKPayload -> PKey
_pubkey :: SomePKPayload -> PKey
_pubkey (PKPayload KeyVersion
_ ThirtyTwoBitTimeStamp
_ Word16
_ PubKeyAlgorithm
_ PKey
p) = PKey
p

data SKAddendum
  = SUS16bit SymmetricAlgorithm S2K IV ByteString
  | SUSSHA1 SymmetricAlgorithm S2K IV ByteString
  | SUSAEAD SymmetricAlgorithm AEADAlgorithm S2K IV ByteString
  | SUSym SymmetricAlgorithm IV ByteString
  | SUUnencrypted SKey Word16
  deriving (Typeable SKAddendum
Typeable SKAddendum =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> SKAddendum -> c SKAddendum)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c SKAddendum)
-> (SKAddendum -> Constr)
-> (SKAddendum -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c SKAddendum))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c SKAddendum))
-> ((forall b. Data b => b -> b) -> SKAddendum -> SKAddendum)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> SKAddendum -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> SKAddendum -> r)
-> (forall u. (forall d. Data d => d -> u) -> SKAddendum -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> SKAddendum -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum)
-> Data SKAddendum
SKAddendum -> Constr
SKAddendum -> DataType
(forall b. Data b => b -> b) -> SKAddendum -> SKAddendum
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) -> SKAddendum -> u
forall u. (forall d. Data d => d -> u) -> SKAddendum -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SKAddendum -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SKAddendum -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SKAddendum
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SKAddendum -> c SKAddendum
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SKAddendum)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKAddendum)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SKAddendum -> c SKAddendum
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> SKAddendum -> c SKAddendum
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SKAddendum
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c SKAddendum
$ctoConstr :: SKAddendum -> Constr
toConstr :: SKAddendum -> Constr
$cdataTypeOf :: SKAddendum -> DataType
dataTypeOf :: SKAddendum -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SKAddendum)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c SKAddendum)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKAddendum)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SKAddendum)
$cgmapT :: (forall b. Data b => b -> b) -> SKAddendum -> SKAddendum
gmapT :: (forall b. Data b => b -> b) -> SKAddendum -> SKAddendum
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SKAddendum -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> SKAddendum -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SKAddendum -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> SKAddendum -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> SKAddendum -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> SKAddendum -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SKAddendum -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> SKAddendum -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> SKAddendum -> m SKAddendum
Data, SKAddendum -> SKAddendum -> Bool
(SKAddendum -> SKAddendum -> Bool)
-> (SKAddendum -> SKAddendum -> Bool) -> Eq SKAddendum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SKAddendum -> SKAddendum -> Bool
== :: SKAddendum -> SKAddendum -> Bool
$c/= :: SKAddendum -> SKAddendum -> Bool
/= :: SKAddendum -> SKAddendum -> Bool
Eq, (forall x. SKAddendum -> Rep SKAddendum x)
-> (forall x. Rep SKAddendum x -> SKAddendum) -> Generic SKAddendum
forall x. Rep SKAddendum x -> SKAddendum
forall x. SKAddendum -> Rep SKAddendum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. SKAddendum -> Rep SKAddendum x
from :: forall x. SKAddendum -> Rep SKAddendum x
$cto :: forall x. Rep SKAddendum x -> SKAddendum
to :: forall x. Rep SKAddendum x -> SKAddendum
Generic, Int -> SKAddendum -> ShowS
[SKAddendum] -> ShowS
SKAddendum -> String
(Int -> SKAddendum -> ShowS)
-> (SKAddendum -> String)
-> ([SKAddendum] -> ShowS)
-> Show SKAddendum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SKAddendum -> ShowS
showsPrec :: Int -> SKAddendum -> ShowS
$cshow :: SKAddendum -> String
show :: SKAddendum -> String
$cshowList :: [SKAddendum] -> ShowS
showList :: [SKAddendum] -> ShowS
Show, Typeable)

instance Ord SKAddendum where
  compare :: SKAddendum -> SKAddendum -> Ordering
compare (SUS16bit SymmetricAlgorithm
sa1 S2K
s2k1 IV
iv1 ByteString
bs1) (SUS16bit SymmetricAlgorithm
sa2 S2K
s2k2 IV
iv2 ByteString
bs2) =
    SymmetricAlgorithm -> SymmetricAlgorithm -> Ordering
forall a. Ord a => a -> a -> Ordering
compare SymmetricAlgorithm
sa1 SymmetricAlgorithm
sa2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> S2K -> S2K -> Ordering
forall a. Ord a => a -> a -> Ordering
compare S2K
s2k1 S2K
s2k2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> IV -> IV -> Ordering
forall a. Ord a => a -> a -> Ordering
compare IV
iv1 IV
iv2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (SUSSHA1 SymmetricAlgorithm
sa1 S2K
s2k1 IV
iv1 ByteString
bs1) (SUSSHA1 SymmetricAlgorithm
sa2 S2K
s2k2 IV
iv2 ByteString
bs2) =
    SymmetricAlgorithm -> SymmetricAlgorithm -> Ordering
forall a. Ord a => a -> a -> Ordering
compare SymmetricAlgorithm
sa1 SymmetricAlgorithm
sa2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> S2K -> S2K -> Ordering
forall a. Ord a => a -> a -> Ordering
compare S2K
s2k1 S2K
s2k2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> IV -> IV -> Ordering
forall a. Ord a => a -> a -> Ordering
compare IV
iv1 IV
iv2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (SUSAEAD SymmetricAlgorithm
sa1 AEADAlgorithm
aa1 S2K
s2k1 IV
iv1 ByteString
bs1) (SUSAEAD SymmetricAlgorithm
sa2 AEADAlgorithm
aa2 S2K
s2k2 IV
iv2 ByteString
bs2) =
    SymmetricAlgorithm -> SymmetricAlgorithm -> Ordering
forall a. Ord a => a -> a -> Ordering
compare SymmetricAlgorithm
sa1 SymmetricAlgorithm
sa2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> AEADAlgorithm -> AEADAlgorithm -> Ordering
forall a. Ord a => a -> a -> Ordering
compare AEADAlgorithm
aa1 AEADAlgorithm
aa2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> S2K -> S2K -> Ordering
forall a. Ord a => a -> a -> Ordering
compare S2K
s2k1 S2K
s2k2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> IV -> IV -> Ordering
forall a. Ord a => a -> a -> Ordering
compare IV
iv1 IV
iv2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<>
    ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (SUSym SymmetricAlgorithm
sa1 IV
iv1 ByteString
bs1) (SUSym SymmetricAlgorithm
sa2 IV
iv2 ByteString
bs2) =
    SymmetricAlgorithm -> SymmetricAlgorithm -> Ordering
forall a. Ord a => a -> a -> Ordering
compare SymmetricAlgorithm
sa1 SymmetricAlgorithm
sa2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> IV -> IV -> Ordering
forall a. Ord a => a -> a -> Ordering
compare IV
iv1 IV
iv2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> ByteString -> ByteString -> Ordering
forall a. Ord a => a -> a -> Ordering
compare ByteString
bs1 ByteString
bs2
  compare (SUUnencrypted SKey
sk1 Word16
ck1) (SUUnencrypted SKey
sk2 Word16
ck2) =
    SKey -> SKey -> Ordering
forall a. Ord a => a -> a -> Ordering
compare SKey
sk1 SKey
sk2 Ordering -> Ordering -> Ordering
forall a. Semigroup a => a -> a -> a
<> Word16 -> Word16 -> Ordering
forall a. Ord a => a -> a -> Ordering
compare Word16
ck1 Word16
ck2
  compare SUS16bit {} SUSSHA1 {} = Ordering
LT
  compare SUS16bit {} SUSAEAD {} = Ordering
LT
  compare SUS16bit {} SUSym {} = Ordering
LT
  compare SUS16bit {} SUUnencrypted {} = Ordering
LT
  compare SUSSHA1 {} SUS16bit {} = Ordering
GT
  compare SUSSHA1 {} SUSAEAD {} = Ordering
LT
  compare SUSSHA1 {} SUSym {} = Ordering
LT
  compare SUSSHA1 {} SUUnencrypted {} = Ordering
LT
  compare SUSAEAD {} SUS16bit {} = Ordering
GT
  compare SUSAEAD {} SUSSHA1 {} = Ordering
GT
  compare SUSAEAD {} SUSym {} = Ordering
LT
  compare SUSAEAD {} SUUnencrypted {} = Ordering
LT
  compare SUSym {} SUS16bit {} = Ordering
GT
  compare SUSym {} SUSSHA1 {} = Ordering
GT
  compare SUSym {} SUSAEAD {} = Ordering
GT
  compare SUSym {} SUUnencrypted {} = Ordering
LT
  compare SUUnencrypted {} SKAddendum
_ = Ordering
GT

instance Hashable SKAddendum

instance Pretty SKAddendum where
  pretty :: forall ann. SKAddendum -> Doc ann
pretty (SUS16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"SUS16bit" 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
<+> IV -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. IV -> Doc ann
pretty IV
iv 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 (SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"SUSSHA1" 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
<+> IV -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. IV -> Doc ann
pretty IV
iv 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 (SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"SUSAEAD" 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
<+> AEADAlgorithm -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. AEADAlgorithm -> Doc ann
pretty AEADAlgorithm
aa 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
<+> IV -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. IV -> Doc ann
pretty IV
iv 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 (SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"SUSym" 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
<+> IV -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. IV -> Doc ann
pretty IV
iv 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 (SUUnencrypted SKey
s Word16
ck) =
    String -> Doc ann
forall ann. String -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty String
"SUUnencrypted" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> SKey -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. SKey -> Doc ann
pretty SKey
s Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Word16 -> Doc ann
forall ann. Word16 -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Word16
ck

instance A.ToJSON SKAddendum where
  toJSON :: SKAddendum -> Value
toJSON (SUS16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) = (SymmetricAlgorithm, S2K, IV, [Word8]) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (SymmetricAlgorithm
sa, S2K
s2k, IV
iv, ByteString -> [Word8]
BL.unpack ByteString
bs)
  toJSON (SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) = (SymmetricAlgorithm, S2K, IV, [Word8]) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (SymmetricAlgorithm
sa, S2K
s2k, IV
iv, ByteString -> [Word8]
BL.unpack ByteString
bs)
  toJSON (SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) = (SymmetricAlgorithm, AEADAlgorithm, S2K, IV, [Word8]) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (SymmetricAlgorithm
sa, AEADAlgorithm
aa, S2K
s2k, IV
iv, ByteString -> [Word8]
BL.unpack ByteString
bs)
  toJSON (SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs) = (SymmetricAlgorithm, IV, [Word8]) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (SymmetricAlgorithm
sa, IV
iv, ByteString -> [Word8]
BL.unpack ByteString
bs)
  toJSON (SUUnencrypted SKey
s Word16
ck) = (SKey, Word16) -> Value
forall a. ToJSON a => a -> Value
A.toJSON (SKey
s, Word16
ck)

class LegacyKeyVersion (v :: KeyVersion)

instance LegacyKeyVersion 'DeprecatedV3

instance LegacyKeyVersion 'V4

data SKAddendumV (v :: KeyVersion) where
  SKA16bit ::
       LegacyKeyVersion v
    => SymmetricAlgorithm
    -> S2K
    -> IV
    -> ByteString
    -> SKAddendumV v
  SKASHA1Legacy ::
       LegacyKeyVersion v
    => SymmetricAlgorithm
    -> S2K
    -> IV
    -> ByteString
    -> SKAddendumV v
  SKASHA1V6 ::
       SymmetricAlgorithm
    -> S2K
    -> IV
    -> ByteString
    -> SKAddendumV 'V6
  SKAAEADV6 ::
       SymmetricAlgorithm
    -> AEADAlgorithm
    -> S2K
    -> IV
    -> ByteString
    -> SKAddendumV 'V6
  SKAAEADLegacy ::
       LegacyKeyVersion v
    => SymmetricAlgorithm
    -> AEADAlgorithm
    -> S2K
    -> IV
    -> ByteString
    -> SKAddendumV v
  SKASymLegacy ::
       LegacyKeyVersion v
    => SymmetricAlgorithm
    -> IV
    -> ByteString
    -> SKAddendumV v
  SKASymV6 ::
       SymmetricAlgorithm
    -> IV
    -> ByteString
    -> SKAddendumV 'V6
  SKAUnencryptedLegacy ::
       LegacyKeyVersion v
    => SKey
    -> Word16
    -> SKAddendumV v
  SKAUnencryptedV6 ::
       SKey
    -> SKAddendumV 'V6

deriving instance Show (SKAddendumV v)

data SomeSKAddendumV where
  SomeSKAddendumV :: SKAddendumV v -> SomeSKAddendumV

deriving instance Show SomeSKAddendumV

toSKAddendum :: SKAddendumV v -> SKAddendum
toSKAddendum :: forall (v :: KeyVersion). SKAddendumV v -> SKAddendum
toSKAddendum (SKA16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) = SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendum
SUS16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs
toSKAddendum (SKASHA1Legacy SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) = SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendum
SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs
toSKAddendum (SKASHA1V6 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) = SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendum
SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs
toSKAddendum (SKAAEADV6 SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) = SymmetricAlgorithm
-> AEADAlgorithm -> S2K -> IV -> ByteString -> SKAddendum
SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs
toSKAddendum (SKAAEADLegacy SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) = SymmetricAlgorithm
-> AEADAlgorithm -> S2K -> IV -> ByteString -> SKAddendum
SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs
toSKAddendum (SKASymLegacy SymmetricAlgorithm
sa IV
iv ByteString
bs) = SymmetricAlgorithm -> IV -> ByteString -> SKAddendum
SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs
toSKAddendum (SKASymV6 SymmetricAlgorithm
sa IV
iv ByteString
bs) = SymmetricAlgorithm -> IV -> ByteString -> SKAddendum
SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs
toSKAddendum (SKAUnencryptedLegacy SKey
sk Word16
checksum) = SKey -> Word16 -> SKAddendum
SUUnencrypted SKey
sk Word16
checksum
toSKAddendum (SKAUnencryptedV6 SKey
sk) = SKey -> Word16 -> SKAddendum
SUUnencrypted SKey
sk Word16
0

fromSKAddendumForKeyVersion ::
     KeyVersion
  -> SKAddendum
  -> Either String SomeSKAddendumV
fromSKAddendumForKeyVersion :: KeyVersion -> SKAddendum -> Either String SomeSKAddendumV
fromSKAddendumForKeyVersion KeyVersion
DeprecatedV3 (SUS16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'DeprecatedV3 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm
-> S2K -> IV -> ByteString -> SKAddendumV 'DeprecatedV3
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV v
SKA16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs :: SKAddendumV 'DeprecatedV3))
fromSKAddendumForKeyVersion KeyVersion
DeprecatedV3 (SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'DeprecatedV3 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm
-> S2K -> IV -> ByteString -> SKAddendumV 'DeprecatedV3
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV v
SKASHA1Legacy SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs :: SKAddendumV 'DeprecatedV3))
fromSKAddendumForKeyVersion KeyVersion
DeprecatedV3 (SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'DeprecatedV3 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm -> IV -> ByteString -> SKAddendumV 'DeprecatedV3
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm -> IV -> ByteString -> SKAddendumV v
SKASymLegacy SymmetricAlgorithm
sa IV
iv ByteString
bs :: SKAddendumV 'DeprecatedV3))
fromSKAddendumForKeyVersion KeyVersion
DeprecatedV3 (SUUnencrypted SKey
sk Word16
checksum) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'DeprecatedV3 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SKey -> Word16 -> SKAddendumV 'DeprecatedV3
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SKey -> Word16 -> SKAddendumV v
SKAUnencryptedLegacy SKey
sk Word16
checksum :: SKAddendumV 'DeprecatedV3))
fromSKAddendumForKeyVersion KeyVersion
DeprecatedV3 (SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'DeprecatedV3 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm
-> AEADAlgorithm
-> S2K
-> IV
-> ByteString
-> SKAddendumV 'DeprecatedV3
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm
-> AEADAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV v
SKAAEADLegacy SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs :: SKAddendumV 'DeprecatedV3))
fromSKAddendumForKeyVersion KeyVersion
V4 (SUS16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V4 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV 'V4
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV v
SKA16bit SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs :: SKAddendumV 'V4))
fromSKAddendumForKeyVersion KeyVersion
V4 (SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V4 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV 'V4
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV v
SKASHA1Legacy SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs :: SKAddendumV 'V4))
fromSKAddendumForKeyVersion KeyVersion
V4 (SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V4 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm -> IV -> ByteString -> SKAddendumV 'V4
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm -> IV -> ByteString -> SKAddendumV v
SKASymLegacy SymmetricAlgorithm
sa IV
iv ByteString
bs :: SKAddendumV 'V4))
fromSKAddendumForKeyVersion KeyVersion
V4 (SUUnencrypted SKey
sk Word16
checksum) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V4 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SKey -> Word16 -> SKAddendumV 'V4
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SKey -> Word16 -> SKAddendumV v
SKAUnencryptedLegacy SKey
sk Word16
checksum :: SKAddendumV 'V4))
fromSKAddendumForKeyVersion KeyVersion
V4 (SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V4 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm
-> AEADAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV 'V4
forall (v :: KeyVersion).
LegacyKeyVersion v =>
SymmetricAlgorithm
-> AEADAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV v
SKAAEADLegacy SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs :: SKAddendumV 'V4))
fromSKAddendumForKeyVersion KeyVersion
V6 (SUS16bit SymmetricAlgorithm
_ S2K
_ IV
_ ByteString
_) =
  String -> Either String SomeSKAddendumV
forall a b. a -> Either a b
Left String
"v6 secret keys must not use 16-bit checksum protected secret key addendums"
fromSKAddendumForKeyVersion KeyVersion
V6 (SUSSHA1 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V6 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV 'V6
SKASHA1V6 SymmetricAlgorithm
sa S2K
s2k IV
iv ByteString
bs))
fromSKAddendumForKeyVersion KeyVersion
V6 (SUSAEAD SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V6 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm
-> AEADAlgorithm -> S2K -> IV -> ByteString -> SKAddendumV 'V6
SKAAEADV6 SymmetricAlgorithm
sa AEADAlgorithm
aa S2K
s2k IV
iv ByteString
bs))
fromSKAddendumForKeyVersion KeyVersion
V6 (SUSym SymmetricAlgorithm
sa IV
iv ByteString
bs) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V6 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SymmetricAlgorithm -> IV -> ByteString -> SKAddendumV 'V6
SKASymV6 SymmetricAlgorithm
sa IV
iv ByteString
bs))
fromSKAddendumForKeyVersion KeyVersion
V6 (SUUnencrypted SKey
sk Word16
_) =
  SomeSKAddendumV -> Either String SomeSKAddendumV
forall a b. b -> Either a b
Right (SKAddendumV 'V6 -> SomeSKAddendumV
forall (v :: KeyVersion). SKAddendumV v -> SomeSKAddendumV
SomeSKAddendumV (SKey -> SKAddendumV 'V6
SKAUnencryptedV6 SKey
sk))

fromSKAddendumForPKPayload ::
     SomePKPayload
  -> SKAddendum
  -> Either String SomeSKAddendumV
fromSKAddendumForPKPayload :: SomePKPayload -> SKAddendum -> Either String SomeSKAddendumV
fromSKAddendumForPKPayload SomePKPayload
pkp =
  KeyVersion -> SKAddendum -> Either String SomeSKAddendumV
fromSKAddendumForKeyVersion (SomePKPayload -> KeyVersion
_keyVersion SomePKPayload
pkp)