Show / Hide Table of Contents

ChangeReferenceDataResponse Class

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

The response to changing the PIN or PUK.

C#
public sealed class ChangeReferenceDataResponse : PivResponse, IYubiKeyResponseWithData<int?>, IYubiKeyResponse
Inheritance object YubiKeyResponse PivResponse ChangeReferenceDataResponse
Implements
IYubiKeyResponseWithData<int?>
IYubiKeyResponse

Remarks

This is the partner Response class to ChangeReferenceDataCommand

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 or PUK was successfully changed. GetData returns null.
AuthenticationRequiredThe PIN or PUK did not verify. GetData returns the number of retries remaining. If the number of retries is 0, the PIN or PUK is blocked.

Example:

using System.Security.Cryptography;
/* This example assumes the application has a method to collect a
 * PIN/PUK.
 */
byte[] oldPuk;
byte[] newPuk;

IYubiKeyConnection connection = key.Connect(YubiKeyApplication.Piv);
oldPuk = CollectPuk();
newPuk = CollectNewPuk();
var changeReferenceDataCommand =
    new ChangeReferenceDataCommand(PivSlot.Puk, oldPuk, newPuk);
ChangeReferenceDataResponse changeReferenceDataResponse =
    connection.SendCommand(changeReferenceDataCommand);
if (changeReferenceDataResponse.Status != ResponseStatus.Success)
{
  if (resetRetryResponse.Status == ResponseStatus.AuthenticationRequired)
  {
      int retryCount = resetRetryResponse.GetData();
      /* report the retry count */
  }
  else
  {
      // Handle error
  }
}

CryptographicOperations.ZeroMemory(puk);
CryptographicOperations.ZeroMemory(newPuk);

Constructors

Name Description
ChangeReferenceDataResponse(ResponseApdu)

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

Properties

Name Description
StatusCodeMap

Retrieves the details describing the processing state.

Methods

Name Description
GetData()

Gets the number of PIN or PUK retries remaining, if applicable.

In this article
Back to top Generated by DocFX