From c21dd310ae30fcf1c409b6343f1878d8f220748a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 5 Jun 2024 19:20:26 +0200 Subject: [PATCH] Capitalize PIN as its an abbreviation Signed-off-by: Steffen Vogel --- attestation_test.go | 2 +- auth.go | 2 +- auth_test.go | 8 ++++---- key.go | 4 ++-- metadata.go | 2 +- pin_protected.go | 2 +- piv.go | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/attestation_test.go b/attestation_test.go index 3a9cded..21e2aad 100644 --- a/attestation_test.go +++ b/attestation_test.go @@ -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) diff --git a/auth.go b/auth.go index 75fb007..0e87676 100644 --- a/auth.go +++ b/auth.go @@ -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 diff --git a/auth_test.go b/auth_test.go index 017365b..a2e80e1 100644 --- a/auth_test.go +++ b/auth_test.go @@ -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 @@ -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") }) } @@ -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") diff --git a/key.go b/key.go index 5e7e7a3..a5ac037 100644 --- a/key.go +++ b/key.go @@ -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") diff --git a/metadata.go b/metadata.go index 7982070..bf2658d 100644 --- a/metadata.go +++ b/metadata.go @@ -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 { diff --git a/pin_protected.go b/pin_protected.go index c6c18f4..4612acd 100644 --- a/pin_protected.go +++ b/pin_protected.go @@ -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] } diff --git a/piv.go b/piv.go index 66229aa..34edad7 100644 --- a/piv.go +++ b/piv.go @@ -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 (