SetAccessCode Method
SetAccessCode(ReadOnlySpan<Byte>)
An access code that can be used to protect the slot configuration.
public void SetAccessCode(ReadOnlySpan<byte> accessCode)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlySpan<System.Byte> | accessCode | The value to use as the access code for the new configuration. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if the access code length doesn't equal Yubico.YubiKey.Otp.Commands.SlotConfigureBase.AccessCodeLength. |
Remarks
It should be noted that setting an access code will lock the ability to modify the configuration of the slot. There is no way to recover usage of the slot if the access code is lost or forgotten. It is important to stress this potential pitfall when designing any application or process that relies on this feature.
If a configurable slot already has an access code and you need to apply it to a new configuration, call the ApplyCurrentAccessCode(ReadOnlySpan<Byte>) method. The value specified by SetAccessCode will be the code used to protect the slot after the configuration has been applied.
Note that if the slot is already protected by an access code, and you wish to have the same access code remain, both ApplyCurrentAccessCode and SetAccessCode must be called with the same value. Failure to call SetAccessCode will effectively cause the newly applied configuration to be unprotected.
Setting the access code to all zeros is equivalent to not setting an access code. The slot will not be protected.