webauthn-0.5.0.1: Relying party (server) implementation of the WebAuthn 2 specification
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Crypto.WebAuthn.Cose.PublicKey

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

Public key

data UncheckedPublicKey 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, and without any signing algorithm parameters like hashes. Due to the raw nature of parameters, this type is labeled as unchecked. Parameters are checked by using the checkPublicKey function, returning a PublicKey type.

Constructors

PublicKeyEdDSA

(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

PublicKeyECDSA

(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

  • ecdsaCurve :: CoseCurveECDSA

    (spec) The elliptic curve to use

  • ecdsaX :: Integer

    (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 :: Integer

    (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

(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

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

Defined in Crypto.WebAuthn.Cose.PublicKey

Generic UncheckedPublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Associated Types

type Rep UncheckedPublicKey :: Type -> Type #

Show UncheckedPublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Eq UncheckedPublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

type Rep UncheckedPublicKey Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

checkPublicKey :: UncheckedPublicKey -> Either Text PublicKey Source #

Checks whether an UncheckedPublicKey is valid. This is the only way to construct a PublicKey

data PublicKey where Source #

Same as UncheckedPublicKey, but checked to be valid using checkPublicKey.

Bundled Patterns

pattern PublicKey :: UncheckedPublicKey -> PublicKey

Returns the UncheckedPublicKey for a PublicKey

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
ToJSON CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Bounded CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Enum CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Generic CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Associated Types

type Rep CoseCurveEdDSA :: Type -> Type #

Show CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Eq CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

type Rep CoseCurveEdDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

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

coordinateSizeEdDSA :: CoseCurveEdDSA -> Int Source #

Returns the size of a coordinate point for a specific EdDSA curve in bytes.

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
ToJSON CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Bounded CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Enum CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Generic CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Associated Types

type Rep CoseCurveECDSA :: Type -> Type #

Show CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

Eq CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

type Rep CoseCurveECDSA Source # 
Instance details

Defined in Crypto.WebAuthn.Cose.PublicKey

type Rep CoseCurveECDSA = D1 ('MetaData "CoseCurveECDSA" "Crypto.WebAuthn.Cose.PublicKey" "webauthn-0.5.0.1-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)))

coordinateSizeECDSA :: CoseCurveECDSA -> Int Source #

Returns the size of a coordinate point for a specific ECDSA curve in bytes.