dependencies {
implementation 'com.yubico.yubikit:android:(insert version here)'
implementation 'com.yubico.yubikit:fido:(insert version here)'
}
The FIDO module enables applications to authenticate WebAuthn credentials on a YubiKey.
The module is based on the CTAP 2.3 and WebAuthn Level 3 specifications. Its WebAuthn client is a building block for using a YubiKey from a WebAuthn client, not a complete WebAuthn client, and the module does not claim conformance to WebAuthn Level 3:
The application builds the client data (origin, crossOrigin, topOrigin) and passes the effective domain, so origin checks, public suffix checks and related origin requests are the application’s responsibility, as is enforcing the request timeout.
Browser and platform features, such as conditional mediation, the Signal API and getClientCapabilities(), are out of scope.
AuthenticatorAttestationResponse.getPublicKey() returns null when the SDK or the platform cannot encode the credential public key, which WebAuthn Level 3 allows. The algorithm and the attestation object are always returned.
To add the Fido module, along with the Android module as a dependencies to your project, add the following to your gradle configuration:
dependencies {
implementation 'com.yubico.yubikit:android:(insert version here)'
implementation 'com.yubico.yubikit:fido:(insert version here)'
}
This module depends on the core module, which will automatically be added as a transitive dependency to your project.
To communicate with the Fido application on a YubiKey, use the CtapSession class. The class provides constructors for Fido or SmartCard connections, as well as a factory method which takes a YubiKeyDevice and will use the best suited connection type available.
The SDK provides a WebAuthn client implementation which communicates with the YubiKey through CTAP1 and CTAP2 and can make new credentials or assert existing credentials. The client has also functionality for working with the PIN.
Credential operations provided by WebAuthnClient use classes which map to standard Webauthn types and allow easier interoperability with RPs.
For example PublicKeyCredential.toMap() returns a standard Java Map object which can be serialized to JSON representation:
CtapSession session = ...;
WebAuthnClient client = new WebAuthnClient(session);
PublicKeyCredential credential = client.makeCredential(params);
String response = JSONObject(credential.toMap()).toString();