webauthn-0.1.0.0: Relying party (server) implementation of the WebAuthn 2 specification
Stabilityinternal
Safe HaskellNone
LanguageHaskell2010

Crypto.WebAuthn.Cose.Internal.Verify

Description

public keys and signature algorithms are represented with three different types:

  • CoseSignAlg, which is the signature algorithm used, equivalent to a COSE Algorithm from the COSE registry
  • CosePublicKey, which is a combination of a CoseSignAlg along with a public key that can be used with it. This is what the COSE_Key CBOR structure decodes to
  • PublicKey, only the public key part of CosePublicKey

The following main operations are supported for these types:

Synopsis

Public Key

data PublicKey Source #

Same as CosePublicKey, but without signature algorithm parameters, i.e. hash algorithms.

Constructors

PublicKeyEdDSA

See CosePublicKeyEdDSA

Fields

PublicKeyECDSA

See CosePublicKeyECDSA

Fields

  • ecdsaCurve :: CoseCurveECDSA

    (spec) The elliptic curve to use

  • ecdsaX :: ByteString

    (spec) This contains the x-coordinate for the EC point. The integer is converted to a byte string as defined in [SEC1]. Leading zero octets MUST be preserved.

  • ecdsaY :: ByteString

    (spec) This contains the value of the y-coordinate for the EC point. When encoding the value y, the integer is converted to an byte string (as defined in SEC1) and encoded as a CBOR bstr. Leading zero octets MUST be preserved.

PublicKeyRSA

See CosePublicKeyRSA

Fields

  • rsaN :: Integer

    (spec) The RSA modulus n is a product of u distinct odd primes r_i, i = 1, 2, ..., u, where u >= 2

  • rsaE :: Integer

    (spec) The RSA public exponent e is an integer between 3 and n - 1 satisfying GCD(e,\lambda(n)) = 1, where \lambda(n) = LCM(r_1 - 1, ..., r_u - 1)

Instances

Instances details
Eq PublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Internal.Verify

Show PublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Internal.Verify

Generic PublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Internal.Verify

Associated Types

type Rep PublicKey :: Type -> Type #

ToJSON PublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Internal.Verify

type Rep PublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Internal.Verify

fromCose :: CosePublicKey -> PublicKey Source #

Turns a CosePublicKey into a PublicKey by removing the hash functions

fromX509 :: PubKey -> Either Text PublicKey Source #

Turns a X.509 certificates PubKey into a PublicKey

Signature verification

verify :: CoseSignAlg -> PublicKey -> ByteString -> ByteString -> Either Text () Source #

Verifies an asymmetric signature for a message using a CoseSignAlg and a PublicKey. Returns an error if the signature algorithm doesn't match. Also returns an error if the signature wasn't valid or for other errors.

Hash Conversions to cryptonite types

data SomeHashAlgorithm Source #

Some cryptonite HashAlgorithm type, used as a return value of toCryptHashECDSA

Constructors

forall a.HashAlgorithm a => SomeHashAlgorithm a 

toCryptHashECDSA :: CoseHashAlgECDSA -> SomeHashAlgorithm Source #

Returns the cryptonite SomeHashAlgorithm corresponding to this hash algorithm

data SomeHashAlgorithmASN1 Source #

Some cryptonite HashAlgorithmASN1 type, used as a return value of toCryptHashRSA

Constructors

forall a.HashAlgorithmASN1 a => SomeHashAlgorithmASN1 a 

toCryptHashRSA :: CoseHashAlgRSA -> SomeHashAlgorithmASN1 Source #

Returns the cryptonite SomeHashAlgorithmASN1 corresponding to this hash algorithm

Conversions from/to cryptonite elliptic curves