Show / Hide Table of Contents

AuthenticateUsingPinToken Method

AuthenticateUsingPinToken(byte[], byte[])

Returns the result of computing HMAC-SHA-256 on the given message using the pinToken as the key. With protocol 1, the result is the first 16 bytes of the HMAC, and with protocol 2 it is the entire 32-byte result.

C#
public byte[] AuthenticateUsingPinToken(byte[] pinToken, byte[] message)

Parameters

Type Name Description
byte[] pinToken

The PIN token returned by the YubiKey. This is the encrypted value, do not decrypt it.

byte[] message

The data to be authenticated.

Returns

byte[]

A new byte array containing the authentication result.

Exceptions

Type Condition
ArgumentNullException

The pinToken or message argument is null.

InvalidOperationException

The object has been created or initialized, but the Encapsulate(CoseKey) method has not been called.

Remarks

It is possible to obtain the PIN token by calling the command GetPinTokenCommand. The YubiKey will return the PIN token encrypted using the shared secret.

Pass that encrypted PIN token to this method as the first argument. This method will decrypt the PIN token using the EncryptionKey and then perform the authentication on the message.

AuthenticateUsingPinToken(byte[], int, int, byte[])

Returns the result of computing HMAC-SHA-256 on the given message using the pinToken as the key. With protocol 1, the result is the first 16 bytes of the HMAC, and with protocol 2 it is the entire 32-byte result.

C#
public virtual byte[] AuthenticateUsingPinToken(byte[] pinToken, int offset, int length, byte[] message)

Parameters

Type Name Description
byte[] pinToken

The PIN token returned by the YubiKey. This is the encrypted value, do not decrypt it.

int offset

The offset into pinToken buffer where the data begins.

int length

The length, in bytes, of the pin token.

byte[] message

The data to be authenticated.

Returns

byte[]

A new byte array containing the authentication result.

Exceptions

Type Condition
ArgumentNullException

The pinToken or message argument is null.

InvalidOperationException

The object has been created or initialized, but the Encapsulate(CoseKey) method has not been called.

Remarks

This is the same as AuthenticateUsingPinToken(byte[], byte[]), except this specifies an offset and length of the pinToken argument.

In this article
Back to top Generated by DocFX