Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

piv: fix retry errors on some older yubikeys #64

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions piv/pcsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ func (a *apduErr) Unwrap() error {
return AuthErr{0}
case st&0xfff0 == 0x63c0:
return AuthErr{int(st & 0xf)}
case st&0xfff0 == 0x6300:
// Older YubiKeys sometimes return sw1=0x63 and sw2=0x0N to indicate the
// number of retries. This isn't spec compliant, but support it anyway.
//
// https://github.com/go-piv/piv-go/issues/60
return AuthErr{int(st & 0xf)}
}
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions piv/pcsc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ func TestErrors(t *testing.T) {
{0x63, 0xc0, false, true, 0, "verification failed (0 retries remaining)"},
{0x63, 0xc1, false, true, 1, "verification failed (1 retry remaining)"},
{0x63, 0xcf, false, true, 15, "verification failed (15 retries remaining)"},
{0x63, 0x01, false, true, 1, "verification failed (1 retry remaining)"},
{0x63, 0x0f, false, true, 15, "verification failed (15 retries remaining)"},
{0x69, 0x83, false, true, 0, "authentication method blocked"},
{0x6a, 0x82, true, false, 0, "data object or application not found"},
}
Expand Down