Skip to content

Commit d307713

Browse files
committed
misc: added logging for changing pin / puk
1 parent 32f35d8 commit d307713

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,33 @@ private ResponseStatus ChangePinOrPuk(KeyEntryData keyEntryData)
13471347
// If error, throws exception.
13481348
keyEntryData.RetriesRemaining = response.GetData();
13491349

1350-
return response.Status;
1350+
var status = response.Status;
1351+
switch (status)
1352+
{
1353+
case ResponseStatus.Success:
1354+
Logger.LogInformation(
1355+
slotNumber == PivSlot.Pin
1356+
? "The PIV PIN has been changed"
1357+
: "The PIV PUK has been changed");
1358+
1359+
break;
1360+
case ResponseStatus.ConditionsNotSatisfied:
1361+
Logger.LogWarning(
1362+
slotNumber == PivSlot.Pin
1363+
? "The PIV PIN does not meet the complexity requirements"
1364+
: "The PIV PUK does not meet the complexity requirements");
1365+
1366+
break;
1367+
default:
1368+
Logger.LogError(
1369+
slotNumber == PivSlot.Pin
1370+
? $"The PIV PIN could not be changed. Reason: {response.StatusMessage} (0x{response.StatusWord:X4})"
1371+
: $"The PIV PUK could not be changed. Reason: {response.StatusMessage} (0x{response.StatusWord:X4})");
1372+
1373+
break;
1374+
}
1375+
1376+
return status;
13511377
}
13521378

13531379
// This is a delegate that implements the CommandResponse declaration of

0 commit comments

Comments
 (0)