You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Of these options, the **only** method that allows you to configure a slot access code without changing the slot's current cryptographic credential is ``UpdateSlot()``. However, calling ``UpdateSlot()`` will revert a number of other slot settings (such as ``SetAppendCarriageReturn()``) to their default states unless otherwise specified during the operation. See [How to update slot settings](xref:OtpUpdateSlot) for more information.
42
+
44
43
> [!NOTE]
45
44
> If a slot is configured with an access code,
46
45
> calling [ConfigureNdef()](xref:Yubico.YubiKey.Otp.OtpSession.ConfigureNdef%28Yubico.YubiKey.Otp.Slot%29) will fail,
@@ -49,17 +48,17 @@ Access codes can only be set, reset, or removed during another slot configuratio
49
48
> code,
50
49
> you cannot set one when calling ``ConfigureNdef()``.
The [SlotAccessCode](xref:Yubico.YubiKey.Otp.SlotAccessCode) container class pads the code with zeros (0x00) if less
57
54
than six bytes are provided and throws an exception if more than six bytes are provided.
58
55
59
56
If a slot is configured with an access code, that code must be specified during any reconfiguration operation. In
60
-
addition, if you don’t also resupply the same (or any) code as a "new" access code, an access code will not be carried
57
+
addition, if you don’t resupply the same (or any) code as a "new" access code, an access code will not be carried
61
58
over to the new slot configuration, and the slot will no longer be protected after reconfiguration.
62
59
60
+
If a slot is protected by an access code, deleting the slot's configuration requires the use of the compatible [DeleteSlotConfiguration](xref:Yubico.YubiKey.Otp.OtpSession.DeleteSlotConfiguration%28Yubico.YubiKey.Otp.Slot%29) method.
61
+
63
62
## Example code
64
63
65
64
Before running any of the code provided below, make sure you have already connected to a particular YubiKey on your host
@@ -96,79 +99,81 @@ using (OtpSession otp = new OtpSession(yubiKey))
96
99
}
97
100
```
98
101
99
-
## Example: reset a slot access code
102
+
###Example: modify a slot access code
100
103
101
-
To reset a slot's access code, you must provide the current access code
104
+
To modify a slot's access code, you must provide the current access code
102
105
with [UseCurrentAccessCode()](xref:Yubico.YubiKey.Otp.Operations.OperationBase%601.UseCurrentAccessCode%28Yubico.YubiKey.Otp.SlotAccessCode%29)
103
-
followed by the new access code with ``SetNewAccessCode()``:
106
+
followed by the new access code with ``SetNewAccessCode()`` during a slot configuration operation.
107
+
108
+
In this example, we are reconfiguring the long press slot with a new access code via the ``UpdateSlot()`` method. ``UpdateSlot()`` will not modify the slot's cryptographic configuration. However, it will revert a number of other slot settings (such as ``SetAppendCarriageReturn()``) to their default states unless otherwise specified during the operation.
If you want to remove a slot's access code, you must either:
130
+
If you want to remove a slot's access code during a configuration operation, you can either:
127
131
128
-
- provide a new access code of all zeros, or
129
-
- only call ``UseCurrentAccessCode()`` during the reconfiguration operation. The slot's access code will be removed if a
130
-
code is not provided via ``SetNewAccessCode()`` after calling ``UseCurrentAccessCode()``.
132
+
- provide a new access code of all zeros with ``SetNewAccessCode()``, or
133
+
- skip the ``SetNewAccessCode()`` call entirely
131
134
132
135
> [!NOTE]
133
-
> A 6-byte access code of zeros (0x00) is considered no access code. The factory default state of the access code for
134
-
> each OTP slot is all zeros.
136
+
> A 6-byte access code of zeros (0x00) is the factory default state for each OTP slot.
135
137
136
138
Once the access code is removed, you do not need to call ``UseCurrentAccessCode()`` with subsequent configuration
137
139
operations.
138
140
139
-
> [!NOTE]
140
-
> Technically, if a slot does not have an access code, you could provide any 6-byte code
141
-
> with ``UseCurrentAccessCode()``, and the operation would succeed.
141
+
In this example, we are effectively removing the access code from the long press slot by providing a new code of all zeros during the ``UpdateSlot()`` operation. ``UpdateSlot()`` will not modify the slot's cryptographic configuration. However, it will revert a number of other slot settings (such as ``SetAppendCarriageReturn()``) to their default states unless otherwise specified during the operation.
## Example: provide a slot access code during a configuration operation
161
+
###Example: provide a slot access code during a configuration operation
164
162
165
163
Once a slot has been configured with an access code, you must provide that access code with ``UseCurrentAccessCode()``
166
164
when performing a configuration operation on that slot. To retain the access code, you must also
167
-
call ``SetNewAccessCode()``. If you do not call ``SetNewAccessCode()``, the access code will be removed.
165
+
call ``SetNewAccessCode()`` and provide the same access code. If you do not call ``SetNewAccessCode()``, the access code will be removed.
166
+
167
+
> [!NOTE]
168
+
> If a slot does not have an access code, providing any 6-byte code
169
+
> with ``UseCurrentAccessCode()`` during a configuration operation will succeed.
170
+
171
+
In this example, we are reconfiguring an access code-protected long press slot with a new Yubico OTP credential. The access code is carried over to the new slot configuration by the ``SetNewAccessCode(currentAccessCode)`` call.
and provide the current access code with ``UseCurrentAccessCode()``. You cannot set a new access code during this
196
-
operation--calling ``SetNewAccessCode()`` will succeed, but the operation will not be applied.
197
+
and provide the current access code with ``UseCurrentAccessCode()``.
198
+
199
+
You cannot set a new access code during this
200
+
operation. The ``DeleteSlotConfiguration`` operation will still succeed if you call ``SetNewAccessCode()``, but the new access code will not be applied.
0 commit comments