Skip to content

Commit 7bca86e

Browse files
committed
misc: code cleanup
1 parent 5c5e93a commit 7bca86e

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public GetMetadataCommand(byte slotNumber)
140140
/// </remarks>
141141
public GetMetadataCommand()
142142
{
143-
_slotNumber = 0;
143+
144144
}
145145

146146
/// <inheritdoc />

Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Crypto.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,11 @@ private byte[] PerformPrivateKeyOperation(
434434
var metadata = GetMetadataInternal(slotNumber);
435435
if (metadata is not null)
436436
{
437-
// We know the algorithm based on the input data. Is it the
438-
// algorithm of the key in the slot?
439-
// We can make this check with metadata. Without metadata there's
440-
// no way to know until we try to perform the operation.
441437
if (metadata.Algorithm != algorithm)
442438
{
443439
throw new ArgumentException(algorithmExceptionMessage);
444440
}
445-
446-
// If the metadata says Never, then pinRequired is false.
447-
// If the metadata says Once, and the PIN is verified, then the
448-
// PIN is not required.
449-
// The only other case is Always which means we set the
450-
// pinRequired to true, but we init that variable to true.
441+
451442
if (metadata.PinPolicy == PivPinPolicy.Never ||
452443
(metadata.PinPolicy == PivPinPolicy.Once && PinVerified))
453444
{

Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Pin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ public bool TryVerifyPin(ReadOnlyMemory<byte> pin, out int? retriesRemaining)
293293
return true;
294294
}
295295

296-
retriesRemaining = response.GetData();
297-
if ((retriesRemaining ?? 1) == 0)
296+
retriesRemaining = response.GetData() ?? 1;
297+
if (retriesRemaining == 0)
298298
{
299299
throw new SecurityException(
300300
string.Format(

0 commit comments

Comments
 (0)