cose

package
v1.0.0-dev.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package cose reads a WebAuthn credential public key, a COSE_Key (RFC 9052 §7), for the algorithms access offers, and verifies an assertion or self attestation signature under it. Each algorithm has one exact label set (WebAuthn §6.5.1: alg is required and no other optional parameter is allowed), so a key carrying a private member or any extra label is refused.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported = errors.New("cose: algorithm or curve not offered")
	ErrMalformed   = errors.New("cose: malformed credential public key")
	ErrSignature   = errors.New("cose: signature does not verify")
)

The refusals, matched with errors.Is.

Functions

func Offered

func Offered() []int

Offered returns the COSE algorithm identifiers access offers, in its preference order.

Types

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a parsed credential public key; the zero Key verifies nothing.

func ParseKey

func ParseKey(raw []byte) (*Key, error)

ParseKey reads raw as exactly one COSE_Key with no byte after it, and the key keeps no reference to raw. An algorithm or curve access does not offer is ErrUnsupported; any other refusal is ErrMalformed.

func (*Key) Algorithm

func (k *Key) Algorithm() int

Algorithm returns the key's COSE algorithm identifier.

func (*Key) Verify

func (k *Key) Verify(authData []byte, clientDataHash [sha256.Size]byte, sig []byte) error

Verify checks sig over authData ‖ clientDataHash, the message both an assertion (WebAuthn §7.2) and a self attestation (§8.2) sign, where clientDataHash is SHA-256 of the raw clientDataJSON. It returns nil or an error matching ErrSignature.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL