Skip to content

Commit

Permalink
piv: allow PIN verification by exposing VerifyPIN
Browse files Browse the repository at this point in the history
  • Loading branch information
duo-lfalsetta authored and ericchiang committed Mar 15, 2023
1 parent 1902689 commit cdf2024
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions piv/piv.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ func encodePIN(pin string) ([]byte, error) {
return data, nil
}

// authPIN attempts to authenticate against the card with the provided PIN.
// VerifyPIN attempts to authenticate against the card with the provided PIN.
// The PIN is required to use and modify certain slots.
//
// After a specific number of authentication attemps with an invalid PIN,
// usually 3, the PIN will become block and refuse further attempts. At that
// point the PUK must be used to unblock the PIN.
//
// Use DefaultPIN if the PIN hasn't been set.
func (yk *YubiKey) authPIN(pin string) error {
func (yk *YubiKey) VerifyPIN(pin string) error {
return ykLogin(yk.tx, pin)
}

Expand Down
4 changes: 2 additions & 2 deletions piv/piv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestYubiKeyReset(t *testing.T) {
if err := yk.Reset(); err != nil {
t.Fatalf("resetting yubikey: %v", err)
}
if err := yk.authPIN(DefaultPIN); err != nil {
if err := yk.VerifyPIN(DefaultPIN); err != nil {
t.Fatalf("login: %v", err)
}
}
Expand All @@ -199,7 +199,7 @@ func TestYubiKeyLogin(t *testing.T) {
yk, close := newTestYubiKey(t)
defer close()

if err := yk.authPIN(DefaultPIN); err != nil {
if err := yk.VerifyPIN(DefaultPIN); err != nil {
t.Fatalf("login: %v", err)
}
}
Expand Down

0 comments on commit cdf2024

Please sign in to comment.