Class ChangeReferenceDataResponse
The response to changing the PIN or PUK.
public sealed class ChangeReferenceDataResponse : PivResponse, IYubiKeyResponseWithData<int?>, IYubiKeyResponse
- Inheritance
-
objectChangeReferenceDataResponse
- Implements
-
IYubiKeyResponseWithData<int?>
- Inherited Members
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.
Status | Description |
---|---|
Success | The PIN or PUK was successfully changed. GetData returns
null . |
AuthenticationRequired | The 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
ChangeReferenceDataResponse(ResponseApdu)
Constructs a ChangeReferenceDataResponse based on a ResponseApdu received from the YubiKey.
public ChangeReferenceDataResponse(ResponseApdu responseApdu)
Parameters
responseApdu
ResponseApduThe 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 or PUK retries remaining, if applicable.
public int? GetData()
Returns
- int?
null
if the PIN/PUK was successfully changed, or the number of retries remaining if the current PIN/PUK did 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.
Status | Description |
---|---|
Success | The PIN or PUK was successfully changed. GetData returns
null . |
AuthenticationRequired | The 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. |
Exceptions
- InvalidOperationException
Thrown if Status is not Success or AuthenticationRequired.