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

Crypto.WebAuthn.Cose.Key

Description

This module contains a partial implementation of the COSE_Key format, limited to what is needed for Webauthn, and in a structured way.

Synopsis

COSE public Key

data CosePublicKey Source #

(spec) A structured representation of a COSE_Key limited to what is know to be necessary for Webauthn public keys for the credentialPublicKey field. Constructors represent signature algorithms.

Constructors

CosePublicKeyEdDSA

(spec) EdDSA Signature Algorithm

RFC8032 describes the elliptic curve signature scheme Edwards-curve Digital Signature Algorithm (EdDSA). In that document, the signature algorithm is instantiated using parameters for edwards25519 and edwards448 curves. The document additionally describes two variants of the EdDSA algorithm: Pure EdDSA, where no hash function is applied to the content before signing, and HashEdDSA, where a hash function is applied to the content before signing and the result of that hash function is signed. For EdDSA, the content to be signed (either the message or the pre-hash value) is processed twice inside of the signature algorithm. For use with COSE, only the pure EdDSA version is used.

Security considerations are here

Fields

CosePublicKeyECDSA

(spec) ECDSA Signature Algorithm

This document defines ECDSA to work only with the curves P-256, P-384, and P-521. Future documents may define it to work with other curves and points in the future.

In order to promote interoperability, it is suggested that SHA-256 be used only with curve P-256, SHA-384 be used only with curve P-384, and SHA-512 be used with curve P-521. This is aligned with the recommendation in Section 4 of RFC5480.

Security considerations are here

Fields

  • ecdsaHash :: CoseHashAlgECDSA

    The hash function to use

  • 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.

CosePublicKeyRSA

(spec) RSASSA-PKCS1-v1_5 Signature Algorithm

A key of size 2048 bits or larger MUST be used with these algorithms. Security considerations are here

Fields

  • rsaHash :: CoseHashAlgRSA

    The hash function to use

  • 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 CosePublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Show CosePublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Generic CosePublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Associated Types

type Rep CosePublicKey :: Type -> Type #

ToJSON CosePublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Serialise CosePublicKey Source #

CBOR encoding as a COSE_Key using the CTAP2 canonical CBOR encoding form

Instance details

Defined in Crypto.WebAuthn.Cose.Key

type Rep CosePublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

keySignAlg :: CosePublicKey -> CoseSignAlg Source #

The COSE signing algorithm corresponding to a COSE public key

COSE Elliptic Curves

data CoseCurveEdDSA Source #

COSE elliptic curves that can be used with EdDSA

Constructors

CoseCurveEd25519

(spec) Ed25519 for use w/ EdDSA only

Instances

Instances details
Bounded CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Enum CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Eq CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Show CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Generic CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Associated Types

type Rep CoseCurveEdDSA :: Type -> Type #

ToJSON CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

type Rep CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

type Rep CoseCurveEdDSA = D1 ('MetaData "CoseCurveEdDSA" "Crypto.WebAuthn.Cose.Key" "webauthn-0.1.0.0-inplace" 'False) (C1 ('MetaCons "CoseCurveEd25519" 'PrefixI 'False) (U1 :: Type -> Type))

data CoseCurveECDSA Source #

COSE elliptic curves that can be used with ECDSA

Constructors

CoseCurveP256

(spec) NIST P-256 also known as secp256r1

CoseCurveP384

(spec) NIST P-384 also known as secp384r1

CoseCurveP521

(spec) NIST P-521 also known as secp521r1

Instances

Instances details
Bounded CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Enum CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Eq CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Show CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Generic CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

Associated Types

type Rep CoseCurveECDSA :: Type -> Type #

ToJSON CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

type Rep CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.Key

type Rep CoseCurveECDSA = D1 ('MetaData "CoseCurveECDSA" "Crypto.WebAuthn.Cose.Key" "webauthn-0.1.0.0-inplace" 'False) (C1 ('MetaCons "CoseCurveP256" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CoseCurveP384" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CoseCurveP521" 'PrefixI 'False) (U1 :: Type -> Type)))