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

Capitalize PIN as its an abbreviation #59

Merged
merged 1 commit into from
Dec 10, 2024
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
2 changes: 1 addition & 1 deletion attestation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAttestation(t *testing.T) {
serial, err := c.Serial()
assert.NoError(t, err, "Failed to get serial number")
assert.Equal(t, serial, a.Serial, "Mismatching attestation serial got=%d, wanted=%d", a.Serial, serial)
assert.Equal(t, key.PINPolicy, a.PINPolicy, "Mismatching attestation pin policy got=0x%x, wanted=0x%x", a.TouchPolicy, key.PINPolicy)
assert.Equal(t, key.PINPolicy, a.PINPolicy, "Mismatching attestation PIN policy got=0x%x, wanted=0x%x", a.TouchPolicy, key.PINPolicy)
assert.Equal(t, key.TouchPolicy, a.TouchPolicy, "Mismatching attestation touch policy got=0x%x, wanted=0x%x", a.TouchPolicy, key.TouchPolicy)
assert.Equal(t, c.Version(), a.Version, "Mismatching attestation version got=%#v, wanted=%#v", a.Version, c.Version())
assert.Equal(t, SlotAuthentication, a.Slot, "Mismatching attested slot got=%v, wanted=%v", a.Slot, SlotAuthentication)
Expand Down
2 changes: 1 addition & 1 deletion auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func loginNeeded(tx *iso.Transaction) bool {
func (c *Card) Retries() (int, error) {
_, err := send(c.tx, iso.InsVerify, 0, 0x80, nil)
if err == nil {
return 0, fmt.Errorf("%w from empty pin", errExpectedError)
return 0, fmt.Errorf("%w from empty PIN", errExpectedError)
}

var aErr AuthError
Expand Down
8 changes: 4 additions & 4 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func TestUnblockPIN(t *testing.T) {
badPIN := "0"
for {
err := login(c.tx, badPIN)
require.Error(t, err, "Login with bad pin succeeded")
require.Error(t, err, "Login with bad PIN succeeded")

var e AuthError
require.ErrorAs(t, err, &e, "Error returned was not a wrong pin error")
require.ErrorAs(t, err, &e, "Error returned was not a wrong PIN error")

if e.Retries == 0 {
break
Expand All @@ -87,7 +87,7 @@ func TestUnblockPIN(t *testing.T) {
require.NoError(t, err, "Failed to unblock PIN")

err = login(c.tx, DefaultPIN)
assert.NoError(t, err, "Failed to login with pin after unblock")
assert.NoError(t, err, "Failed to login with PIN after unblock")
})
}

Expand All @@ -96,7 +96,7 @@ func TestChangePIN(t *testing.T) {
newPIN := "654321"

err := c.SetPIN(newPIN, newPIN)
assert.Error(t, err, "Successfully changed pin with invalid pin, expected error")
assert.Error(t, err, "Successfully changed PIN with invalid PIN, expected error")

err = c.SetPIN(DefaultPIN, newPIN)
require.NoError(t, err, "Failed to change PIN")
Expand Down
4 changes: 2 additions & 2 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ var (

errInvalidPKCS1Padding = errors.New("invalid PKCS#1 v1.5 padding")
errInvalidSerialNumber = errors.New("invalid serial number")
errMissingPIN = errors.New("pin required but wasn't provided")
errMissingPIN = errors.New("PIN required but wasn't provided")
errParseCert = errors.New("failed to parse certificate")
errUnexpectedLength = errors.New("unexpected length")
errUnmarshal = errors.New("failed to unmarshal")
errUnsupportedAlgorithm = errors.New("unsupported algorithm")
errUnsupportedHashAlgorithm = errors.New("unsupported hash algorithm")
errUnsupportedPinPolicy = errors.New("unsupported pin policy")
errUnsupportedPinPolicy = errors.New("unsupported PIN policy")
errUnsupportedTouchPolicy = errors.New("unsupported touch policy")
errUnsupportedKeyType = errors.New("unsupported key type")
errUnsupportedOrigin = errors.New("unsupported origin")
Expand Down
2 changes: 1 addition & 1 deletion metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (ki *Metadata) unmarshal(tvs tlv.TagValues) (err error) {
// PIN & Touch Policy
if v, _, ok := tvs.Get(0x02); ok {
if len(v) != 2 {
return fmt.Errorf("%w for pin and touch policy", errUnexpectedLength)
return fmt.Errorf("%w for PIN and touch policy", errUnexpectedLength)
}

if ki.PINPolicy, ok = pinPolicyMapInv[v[0]]; !ok {
Expand Down
2 changes: 1 addition & 1 deletion pin_protected.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (d *PinProtectedData) SetManagementKey(key ManagementKey) error {
if tvs := d.PopAll(0x88); len(tvs) == 0 {
tvYubico = tlv.New(0x88)
} else if len(tvs) > 1 {
return fmt.Errorf("%w: found more then one YubiKey pin protected tag value", errUnmarshal)
return fmt.Errorf("%w: found more then one YubiKey PIN protected tag value", errUnmarshal)
} else {
tvYubico = tvs[0]
}
Expand Down
2 changes: 1 addition & 1 deletion piv.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
var (
errChallengeFailed = errors.New("challenge failed")
errExpectedError = errors.New("expected error")
errInvalidPinLength = errors.New("invalid pin length")
errInvalidPinLength = errors.New("invalid PIN length")
)

const (
Expand Down
Loading