Show / Hide Table of Contents

TryChangePinAndPukRetryCounts Method

TryChangePinAndPukRetryCounts(ReadOnlyMemory<byte>, ReadOnlyMemory<byte>, byte, byte, out int?)

Try to change the retry counts for both the PIN and PUK. This method will use the managementKey and pin provided.

Warning

This will reset the PIN and PUK to their default values as well as set the retry counts.

C#
public bool TryChangePinAndPukRetryCounts(ReadOnlyMemory<byte> managementKey, ReadOnlyMemory<byte> pin, byte newRetryCountPin, byte newRetryCountPuk, out int? retriesRemaining)

Parameters

Type Name Description
ReadOnlyMemory<byte> managementKey

The current management key. If it is Empty, the method will authenticate using PIN-only.

ReadOnlyMemory<byte> pin

The current PIN.

byte newRetryCountPin

The PIN's new retry count.

byte newRetryCountPuk

The PUK's new retry count.

int? retriesRemaining

An output, it will be set to the number of retries remaining if the PIN is not verified. If the management key is not authenticated or the PIN is verified, this will be set to null.

Returns

bool

A boolean, true if the retry counts are changed, false if not.

Exceptions

Type Condition
InvalidOperationException

The YubiKey had some error, such as unreliable connection.

SecurityException

The remaining retries count indicates the PIN is blocked.

Remarks

Normally, an application would call the ChangePinAndPukRetryCounts(int, int) method and the SDK would call on the loaded KeyCollector to retrieve the management key and PIN. With this method, the caller provides the management key and PIN and the KeyCollector is never contacted.

Some applications would like to avoid using a KeyCollector. For such situations, this method is provided.

See the ChangePinAndPukRetryCounts(byte, byte) method for further documentation on this method.

If the wrong management key or PIN is provided, this method will return false.

This method will authenticate the management key provided and verify the PIN provided, even if one or both have already been authenticated/verified.

If the YubiKey is configured for PIN-only, the managementKey argument will be ignored. In this case, you can pass in an empty management key: ReadOnlyMemory<byte>.Empty.

In this article
Back to top Generated by DocFX