crypto

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package crypto implements cryptographic operations for CTAP PIN/UV and large-blob workflows.

Index

Constants

View Source
const MaxLargeBlobDataSize uint = 1 << 20

Variables

View Source
var (
	ErrInvalidAuthProtocol = errors.New("invalid auth protocol")
)

Functions

func Authenticate

func Authenticate(number protocol.PinUvAuthProtocol, sharedSecret []byte, message []byte) []byte

func CompressLargeBlobData

func CompressLargeBlobData(data []byte) ([]byte, error)

CompressLargeBlobData applies the raw DEFLATE encoding required by the CTAP largeBlob extension.

func DecompressLargeBlobData

func DecompressLargeBlobData(compressed []byte, originalSize uint) ([]byte, error)

DecompressLargeBlobData decodes raw DEFLATE data and verifies the size reported by the authenticator. The limit prevents decompression bombs.

func DecryptCredentialStoreState

func DecryptCredentialStoreState(
	persistentPinUvAuthToken,
	encCredStoreState []byte,
) ([getInfoEncryptedMemberPlaintextSize]byte, error)

DecryptCredentialStoreState decrypts the credential store state returned in authenticatorGetInfo's encCredStoreState member.

func DecryptDeviceIdentifier

func DecryptDeviceIdentifier(
	persistentPinUvAuthToken,
	encIdentifier []byte,
) ([getInfoEncryptedMemberPlaintextSize]byte, error)

DecryptDeviceIdentifier decrypts the device identifier returned in authenticatorGetInfo's encIdentifier member.

func DecryptLargeBlob

func DecryptLargeBlob(key []byte, blob protocol.LargeBlob) ([]byte, error)

func EncryptLargeBlob

func EncryptLargeBlob(key []byte, origData []byte) (protocol.LargeBlob, error)

func OpenLargeBlob

func OpenLargeBlob(key []byte, blob protocol.LargeBlob) ([]byte, error)

OpenLargeBlob authenticates and decrypts a large-blob array element without decompressing its plaintext. Callers that scan an array can use a successful return to distinguish an AEAD key match from a malformed DEFLATE stream.

Types

type PinUvAuthProtocol

type PinUvAuthProtocol struct {
	Number protocol.PinUvAuthProtocol
	// contains filtered or unexported fields
}

func NewPinUvAuthProtocol

func NewPinUvAuthProtocol(number protocol.PinUvAuthProtocol) (*PinUvAuthProtocol, error)

func (*PinUvAuthProtocol) Decrypt

func (p *PinUvAuthProtocol) Decrypt(sharedSecret []byte, demCiphertext []byte) ([]byte, error)

func (*PinUvAuthProtocol) ECDH

func (p *PinUvAuthProtocol) ECDH(peerCoseKey cose.Key) ([]byte, error)

ECDH returns a caller-owned derived shared secret.

func (*PinUvAuthProtocol) Encapsulate

func (p *PinUvAuthProtocol) Encapsulate(peerCoseKey cose.Key) (cose.Key, []byte, error)

Encapsulate returns the platform public key and a caller-owned derived shared secret.

func (*PinUvAuthProtocol) Encrypt

func (p *PinUvAuthProtocol) Encrypt(sharedSecret []byte, demPlaintext []byte) ([]byte, error)

func (*PinUvAuthProtocol) KDF

func (p *PinUvAuthProtocol) KDF(z []byte) ([]byte, error)

Directories

Path Synopsis
Package protocolone implements PIN/UV Auth Protocol One cryptographic operations.
Package protocolone implements PIN/UV Auth Protocol One cryptographic operations.
Package protocoltwo implements PIN/UV Auth Protocol Two cryptographic operations.
Package protocoltwo implements PIN/UV Auth Protocol Two cryptographic operations.

Jump to

Keyboard shortcuts

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