passkey

package
v0.0.0-...-de2f639 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	ID       string
	Response struct {
		AuthenticatorDataRaw RawURLBase64       `json:"authenticatorData"`
		AuthenticatorData    *AuthenticatorData `json:"-"`
		ClientDataJSON       RawURLBase64       `json:"clientDataJSON"`
		ClientData           ClientData         `json:"-"`
		Signature            RawURLBase64       `json:"signature"`
		VerifiableBytes      []byte             `json:"-"`
	} `json:"response"`
}

Assertion is the CredentialRequestResponse containing the Authenticator Data

func ParseAssertion

func ParseAssertion(credentialRequestResponse []byte) (*Assertion, error)

type AttestedCredentialData

type AttestedCredentialData struct {
	AAGUID        []byte
	CredentialID  []byte
	PublicKeyCBOR []byte
}

AttestedCredentialData represents the structure of attested credential data

func ParseAttestedCredentialData

func ParseAttestedCredentialData(reader *bytes.Reader) (*AttestedCredentialData, error)

ParseAttestedCredentialData parses the attested credential data from the reader

type AuthenticatorData

type AuthenticatorData struct {
	RPIDHash               []byte
	Flags                  Flags
	SignCount              uint32
	AttestedCredentialData *AttestedCredentialData
	Extensions             []byte
}

AuthenticatorData represents the authenticator device or service

func ParseAuthenticatorData

func ParseAuthenticatorData(authData []byte) (*AuthenticatorData, error)

ParseAuthenticatorData parses the AuthenticatorData from decoded base64

type ClientData

type ClientData struct {
	Type      string `json:"type"`
	Challenge string `json:"challenge"`
	Origin    string `json:"origin"`
}

type Flags

type Flags byte

Flags represents the flags byte in the authenticatorData

const (
	FlagUP Flags = 1 << 0 // User presence tested

	FlagUV Flags = 1 << 2 // User verification performed
	FlagBE Flags = 1 << 3 // Backup Eligible (Multi Device)
	FlagBS Flags = 1 << 4 // Backup State (e.g. saved to iCloud)

	FlagAT Flags = 1 << 6 // Attested credential data included
	FlagED Flags = 1 << 7 // Extension data included
)

func (Flags) HasAttestedCredentialData

func (f Flags) HasAttestedCredentialData() bool

HasAttestedCredentialData (6:AT) is true when additional data is attached

func (Flags) HasExtensionData

func (f Flags) HasExtensionData() bool

HasExtensionData (7:ED) is true when data about extensions is present

func (Flags) IsBackedUp

func (f Flags) IsBackedUp() bool

IsBackedUp (4:BS) true if Browser Sync, iCloud, etc is active "Backup State"

func (Flags) IsMultiDeviceCredential

func (f Flags) IsMultiDeviceCredential() bool

IsMultiDeviceCredential (3:BE) true for Browser Sync, iCloud, etc - "Backup Eligible"

func (Flags) IsUserPresent

func (f Flags) IsUserPresent() bool

IsUserPresent (0:UP) is true if the user is physically detected (NFC, Touch, BLE, etc)

func (Flags) String

func (f Flags) String() string

String returns a string representation of the Flags with human-readable status

func (Flags) UserVerified

func (f Flags) UserVerified() bool

UserVerified (2:UV) is true when the user verified via password, PIN, Touch, Face, etc

type RawURLBase64

type RawURLBase64 []byte

RawURLBase64 is a newtype of string for base64 encoding

func (RawURLBase64) MarshalJSON

func (b RawURLBase64) MarshalJSON() ([]byte, error)

MarshalJSON encodes the Base64 as a base64 byte array

func (*RawURLBase64) UnmarshalJSON

func (b *RawURLBase64) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a base64 byte array into the Base64

type Registration

type Registration struct {
	ID       string
	Response struct {
		AttestationCBOR       RawURLBase64       `json:"attestationObject"`
		AuthenticatorDataRaw  RawURLBase64       `json:"authenticatorData"`
		AuthenticatorData     *AuthenticatorData `json:"-"`
		ClientDataJSON        RawURLBase64       `json:"clientDataJSON"`
		ClientData            ClientData         `json:"-"`
		PublicKeyAlgorithmInt int                `json:"publicKeyAlgorithm"`
		PublicKeyAlgorithm    string             `json:"publicKeyAlgorithmName"`
		PublicKeyDER          RawURLBase64       `json:"publicKey"`
		PublicKeyECDSA        *ecdsa.PublicKey   `json:"-"`
		Transports            []string           `json:"transports"`
	} `json:"response"`
}

Registration is the CredentialCreationResponse containing the Attestation Object and PublicKey

func ParseRegistration

func ParseRegistration(credentialCreationResponse []byte) (*Registration, error)

Jump to

Keyboard shortcuts

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