{-# LANGUAGE PatternSynonyms #-}

-- | TLS signature schemes, as RFC 8446 section 4.2.3 and the IANA
-- TLS SignatureScheme registry name them.
module Network.TLS.SignatureScheme (
    SignatureScheme (
        ..,
        -- the schemes the IANA registry names
        RSA_PKCS1_SHA1,
        ECDSA_SHA1,
        DSA_SHA1,
        RSA_PKCS1_SHA256,
        ECDSA_SECP256R1_SHA256,
        RSA_PKCS1_SHA384,
        ECDSA_SECP384R1_SHA384,
        RSA_PKCS1_SHA512,
        ECDSA_SECP521R1_SHA512,
        RSA_PSS_RSAE_SHA256,
        RSA_PSS_RSAE_SHA384,
        RSA_PSS_RSAE_SHA512,
        ED25519,
        ED448,
        RSA_PSS_PSS_SHA256,
        RSA_PSS_PSS_SHA384,
        RSA_PSS_PSS_SHA512,
        ECDSA_BRAINPOOLP256R1TLS13_SHA256,
        ECDSA_BRAINPOOLP384R1TLS13_SHA384,
        ECDSA_BRAINPOOLP512R1TLS13_SHA512,
        MLDSA44,
        MLDSA65,
        MLDSA87,

        -- the TLS 1.2 combinations it does not
        RSA_PKCS1_MD5,
        DSA_MD5,
        ECDSA_MD5,
        RSA_PKCS1_SHA224,
        DSA_SHA224,
        ECDSA_SHA224,
        DSA_SHA256,
        DSA_SHA384,
        DSA_SHA512
    ),
    HashAndSignatureAlgorithm,
    supportedSignatureSchemes,
    signatureSchemesForTLS13,
    isMLDSA,
    rsaPkcs1Schemes,
    rsaPssSchemes,
    dsaSchemes,
    ecdsaSchemes,
) where

import Numeric (showHex)

import Network.TLS.Imports

-- | A signature scheme: the 16-bit number that travels on the wire, with a
-- name for each one this library knows.
--
-- A scheme is one number, not a hash and a signature algorithm.  TLS 1.2
-- read the two bytes separately and some of the values still line up that
-- way, but from TLS 1.3 the number is indivisible, and for ML-DSA neither
-- byte means what it does elsewhere -- 0x09 is no hash, and the second byte
-- repeats numbers RSASSA-PSS uses, so @mldsa87@ read byte by byte looks
-- like @rsa_pss_rsae_sha512@.  Code that took the halves apart got that
-- wrong, which is why the halves are gone.
--
-- The names are pattern synonyms with no @COMPLETE@ pragma, so a @case@
-- over them needs a catch-all and a scheme named in a later release breaks
-- nothing that compiled against this one.  'Show' is written out for the
-- same reason: a program built against an older hs-tls still says something
-- useful about a scheme a newer one produced.
newtype SignatureScheme = SignatureScheme {SignatureScheme -> Word16
fromSignatureScheme :: Word16}
    deriving (SignatureScheme -> SignatureScheme -> Bool
(SignatureScheme -> SignatureScheme -> Bool)
-> (SignatureScheme -> SignatureScheme -> Bool)
-> Eq SignatureScheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SignatureScheme -> SignatureScheme -> Bool
== :: SignatureScheme -> SignatureScheme -> Bool
$c/= :: SignatureScheme -> SignatureScheme -> Bool
/= :: SignatureScheme -> SignatureScheme -> Bool
Eq, Eq SignatureScheme
Eq SignatureScheme =>
(SignatureScheme -> SignatureScheme -> Ordering)
-> (SignatureScheme -> SignatureScheme -> Bool)
-> (SignatureScheme -> SignatureScheme -> Bool)
-> (SignatureScheme -> SignatureScheme -> Bool)
-> (SignatureScheme -> SignatureScheme -> Bool)
-> (SignatureScheme -> SignatureScheme -> SignatureScheme)
-> (SignatureScheme -> SignatureScheme -> SignatureScheme)
-> Ord SignatureScheme
SignatureScheme -> SignatureScheme -> Bool
SignatureScheme -> SignatureScheme -> Ordering
SignatureScheme -> SignatureScheme -> SignatureScheme
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 :: SignatureScheme -> SignatureScheme -> Ordering
compare :: SignatureScheme -> SignatureScheme -> Ordering
$c< :: SignatureScheme -> SignatureScheme -> Bool
< :: SignatureScheme -> SignatureScheme -> Bool
$c<= :: SignatureScheme -> SignatureScheme -> Bool
<= :: SignatureScheme -> SignatureScheme -> Bool
$c> :: SignatureScheme -> SignatureScheme -> Bool
> :: SignatureScheme -> SignatureScheme -> Bool
$c>= :: SignatureScheme -> SignatureScheme -> Bool
>= :: SignatureScheme -> SignatureScheme -> Bool
$cmax :: SignatureScheme -> SignatureScheme -> SignatureScheme
max :: SignatureScheme -> SignatureScheme -> SignatureScheme
$cmin :: SignatureScheme -> SignatureScheme -> SignatureScheme
min :: SignatureScheme -> SignatureScheme -> SignatureScheme
Ord)

{- FOURMOLU_DISABLE -}
pattern RSA_PKCS1_SHA1                    :: SignatureScheme
pattern $bRSA_PKCS1_SHA1 :: SignatureScheme
$mRSA_PKCS1_SHA1 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PKCS1_SHA1                     = SignatureScheme 0x0201  -- RFC8446, legacy
pattern ECDSA_SHA1                        :: SignatureScheme
pattern $bECDSA_SHA1 :: SignatureScheme
$mECDSA_SHA1 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_SHA1                         = SignatureScheme 0x0203  -- RFC8446, legacy
pattern DSA_SHA1                          :: SignatureScheme
pattern $bDSA_SHA1 :: SignatureScheme
$mDSA_SHA1 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
DSA_SHA1                           = SignatureScheme 0x0202  -- TLS 1.2 only, no IANA name
pattern RSA_PKCS1_SHA256                  :: SignatureScheme
pattern $bRSA_PKCS1_SHA256 :: SignatureScheme
$mRSA_PKCS1_SHA256 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PKCS1_SHA256                   = SignatureScheme 0x0401
pattern ECDSA_SECP256R1_SHA256            :: SignatureScheme
pattern $bECDSA_SECP256R1_SHA256 :: SignatureScheme
$mECDSA_SECP256R1_SHA256 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_SECP256R1_SHA256             = SignatureScheme 0x0403
pattern RSA_PKCS1_SHA384                  :: SignatureScheme
pattern $bRSA_PKCS1_SHA384 :: SignatureScheme
$mRSA_PKCS1_SHA384 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PKCS1_SHA384                   = SignatureScheme 0x0501
pattern ECDSA_SECP384R1_SHA384            :: SignatureScheme
pattern $bECDSA_SECP384R1_SHA384 :: SignatureScheme
$mECDSA_SECP384R1_SHA384 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_SECP384R1_SHA384             = SignatureScheme 0x0503
pattern RSA_PKCS1_SHA512                  :: SignatureScheme
pattern $bRSA_PKCS1_SHA512 :: SignatureScheme
$mRSA_PKCS1_SHA512 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PKCS1_SHA512                   = SignatureScheme 0x0601
pattern ECDSA_SECP521R1_SHA512            :: SignatureScheme
pattern $bECDSA_SECP521R1_SHA512 :: SignatureScheme
$mECDSA_SECP521R1_SHA512 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_SECP521R1_SHA512             = SignatureScheme 0x0603
pattern RSA_PSS_RSAE_SHA256               :: SignatureScheme
pattern $bRSA_PSS_RSAE_SHA256 :: SignatureScheme
$mRSA_PSS_RSAE_SHA256 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PSS_RSAE_SHA256                = SignatureScheme 0x0804
pattern RSA_PSS_RSAE_SHA384               :: SignatureScheme
pattern $bRSA_PSS_RSAE_SHA384 :: SignatureScheme
$mRSA_PSS_RSAE_SHA384 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PSS_RSAE_SHA384                = SignatureScheme 0x0805
pattern RSA_PSS_RSAE_SHA512               :: SignatureScheme
pattern $bRSA_PSS_RSAE_SHA512 :: SignatureScheme
$mRSA_PSS_RSAE_SHA512 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PSS_RSAE_SHA512                = SignatureScheme 0x0806
pattern ED25519                           :: SignatureScheme
pattern $bED25519 :: SignatureScheme
$mED25519 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ED25519                            = SignatureScheme 0x0807
pattern ED448                             :: SignatureScheme
pattern $bED448 :: SignatureScheme
$mED448 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ED448                              = SignatureScheme 0x0808
pattern RSA_PSS_PSS_SHA256                :: SignatureScheme
pattern $bRSA_PSS_PSS_SHA256 :: SignatureScheme
$mRSA_PSS_PSS_SHA256 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PSS_PSS_SHA256                 = SignatureScheme 0x0809
pattern RSA_PSS_PSS_SHA384                :: SignatureScheme
pattern $bRSA_PSS_PSS_SHA384 :: SignatureScheme
$mRSA_PSS_PSS_SHA384 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PSS_PSS_SHA384                 = SignatureScheme 0x080a
pattern RSA_PSS_PSS_SHA512                :: SignatureScheme
pattern $bRSA_PSS_PSS_SHA512 :: SignatureScheme
$mRSA_PSS_PSS_SHA512 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PSS_PSS_SHA512                 = SignatureScheme 0x080b
pattern ECDSA_BRAINPOOLP256R1TLS13_SHA256 :: SignatureScheme
pattern $bECDSA_BRAINPOOLP256R1TLS13_SHA256 :: SignatureScheme
$mECDSA_BRAINPOOLP256R1TLS13_SHA256 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_BRAINPOOLP256R1TLS13_SHA256  = SignatureScheme 0x081a  -- RFC8734
pattern ECDSA_BRAINPOOLP384R1TLS13_SHA384 :: SignatureScheme
pattern $bECDSA_BRAINPOOLP384R1TLS13_SHA384 :: SignatureScheme
$mECDSA_BRAINPOOLP384R1TLS13_SHA384 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_BRAINPOOLP384R1TLS13_SHA384  = SignatureScheme 0x081b  -- RFC8734
pattern ECDSA_BRAINPOOLP512R1TLS13_SHA512 :: SignatureScheme
pattern $bECDSA_BRAINPOOLP512R1TLS13_SHA512 :: SignatureScheme
$mECDSA_BRAINPOOLP512R1TLS13_SHA512 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_BRAINPOOLP512R1TLS13_SHA512  = SignatureScheme 0x081c  -- RFC8734
pattern MLDSA44                           :: SignatureScheme
pattern $bMLDSA44 :: SignatureScheme
$mMLDSA44 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
MLDSA44                            = SignatureScheme 0x0904  -- draft-ietf-tls-mldsa
pattern MLDSA65                           :: SignatureScheme
pattern $bMLDSA65 :: SignatureScheme
$mMLDSA65 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
MLDSA65                            = SignatureScheme 0x0905  -- draft-ietf-tls-mldsa
pattern MLDSA87                           :: SignatureScheme
pattern $bMLDSA87 :: SignatureScheme
$mMLDSA87 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
MLDSA87                            = SignatureScheme 0x0906  -- draft-ietf-tls-mldsa

-- TLS 1.2 wrote a hash and a signature algorithm, and some of the
-- combinations it allowed are schemes the registry never named.  They still
-- turn up: a certificate can be signed with one, and the peer's
-- signature_algorithms list is matched against the number.
pattern RSA_PKCS1_MD5                      :: SignatureScheme
pattern $bRSA_PKCS1_MD5 :: SignatureScheme
$mRSA_PKCS1_MD5 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PKCS1_MD5                       = SignatureScheme 0x0101
pattern DSA_MD5                            :: SignatureScheme
pattern $bDSA_MD5 :: SignatureScheme
$mDSA_MD5 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
DSA_MD5                             = SignatureScheme 0x0102
pattern ECDSA_MD5                          :: SignatureScheme
pattern $bECDSA_MD5 :: SignatureScheme
$mECDSA_MD5 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_MD5                           = SignatureScheme 0x0103
pattern RSA_PKCS1_SHA224                   :: SignatureScheme
pattern $bRSA_PKCS1_SHA224 :: SignatureScheme
$mRSA_PKCS1_SHA224 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
RSA_PKCS1_SHA224                    = SignatureScheme 0x0301
pattern DSA_SHA224                         :: SignatureScheme
pattern $bDSA_SHA224 :: SignatureScheme
$mDSA_SHA224 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
DSA_SHA224                          = SignatureScheme 0x0302
pattern ECDSA_SHA224                       :: SignatureScheme
pattern $bECDSA_SHA224 :: SignatureScheme
$mECDSA_SHA224 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
ECDSA_SHA224                        = SignatureScheme 0x0303
pattern DSA_SHA256                         :: SignatureScheme
pattern $bDSA_SHA256 :: SignatureScheme
$mDSA_SHA256 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
DSA_SHA256                          = SignatureScheme 0x0402
pattern DSA_SHA384                         :: SignatureScheme
pattern $bDSA_SHA384 :: SignatureScheme
$mDSA_SHA384 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
DSA_SHA384                          = SignatureScheme 0x0502
pattern DSA_SHA512                         :: SignatureScheme
pattern $bDSA_SHA512 :: SignatureScheme
$mDSA_SHA512 :: forall {r}. SignatureScheme -> ((# #) -> r) -> ((# #) -> r) -> r
DSA_SHA512                          = SignatureScheme 0x0602

-- | The IANA name, and the number for a scheme this release does not know.
instance Show SignatureScheme where
    show :: SignatureScheme -> String
show SignatureScheme
RSA_PKCS1_SHA1                    = String
"rsa_pkcs1_sha1"
    show SignatureScheme
ECDSA_SHA1                        = String
"ecdsa_sha1"
    show SignatureScheme
DSA_SHA1                          = String
"dsa_sha1"
    show SignatureScheme
RSA_PKCS1_SHA256                  = String
"rsa_pkcs1_sha256"
    show SignatureScheme
ECDSA_SECP256R1_SHA256            = String
"ecdsa_secp256r1_sha256"
    show SignatureScheme
RSA_PKCS1_SHA384                  = String
"rsa_pkcs1_sha384"
    show SignatureScheme
ECDSA_SECP384R1_SHA384            = String
"ecdsa_secp384r1_sha384"
    show SignatureScheme
RSA_PKCS1_SHA512                  = String
"rsa_pkcs1_sha512"
    show SignatureScheme
ECDSA_SECP521R1_SHA512            = String
"ecdsa_secp521r1_sha512"
    show SignatureScheme
RSA_PSS_RSAE_SHA256               = String
"rsa_pss_rsae_sha256"
    show SignatureScheme
RSA_PSS_RSAE_SHA384               = String
"rsa_pss_rsae_sha384"
    show SignatureScheme
RSA_PSS_RSAE_SHA512               = String
"rsa_pss_rsae_sha512"
    show SignatureScheme
ED25519                           = String
"ed25519"
    show SignatureScheme
ED448                             = String
"ed448"
    show SignatureScheme
RSA_PSS_PSS_SHA256                = String
"rsa_pss_pss_sha256"
    show SignatureScheme
RSA_PSS_PSS_SHA384                = String
"rsa_pss_pss_sha384"
    show SignatureScheme
RSA_PSS_PSS_SHA512                = String
"rsa_pss_pss_sha512"
    show SignatureScheme
ECDSA_BRAINPOOLP256R1TLS13_SHA256 = String
"ecdsa_brainpoolP256r1tls13_sha256"
    show SignatureScheme
ECDSA_BRAINPOOLP384R1TLS13_SHA384 = String
"ecdsa_brainpoolP384r1tls13_sha384"
    show SignatureScheme
ECDSA_BRAINPOOLP512R1TLS13_SHA512 = String
"ecdsa_brainpoolP512r1tls13_sha512"
    show SignatureScheme
MLDSA44                           = String
"mldsa44"
    show SignatureScheme
MLDSA65                           = String
"mldsa65"
    show SignatureScheme
MLDSA87                           = String
"mldsa87"
    show SignatureScheme
RSA_PKCS1_MD5                      = String
"rsa_pkcs1_md5"
    show SignatureScheme
DSA_MD5                            = String
"dsa_md5"
    show SignatureScheme
ECDSA_MD5                          = String
"ecdsa_md5"
    show SignatureScheme
RSA_PKCS1_SHA224                   = String
"rsa_pkcs1_sha224"
    show SignatureScheme
DSA_SHA224                         = String
"dsa_sha224"
    show SignatureScheme
ECDSA_SHA224                       = String
"ecdsa_sha224"
    show SignatureScheme
DSA_SHA256                         = String
"dsa_sha256"
    show SignatureScheme
DSA_SHA384                         = String
"dsa_sha384"
    show SignatureScheme
DSA_SHA512                         = String
"dsa_sha512"
    show (SignatureScheme Word16
n) = String
"signature_scheme(0x" String -> ShowS
forall a. [a] -> [a] -> [a]
++ Word16 -> String
hex4 Word16
n String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
")"
{- FOURMOLU_ENABLE -}

-- | Four hexadecimal digits, as the IANA registry writes a code point.
hex4 :: Word16 -> String
hex4 :: Word16 -> String
hex4 Word16
n = Int -> Char -> String
forall a. Int -> a -> [a]
replicate (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
- String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
digits) Char
'0' String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
digits
  where
    digits :: String
digits = Word16 -> ShowS
forall a. Integral a => a -> ShowS
showHex Word16
n String
""

-- | Is this one of the ML-DSA schemes?  They are TLS 1.3 only, so the
-- TLS 1.2 paths filter them out and refuse one that arrives anyway.
isMLDSA :: SignatureScheme -> Bool
isMLDSA :: SignatureScheme -> Bool
isMLDSA SignatureScheme
MLDSA44 = Bool
True
isMLDSA SignatureScheme
MLDSA65 = Bool
True
isMLDSA SignatureScheme
MLDSA87 = Bool
True
isMLDSA SignatureScheme
_ = Bool
False

{- FOURMOLU_DISABLE -}
-- | What a signature scheme used to be called, when it was a pair.
--
-- Kept so that code which only names the type goes on compiling.  Code that
-- took the pair apart cannot be helped by a synonym and has to say which
-- scheme it meant.
type HashAndSignatureAlgorithm = SignatureScheme
{-# DEPRECATED HashAndSignatureAlgorithm "Use SignatureScheme" #-}

-- | The schemes an RSA key signs under with PKCS#1 v1.5.
rsaPkcs1Schemes :: [SignatureScheme]
rsaPkcs1Schemes :: [SignatureScheme]
rsaPkcs1Schemes =
    [ SignatureScheme
RSA_PKCS1_MD5
    , SignatureScheme
RSA_PKCS1_SHA1
    , SignatureScheme
RSA_PKCS1_SHA224
    , SignatureScheme
RSA_PKCS1_SHA256
    , SignatureScheme
RSA_PKCS1_SHA384
    , SignatureScheme
RSA_PKCS1_SHA512
    ]

-- | The schemes an RSA key signs under with PSS, under either kind of key.
rsaPssSchemes :: [SignatureScheme]
rsaPssSchemes :: [SignatureScheme]
rsaPssSchemes =
    [ SignatureScheme
RSA_PSS_RSAE_SHA256
    , SignatureScheme
RSA_PSS_RSAE_SHA384
    , SignatureScheme
RSA_PSS_RSAE_SHA512
    , SignatureScheme
RSA_PSS_PSS_SHA256
    , SignatureScheme
RSA_PSS_PSS_SHA384
    , SignatureScheme
RSA_PSS_PSS_SHA512
    ]

-- | The schemes a DSA key signs under.
dsaSchemes :: [SignatureScheme]
dsaSchemes :: [SignatureScheme]
dsaSchemes =
    [ SignatureScheme
DSA_MD5
    , SignatureScheme
DSA_SHA1
    , SignatureScheme
DSA_SHA224
    , SignatureScheme
DSA_SHA256
    , SignatureScheme
DSA_SHA384
    , SignatureScheme
DSA_SHA512
    ]

-- | The schemes an ECDSA key signs under.
ecdsaSchemes :: [SignatureScheme]
ecdsaSchemes :: [SignatureScheme]
ecdsaSchemes =
    [ SignatureScheme
ECDSA_MD5
    , SignatureScheme
ECDSA_SHA1
    , SignatureScheme
ECDSA_SHA224
    , SignatureScheme
ECDSA_SECP256R1_SHA256
    , SignatureScheme
ECDSA_SECP384R1_SHA384
    , SignatureScheme
ECDSA_SECP521R1_SHA512
    ]

-- | What this library offers, best first.
supportedSignatureSchemes :: [SignatureScheme]
supportedSignatureSchemes :: [SignatureScheme]
supportedSignatureSchemes =
    -- ML-DSA, TLS 1.3 only
    [ SignatureScheme
MLDSA87
    , SignatureScheme
MLDSA65
    , SignatureScheme
MLDSA44
    -- EdDSA
    , SignatureScheme
ED448
    , SignatureScheme
ED25519
    -- ECDSA
    , SignatureScheme
ECDSA_SECP521R1_SHA512
    , SignatureScheme
ECDSA_SECP384R1_SHA384
    , SignatureScheme
ECDSA_SECP256R1_SHA256
    -- RSASSA-PSS with an RSAE key
    , SignatureScheme
RSA_PSS_RSAE_SHA512
    , SignatureScheme
RSA_PSS_RSAE_SHA384
    , SignatureScheme
RSA_PSS_RSAE_SHA256
    -- RSASSA-PSS with a PSS key
    , SignatureScheme
RSA_PSS_PSS_SHA512
    , SignatureScheme
RSA_PSS_PSS_SHA384
    , SignatureScheme
RSA_PSS_PSS_SHA256
    -- RSASSA-PKCS1-v1_5
    , SignatureScheme
RSA_PKCS1_SHA512
    , SignatureScheme
RSA_PKCS1_SHA384
    , SignatureScheme
RSA_PKCS1_SHA256
    -- Legacy
    , SignatureScheme
RSA_PKCS1_SHA1
    , SignatureScheme
ECDSA_SHA1
    ]

-- | The subset of 'supportedSignatureSchemes' that TLS 1.3 allows in
-- CertificateVerify.  RFC 8446 section 4.2.3 defines the
-- RSASSA-PKCS1-v1_5 schemes, and the two SHA-1 ones, for signatures in
-- certificates only.
signatureSchemesForTLS13 :: [SignatureScheme]
signatureSchemesForTLS13 :: [SignatureScheme]
signatureSchemesForTLS13 =
    [ SignatureScheme
MLDSA87
    , SignatureScheme
MLDSA65
    , SignatureScheme
MLDSA44
    , SignatureScheme
ED448
    , SignatureScheme
ED25519
    , SignatureScheme
ECDSA_SECP521R1_SHA512
    , SignatureScheme
ECDSA_SECP384R1_SHA384
    , SignatureScheme
ECDSA_SECP256R1_SHA256
    , SignatureScheme
RSA_PSS_RSAE_SHA512
    , SignatureScheme
RSA_PSS_RSAE_SHA384
    , SignatureScheme
RSA_PSS_RSAE_SHA256
    , SignatureScheme
RSA_PSS_PSS_SHA512
    , SignatureScheme
RSA_PSS_PSS_SHA384
    , SignatureScheme
RSA_PSS_PSS_SHA256
    ]
{- FOURMOLU_ENABLE -}