{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE StandaloneDeriving #-}
module Crypto.WebAuthn.Cose.SignAlg
(
CoseSignAlg
( ..,
CoseAlgorithmEdDSA,
CoseAlgorithmES256,
CoseAlgorithmES384,
CoseAlgorithmES512,
CoseAlgorithmRS256,
CoseAlgorithmRS384,
CoseAlgorithmRS512,
CoseAlgorithmRS1
),
fromCoseSignAlg,
toCoseSignAlg,
CoseHashAlgECDSA (..),
CoseHashAlgRSA (..),
)
where
import Codec.CBOR.Decoding (decodeIntCanonical)
import Codec.CBOR.Encoding (encodeInt)
import Codec.Serialise (Serialise)
import Codec.Serialise.Class (decode, encode)
import Data.Aeson (ToJSON)
import Data.Text (Text)
import qualified Data.Text as Text
import GHC.Generics (Generic)
data CoseSignAlg
=
CoseSignAlgEdDSA
|
CoseSignAlgECDSA CoseHashAlgECDSA
|
CoseSignAlgRSA CoseHashAlgRSA
deriving (CoseSignAlg -> CoseSignAlg -> Bool
(CoseSignAlg -> CoseSignAlg -> Bool)
-> (CoseSignAlg -> CoseSignAlg -> Bool) -> Eq CoseSignAlg
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CoseSignAlg -> CoseSignAlg -> Bool
== :: CoseSignAlg -> CoseSignAlg -> Bool
$c/= :: CoseSignAlg -> CoseSignAlg -> Bool
/= :: CoseSignAlg -> CoseSignAlg -> Bool
Eq, Int -> CoseSignAlg -> ShowS
[CoseSignAlg] -> ShowS
CoseSignAlg -> String
(Int -> CoseSignAlg -> ShowS)
-> (CoseSignAlg -> String)
-> ([CoseSignAlg] -> ShowS)
-> Show CoseSignAlg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CoseSignAlg -> ShowS
showsPrec :: Int -> CoseSignAlg -> ShowS
$cshow :: CoseSignAlg -> String
show :: CoseSignAlg -> String
$cshowList :: [CoseSignAlg] -> ShowS
showList :: [CoseSignAlg] -> ShowS
Show, Eq CoseSignAlg
Eq CoseSignAlg
-> (CoseSignAlg -> CoseSignAlg -> Ordering)
-> (CoseSignAlg -> CoseSignAlg -> Bool)
-> (CoseSignAlg -> CoseSignAlg -> Bool)
-> (CoseSignAlg -> CoseSignAlg -> Bool)
-> (CoseSignAlg -> CoseSignAlg -> Bool)
-> (CoseSignAlg -> CoseSignAlg -> CoseSignAlg)
-> (CoseSignAlg -> CoseSignAlg -> CoseSignAlg)
-> Ord CoseSignAlg
CoseSignAlg -> CoseSignAlg -> Bool
CoseSignAlg -> CoseSignAlg -> Ordering
CoseSignAlg -> CoseSignAlg -> CoseSignAlg
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 :: CoseSignAlg -> CoseSignAlg -> Ordering
compare :: CoseSignAlg -> CoseSignAlg -> Ordering
$c< :: CoseSignAlg -> CoseSignAlg -> Bool
< :: CoseSignAlg -> CoseSignAlg -> Bool
$c<= :: CoseSignAlg -> CoseSignAlg -> Bool
<= :: CoseSignAlg -> CoseSignAlg -> Bool
$c> :: CoseSignAlg -> CoseSignAlg -> Bool
> :: CoseSignAlg -> CoseSignAlg -> Bool
$c>= :: CoseSignAlg -> CoseSignAlg -> Bool
>= :: CoseSignAlg -> CoseSignAlg -> Bool
$cmax :: CoseSignAlg -> CoseSignAlg -> CoseSignAlg
max :: CoseSignAlg -> CoseSignAlg -> CoseSignAlg
$cmin :: CoseSignAlg -> CoseSignAlg -> CoseSignAlg
min :: CoseSignAlg -> CoseSignAlg -> CoseSignAlg
Ord, (forall x. CoseSignAlg -> Rep CoseSignAlg x)
-> (forall x. Rep CoseSignAlg x -> CoseSignAlg)
-> Generic CoseSignAlg
forall x. Rep CoseSignAlg x -> CoseSignAlg
forall x. CoseSignAlg -> Rep CoseSignAlg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CoseSignAlg -> Rep CoseSignAlg x
from :: forall x. CoseSignAlg -> Rep CoseSignAlg x
$cto :: forall x. Rep CoseSignAlg x -> CoseSignAlg
to :: forall x. Rep CoseSignAlg x -> CoseSignAlg
Generic)
deriving instance ToJSON CoseSignAlg
data CoseHashAlgECDSA
=
CoseHashAlgECDSASHA256
|
CoseHashAlgECDSASHA384
|
CoseHashAlgECDSASHA512
deriving (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
(CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool)
-> Eq CoseHashAlgECDSA
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
== :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
$c/= :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
/= :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
Eq, Int -> CoseHashAlgECDSA -> ShowS
[CoseHashAlgECDSA] -> ShowS
CoseHashAlgECDSA -> String
(Int -> CoseHashAlgECDSA -> ShowS)
-> (CoseHashAlgECDSA -> String)
-> ([CoseHashAlgECDSA] -> ShowS)
-> Show CoseHashAlgECDSA
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CoseHashAlgECDSA -> ShowS
showsPrec :: Int -> CoseHashAlgECDSA -> ShowS
$cshow :: CoseHashAlgECDSA -> String
show :: CoseHashAlgECDSA -> String
$cshowList :: [CoseHashAlgECDSA] -> ShowS
showList :: [CoseHashAlgECDSA] -> ShowS
Show, Eq CoseHashAlgECDSA
Eq CoseHashAlgECDSA
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Ordering)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA)
-> Ord CoseHashAlgECDSA
CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
CoseHashAlgECDSA -> CoseHashAlgECDSA -> Ordering
CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA
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 :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Ordering
compare :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Ordering
$c< :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
< :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
$c<= :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
<= :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
$c> :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
> :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
$c>= :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
>= :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bool
$cmax :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA
max :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA
$cmin :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA
min :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> CoseHashAlgECDSA
Ord, Int -> CoseHashAlgECDSA
CoseHashAlgECDSA -> Int
CoseHashAlgECDSA -> [CoseHashAlgECDSA]
CoseHashAlgECDSA -> CoseHashAlgECDSA
CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
CoseHashAlgECDSA
-> CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
(CoseHashAlgECDSA -> CoseHashAlgECDSA)
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA)
-> (Int -> CoseHashAlgECDSA)
-> (CoseHashAlgECDSA -> Int)
-> (CoseHashAlgECDSA -> [CoseHashAlgECDSA])
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA])
-> (CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA])
-> (CoseHashAlgECDSA
-> CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA])
-> Enum CoseHashAlgECDSA
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: CoseHashAlgECDSA -> CoseHashAlgECDSA
succ :: CoseHashAlgECDSA -> CoseHashAlgECDSA
$cpred :: CoseHashAlgECDSA -> CoseHashAlgECDSA
pred :: CoseHashAlgECDSA -> CoseHashAlgECDSA
$ctoEnum :: Int -> CoseHashAlgECDSA
toEnum :: Int -> CoseHashAlgECDSA
$cfromEnum :: CoseHashAlgECDSA -> Int
fromEnum :: CoseHashAlgECDSA -> Int
$cenumFrom :: CoseHashAlgECDSA -> [CoseHashAlgECDSA]
enumFrom :: CoseHashAlgECDSA -> [CoseHashAlgECDSA]
$cenumFromThen :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
enumFromThen :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
$cenumFromTo :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
enumFromTo :: CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
$cenumFromThenTo :: CoseHashAlgECDSA
-> CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
enumFromThenTo :: CoseHashAlgECDSA
-> CoseHashAlgECDSA -> CoseHashAlgECDSA -> [CoseHashAlgECDSA]
Enum, CoseHashAlgECDSA
CoseHashAlgECDSA -> CoseHashAlgECDSA -> Bounded CoseHashAlgECDSA
forall a. a -> a -> Bounded a
$cminBound :: CoseHashAlgECDSA
minBound :: CoseHashAlgECDSA
$cmaxBound :: CoseHashAlgECDSA
maxBound :: CoseHashAlgECDSA
Bounded, (forall x. CoseHashAlgECDSA -> Rep CoseHashAlgECDSA x)
-> (forall x. Rep CoseHashAlgECDSA x -> CoseHashAlgECDSA)
-> Generic CoseHashAlgECDSA
forall x. Rep CoseHashAlgECDSA x -> CoseHashAlgECDSA
forall x. CoseHashAlgECDSA -> Rep CoseHashAlgECDSA x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CoseHashAlgECDSA -> Rep CoseHashAlgECDSA x
from :: forall x. CoseHashAlgECDSA -> Rep CoseHashAlgECDSA x
$cto :: forall x. Rep CoseHashAlgECDSA x -> CoseHashAlgECDSA
to :: forall x. Rep CoseHashAlgECDSA x -> CoseHashAlgECDSA
Generic)
deriving instance ToJSON CoseHashAlgECDSA
data CoseHashAlgRSA
=
CoseHashAlgRSASHA1
|
CoseHashAlgRSASHA256
|
CoseHashAlgRSASHA384
|
CoseHashAlgRSASHA512
deriving (CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
(CoseHashAlgRSA -> CoseHashAlgRSA -> Bool)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> Bool) -> Eq CoseHashAlgRSA
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
== :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
$c/= :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
/= :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
Eq, Int -> CoseHashAlgRSA -> ShowS
[CoseHashAlgRSA] -> ShowS
CoseHashAlgRSA -> String
(Int -> CoseHashAlgRSA -> ShowS)
-> (CoseHashAlgRSA -> String)
-> ([CoseHashAlgRSA] -> ShowS)
-> Show CoseHashAlgRSA
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CoseHashAlgRSA -> ShowS
showsPrec :: Int -> CoseHashAlgRSA -> ShowS
$cshow :: CoseHashAlgRSA -> String
show :: CoseHashAlgRSA -> String
$cshowList :: [CoseHashAlgRSA] -> ShowS
showList :: [CoseHashAlgRSA] -> ShowS
Show, Eq CoseHashAlgRSA
Eq CoseHashAlgRSA
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> Ordering)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> Bool)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> Bool)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> Bool)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> Bool)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA)
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA)
-> Ord CoseHashAlgRSA
CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
CoseHashAlgRSA -> CoseHashAlgRSA -> Ordering
CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA
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 :: CoseHashAlgRSA -> CoseHashAlgRSA -> Ordering
compare :: CoseHashAlgRSA -> CoseHashAlgRSA -> Ordering
$c< :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
< :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
$c<= :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
<= :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
$c> :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
> :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
$c>= :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
>= :: CoseHashAlgRSA -> CoseHashAlgRSA -> Bool
$cmax :: CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA
max :: CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA
$cmin :: CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA
min :: CoseHashAlgRSA -> CoseHashAlgRSA -> CoseHashAlgRSA
Ord, Int -> CoseHashAlgRSA
CoseHashAlgRSA -> Int
CoseHashAlgRSA -> [CoseHashAlgRSA]
CoseHashAlgRSA -> CoseHashAlgRSA
CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
CoseHashAlgRSA
-> CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
(CoseHashAlgRSA -> CoseHashAlgRSA)
-> (CoseHashAlgRSA -> CoseHashAlgRSA)
-> (Int -> CoseHashAlgRSA)
-> (CoseHashAlgRSA -> Int)
-> (CoseHashAlgRSA -> [CoseHashAlgRSA])
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA])
-> (CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA])
-> (CoseHashAlgRSA
-> CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA])
-> Enum CoseHashAlgRSA
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: CoseHashAlgRSA -> CoseHashAlgRSA
succ :: CoseHashAlgRSA -> CoseHashAlgRSA
$cpred :: CoseHashAlgRSA -> CoseHashAlgRSA
pred :: CoseHashAlgRSA -> CoseHashAlgRSA
$ctoEnum :: Int -> CoseHashAlgRSA
toEnum :: Int -> CoseHashAlgRSA
$cfromEnum :: CoseHashAlgRSA -> Int
fromEnum :: CoseHashAlgRSA -> Int
$cenumFrom :: CoseHashAlgRSA -> [CoseHashAlgRSA]
enumFrom :: CoseHashAlgRSA -> [CoseHashAlgRSA]
$cenumFromThen :: CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
enumFromThen :: CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
$cenumFromTo :: CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
enumFromTo :: CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
$cenumFromThenTo :: CoseHashAlgRSA
-> CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
enumFromThenTo :: CoseHashAlgRSA
-> CoseHashAlgRSA -> CoseHashAlgRSA -> [CoseHashAlgRSA]
Enum, CoseHashAlgRSA
CoseHashAlgRSA -> CoseHashAlgRSA -> Bounded CoseHashAlgRSA
forall a. a -> a -> Bounded a
$cminBound :: CoseHashAlgRSA
minBound :: CoseHashAlgRSA
$cmaxBound :: CoseHashAlgRSA
maxBound :: CoseHashAlgRSA
Bounded, (forall x. CoseHashAlgRSA -> Rep CoseHashAlgRSA x)
-> (forall x. Rep CoseHashAlgRSA x -> CoseHashAlgRSA)
-> Generic CoseHashAlgRSA
forall x. Rep CoseHashAlgRSA x -> CoseHashAlgRSA
forall x. CoseHashAlgRSA -> Rep CoseHashAlgRSA x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CoseHashAlgRSA -> Rep CoseHashAlgRSA x
from :: forall x. CoseHashAlgRSA -> Rep CoseHashAlgRSA x
$cto :: forall x. Rep CoseHashAlgRSA x -> CoseHashAlgRSA
to :: forall x. Rep CoseHashAlgRSA x -> CoseHashAlgRSA
Generic)
deriving instance ToJSON CoseHashAlgRSA
pattern CoseAlgorithmEdDSA :: CoseSignAlg
pattern $mCoseAlgorithmEdDSA :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmEdDSA :: CoseSignAlg
CoseAlgorithmEdDSA = CoseSignAlgEdDSA
pattern CoseAlgorithmES256 :: CoseSignAlg
pattern $mCoseAlgorithmES256 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmES256 :: CoseSignAlg
CoseAlgorithmES256 = CoseSignAlgECDSA CoseHashAlgECDSASHA256
pattern CoseAlgorithmES384 :: CoseSignAlg
pattern $mCoseAlgorithmES384 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmES384 :: CoseSignAlg
CoseAlgorithmES384 = CoseSignAlgECDSA CoseHashAlgECDSASHA384
pattern CoseAlgorithmES512 :: CoseSignAlg
pattern $mCoseAlgorithmES512 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmES512 :: CoseSignAlg
CoseAlgorithmES512 = CoseSignAlgECDSA CoseHashAlgECDSASHA512
pattern CoseAlgorithmRS256 :: CoseSignAlg
pattern $mCoseAlgorithmRS256 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmRS256 :: CoseSignAlg
CoseAlgorithmRS256 = CoseSignAlgRSA CoseHashAlgRSASHA256
pattern CoseAlgorithmRS384 :: CoseSignAlg
pattern $mCoseAlgorithmRS384 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmRS384 :: CoseSignAlg
CoseAlgorithmRS384 = CoseSignAlgRSA CoseHashAlgRSASHA384
pattern CoseAlgorithmRS512 :: CoseSignAlg
pattern $mCoseAlgorithmRS512 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmRS512 :: CoseSignAlg
CoseAlgorithmRS512 = CoseSignAlgRSA CoseHashAlgRSASHA512
pattern CoseAlgorithmRS1 :: CoseSignAlg
pattern $mCoseAlgorithmRS1 :: forall {r}. CoseSignAlg -> ((# #) -> r) -> ((# #) -> r) -> r
$bCoseAlgorithmRS1 :: CoseSignAlg
CoseAlgorithmRS1 = CoseSignAlgRSA CoseHashAlgRSASHA1
instance Serialise CoseSignAlg where
encode :: CoseSignAlg -> Encoding
encode = Int -> Encoding
encodeInt (Int -> Encoding)
-> (CoseSignAlg -> Int) -> CoseSignAlg -> Encoding
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CoseSignAlg -> Int
forall p. Num p => CoseSignAlg -> p
fromCoseSignAlg
decode :: forall s. Decoder s CoseSignAlg
decode = do
Int
int <- Decoder s Int
forall s. Decoder s Int
decodeIntCanonical
case Int -> Either Text CoseSignAlg
forall a. (Eq a, Num a, Show a) => a -> Either Text CoseSignAlg
toCoseSignAlg Int
int of
Right CoseSignAlg
res -> CoseSignAlg -> Decoder s CoseSignAlg
forall a. a -> Decoder s a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CoseSignAlg
res
Left Text
err -> String -> Decoder s CoseSignAlg
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Decoder s CoseSignAlg)
-> String -> Decoder s CoseSignAlg
forall a b. (a -> b) -> a -> b
$ Text -> String
Text.unpack Text
err
fromCoseSignAlg :: (Num p) => CoseSignAlg -> p
fromCoseSignAlg :: forall p. Num p => CoseSignAlg -> p
fromCoseSignAlg (CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA1) = -p
65535
fromCoseSignAlg (CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA512) = -p
259
fromCoseSignAlg (CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA384) = -p
258
fromCoseSignAlg (CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA256) = -p
257
fromCoseSignAlg (CoseSignAlgECDSA CoseHashAlgECDSA
CoseHashAlgECDSASHA512) = -p
36
fromCoseSignAlg (CoseSignAlgECDSA CoseHashAlgECDSA
CoseHashAlgECDSASHA384) = -p
35
fromCoseSignAlg CoseSignAlg
CoseSignAlgEdDSA = -p
8
fromCoseSignAlg (CoseSignAlgECDSA CoseHashAlgECDSA
CoseHashAlgECDSASHA256) = -p
7
toCoseSignAlg :: (Eq a, Num a, Show a) => a -> Either Text CoseSignAlg
toCoseSignAlg :: forall a. (Eq a, Num a, Show a) => a -> Either Text CoseSignAlg
toCoseSignAlg (-65535) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgRSA -> CoseSignAlg
CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA1)
toCoseSignAlg (-259) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgRSA -> CoseSignAlg
CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA512)
toCoseSignAlg (-258) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgRSA -> CoseSignAlg
CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA384)
toCoseSignAlg (-257) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgRSA -> CoseSignAlg
CoseSignAlgRSA CoseHashAlgRSA
CoseHashAlgRSASHA256)
toCoseSignAlg (-36) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgECDSA -> CoseSignAlg
CoseSignAlgECDSA CoseHashAlgECDSA
CoseHashAlgECDSASHA512)
toCoseSignAlg (-35) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgECDSA -> CoseSignAlg
CoseSignAlgECDSA CoseHashAlgECDSA
CoseHashAlgECDSASHA384)
toCoseSignAlg (-8) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CoseSignAlg
CoseSignAlgEdDSA
toCoseSignAlg (-7) = CoseSignAlg -> Either Text CoseSignAlg
forall a. a -> Either Text a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CoseHashAlgECDSA -> CoseSignAlg
CoseSignAlgECDSA CoseHashAlgECDSA
CoseHashAlgECDSASHA256)
toCoseSignAlg a
value = Text -> Either Text CoseSignAlg
forall a b. a -> Either a b
Left (Text -> Either Text CoseSignAlg)
-> Text -> Either Text CoseSignAlg
forall a b. (a -> b) -> a -> b
$ Text
"Unknown COSE algorithm value " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
Text.pack (a -> String
forall a. Show a => a -> String
show a
value)