hwsecurity / de.cotech.hw / SecurityKeyAuthenticator /

SecurityKeyAuthenticator

interface SecurityKeyAuthenticator

This use case class performs an “authenticate” operation on a challenge.

Instances of this class can be obtained from SecurityKey objects for Security Key types that support it. For Security Keys that contain more than possible key for authentication operations, each instance of this class is already associated with a specific key.

Example:

byte[] challenge = { (byte) 1, (byte) 2, (byte) 3, (byte) 4 };
PinProvider pinProvider = StaticPinProvider.getInstance(ByteSecret.unsafeFromString("123456"));

SecurityKeyAuthenticator securityKeyAuthenticator = securityKey.createSecurityKeyAuthenticator(pinProvider)
byte[] signatureBytes = authenticator.authenticateWithDigest(challenge, "SHA-1");

Signature signature = Signature.getInstance("SHA1withRSA");
signature.initVerify(securityKeyAuthenticator.retrievePublicKey());
signature.update(challenge);
boolean isVerified = signature.verify(signatureBytes);
assert isVerified;

Functions

Name Summary
authenticatePresignedDigest

abstract fun authenticatePresignedDigest(digest: Array<Byte>, hashAlgo: String): Array<Byte>

Authenticate a digest by signing it with the Security Key’s authentication key.

authenticateWithDigest

abstract fun authenticateWithDigest(challenge: Array<Byte>, hashAlgo: String): Array<Byte>

Authenticate a challenge, by hashing it with the given hashing algorithm and signing it with the Security Key’sauthentication key.

retrieveCertificateData

abstract fun retrieveCertificateData(): Array<Byte>

Read associated certificate data from the Security Key.

retrievePublicKey

abstract fun retrievePublicKey(): PublicKey

Retrieve the public key associated to this authenticator from the Security Key as a JCA PublicKey object.