Table of Contents

Class VerifyPinResponse

Namespace
Yubico.YubiKey.Piv.Commands
Assembly
Yubico.YubiKey.dll

The response to verifying the PIN.

public sealed class VerifyPinResponse : PivResponse, IYubiKeyResponseWithData<int?>, IYubiKeyResponse
Inheritance
object
VerifyPinResponse
Implements
Inherited Members

Remarks

This is the partner Response class to VerifyPinCommand.

To determine the result of the command, first look at the Status. If Status is not one of the following values then an error has occurred and GetData() will throw an exception.

StatusDescription
SuccessThe PIN verified. GetData returns null.
AuthenticationRequiredThe PIN did not verify. GetData returns the number of retries remaining. If the number of retries is 0, the PIN is blocked.

Example:

/* This example assumes the application has a method to collect a PIN.
 */
byte[] pin;

IYubiKeyConnection connection = key.Connect(YubiKeyApplication.Piv);
pin = CollectPin();
var verifyPinCommand = new VerifyPinCommand(pin);
VerifyPinResponse verifyPinResponse = connection.SendCommand(verifyPinCommand);
if (resetRetryResponse.Status == ResponseStatus.AuthenticationRequired)
{
  int retryCount = resetRetryResponse.GetData();
  /* report the retry count */
}
else if (verifyPinResponse.Status != ResponseStatus.Success)
{
  // Handle error
}

CryptographicOperations.ZeroMemory(pin)

Constructors

VerifyPinResponse(ResponseApdu)

Constructs a VerifyPinResponse based on a ResponseApdu received from the YubiKey.

public VerifyPinResponse(ResponseApdu responseApdu)

Parameters

responseApdu ResponseApdu

The object containing the response APDU
returned by the YubiKey.

Properties

StatusCodeMap

Retrieves the details describing the processing state.

protected override YubiKeyResponse.ResponseStatusPair StatusCodeMap { get; }

Property Value

YubiKeyResponse.ResponseStatusPair

The ResponseStatus and a descriptive message, as a YubiKeyResponse.ResponseStatusPair.

Remarks

Implementers of subtypes can override this member to change or add mappings.

Methods

GetData()

Gets the number of PIN retries remaining, if applicable.

public int? GetData()

Returns

int?

null if the PIN verifies, or the number of retries remaining if the PIN does not verify.

Remarks

First look at the Status. If Status is not one of the following values then an error has occurred and GetData() will throw an exception.

StatusDescription
SuccessThe PIN verified. GetData returns null.
AuthenticationRequiredThe PIN did not verify. GetData returns the number of retries remaining. If the number of retries is 0, the PIN is blocked.

Exceptions

InvalidOperationException

Thrown if Status is not Success or AuthenticationRequired.