go-ctaphid is an idiomatic Go library implementing the CTAPHID transport protocol to interact with FIDO2 authenticators, featuring a clean, modern API with multiple layers of abstraction.
Warning
Work in progress! API may change during v0.x
!
Library supports almost entire CTAP 2.2 specification, except few extensions which are not yet seen in the wild
(hmac-secret-mc
, dedicated largeBlob
, not to be confused with largeBlobKey
which is supported).
My current priorities are to write better tests and replace sstallion/go-hid
with the own cgo
-free alternative.
The library exposes several abstraction levels, allowing you to choose the API that best suits your needs:
-
Transport Layer (
ctaphid
)Direct access to the raw CTAPHID transport protocol. If you need maximum control, you can communicate with devices at the frame level.
-
Protocol Layer (
ctap
)Implements CTAP 2.2 protocol messaging atop the transport, letting you work with high-level commands and CBOR-encoded messages.
-
Device Abstraction (
device
)Provides a convenient wrapper over the
ctap
package, managing device descriptor and abstracting channel (CID) management, so you don’t have to handle these low-level details manually. -
Scenario Helpers (
sugar
) (Mostly TODO now)A growing set of utility functions for common use-cases. These helpers streamline trivial or repetitive scenarios, letting you get started quickly without deep protocol knowledge.
- Implements major FIDO2 commands: MakeCredential, GetAssertion, ClientPIN (with both PIN/UV methods), Reset, CredentialManagement, and more.
- Both low-level access and ergonomic, high-level APIs.
- Modern Go design, making use of language features like iterators.
cgo
is currently used for HID transport, but FIDO2 protocol logic is pure Go.
- MakeCredential
- GetAssertion / GetNextAssertion
- GetInfo
- ClientPIN
- getPINRetries
- getKeyAgreement
- setPIN
- changePIN
- getPinToken
- getPinUvAuthTokenUsingUvWithPermissions
- getUVRetries
- getPinUvAuthTokenUsingPinWithPermissions
- Reset
- BioEnrollment
- enrollBegin
- enrollCaptureNextSample
- cancelCurrentEnrollment
- enumerateEnrollments
- setFriendlyName
- removeEnrollment
- getFingerprintSensorInfo
- CredentialManagement
- getCredsMetadata
- enumerateRPsBegin / enumerateRPsGetNextRP
- enumerateCredentialsBegin / enumerateCredentialsGetNextCredential
- deleteCredential
- updateUserInformation
- Selection
- LargeBlobs
- raw get
- raw set
- get serialized large-blob array
- set serialized large-blob array
- Config
- enableEnterpriseAttestation
- toggleAlwaysUv
- setMinPINLength
- Prototype BioEnrollment
- Prototype CredentialManagement
- credProtect
- credBlob
- largeBlobKey
- largeBlob
- minPinLength
- pinComplexityPolicy
- hmac-secret
- hmac-secret-mc
- thirdPartyPayment
- credProps
- prf
- largeBlob
- PIN/UV Auth Protocol One
- PIN/UV Auth Protocol Two
- Encrypt/Decrypt using
LargeBlobsKey
extension
For Linux systems, you'll need to install the following packages to build:
libudev-dev
: udev device management librarylibusb-1.0-0-dev
: USB device access library
- Better tests (using virtual authenticator?)
- Extended "sugar" helpers for common use-cases.
-
cgo
-free version. See go-hid.