Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
Signed-off-by: Steffen Vogel <[email protected]>
  • Loading branch information
stv0g committed Nov 8, 2023
1 parent 3e54f6e commit 6544fcf
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type Attestation struct {
Version Version
// Serial is the YubiKey's serial number.
Serial uint32
// Formfactor indicates the physical type of the YubiKey.
// FormFactor indicates the physical type of the YubiKey.
//
// Formfactor may be empty Formfactor(0) for some YubiKeys.
Formfactor Formfactor
// FormFactor may be empty FormFactor(0) for some YubiKeys.
FormFactor FormFactor

// PINPolicy set on the slot.
PINPolicy PINPolicy
Expand Down Expand Up @@ -88,7 +88,7 @@ func (a *Attestation) addExt(e pkix.Extension) error {
if len(e.Value) != 1 {
return fmt.Errorf("%w: expected 1 byte for form factor, got=%d", errUnexpectedLength, len(e.Value))
}
a.Formfactor = Formfactor(e.Value[0])
a.FormFactor = FormFactor(e.Value[0])
}
return nil
}
Expand Down
54 changes: 27 additions & 27 deletions form_factor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ package piv

import "fmt"

// Formfactor enumerates the physical set of forms a key can take. USB-A vs.
// FormFactor enumerates the physical set of forms a key can take. USB-A vs.
// USB-C and Keychain vs. Nano (and FIPS variants for these).
type Formfactor int
type FormFactor int

// The mapping between known Formfactor values and their descriptions.
// The mapping between known form factor values and their descriptions.
//
//nolint:gochecknoglobals
var formFactorStrings = map[Formfactor]string{
FormfactorUSBAKeychain: "USB-A Keychain",
FormfactorUSBANano: "USB-A Nano",
FormfactorUSBCKeychain: "USB-C Keychain",
FormfactorUSBCNano: "USB-C Nano",
FormfactorUSBCLightningKeychain: "USB-C/Lightning Keychain",

FormfactorUSBAKeychainFIPS: "USB-A Keychain FIPS",
FormfactorUSBANanoFIPS: "USB-A Nano FIPS",
FormfactorUSBCKeychainFIPS: "USB-C Keychain FIPS",
FormfactorUSBCNanoFIPS: "USB-C Nano FIPS",
FormfactorUSBCLightningKeychainFIPS: "USB-C/Lightning Keychain FIPS",
var formFactorStrings = map[FormFactor]string{
FormFactorUSBAKeychain: "USB-A Keychain",
FormFactorUSBANano: "USB-A Nano",
FormFactorUSBCKeychain: "USB-C Keychain",
FormFactorUSBCNano: "USB-C Nano",
FormFactorUSBCLightningKeychain: "USB-C/Lightning Keychain",

FormFactorUSBAKeychainFIPS: "USB-A Keychain FIPS",
FormFactorUSBANanoFIPS: "USB-A Nano FIPS",
FormFactorUSBCKeychainFIPS: "USB-C Keychain FIPS",
FormFactorUSBCNanoFIPS: "USB-C Nano FIPS",
FormFactorUSBCLightningKeychainFIPS: "USB-C/Lightning Keychain FIPS",
}

// String returns the human-readable description for the given form-factor
// value, or a fallback value for any other, unknown form-factor.
func (f Formfactor) String() string {
func (f FormFactor) String() string {
if s, ok := formFactorStrings[f]; ok {
return s
}
Expand All @@ -38,15 +38,15 @@ func (f Formfactor) String() string {
// Formfactors recognized by this package. See the reference for more information:
// https://developers.yubico.com/yubikey-manager/Config_Reference.html#_form_factor
const (
FormfactorUSBAKeychain = 0x1
FormfactorUSBANano = 0x2
FormfactorUSBCKeychain = 0x3
FormfactorUSBCNano = 0x4
FormfactorUSBCLightningKeychain = 0x5

FormfactorUSBAKeychainFIPS = 0x81
FormfactorUSBANanoFIPS = 0x82
FormfactorUSBCKeychainFIPS = 0x83
FormfactorUSBCNanoFIPS = 0x84
FormfactorUSBCLightningKeychainFIPS = 0x85
FormFactorUSBAKeychain = 0x1
FormFactorUSBANano = 0x2
FormFactorUSBCKeychain = 0x3
FormFactorUSBCNano = 0x4
FormFactorUSBCLightningKeychain = 0x5

FormFactorUSBAKeychainFIPS = 0x81
FormFactorUSBANanoFIPS = 0x82
FormFactorUSBCKeychainFIPS = 0x83
FormFactorUSBCNanoFIPS = 0x84
FormFactorUSBCLightningKeychainFIPS = 0x85
)
4 changes: 2 additions & 2 deletions key_ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ func TestSignECDSA(t *testing.T) {
require.NoError(t, err, "Failed to generate key")

pub, ok := pubKey.(*ecdsa.PublicKey)
require.True(t, ok, "public key is not an ecdsa key")
require.True(t, ok, "public key is not an ECDSA key")

data := sha256.Sum256([]byte("hello"))
priv, err := c.PrivateKey(slot, pub, KeyAuth{})
require.NoError(t, err, "Failed to gett private key")
require.NoError(t, err, "Failed to get private key")

s, ok := priv.(crypto.Signer)
require.True(t, ok, "expected private key to implement crypto.Signer")
Expand Down
4 changes: 2 additions & 2 deletions key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestDecryptRSA(t *testing.T) {
require.NoError(t, err, "Failed to get private key")

d, ok := priv.(crypto.Decrypter)
require.True(t, ok, "Private key didn't implement crypto.Decypter")
require.True(t, ok, "Private key didn't implement crypto.Decrypter")

got, err := d.Decrypt(rand.Reader, ct, nil)
require.NoError(t, err, "Failed to decrypt")
Expand Down Expand Up @@ -253,7 +253,7 @@ func TestPrivateKey(t *testing.T) {

auth := KeyAuth{PIN: DefaultPIN}
priv, err := c.PrivateKey(slot, pub, auth)
require.NoError(t, err, "Failed to gett private key")
require.NoError(t, err, "Failed to get private key")

signer, ok := priv.(crypto.Signer)
require.True(t, ok, "Private key doesn't implement crypto.Signer")
Expand Down
8 changes: 4 additions & 4 deletions piv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/stretchr/testify/require"
)

// canModifyCard indicates whether the test running has constented to
// canModifyCard indicates whether the test running has consented to
// destroying data on YubiKeys connected to the system.
//
//nolint:gochecknoglobals
Expand Down Expand Up @@ -105,9 +105,9 @@ func TestMultipleConnections(t *testing.T) {
_, err = Open(card)
require.Error(t, err, "Expected second open operation to fail")

var serr scard.Error
require.ErrorAs(t, err, &serr, "Expected scard.Error, got %T", err)
require.ErrorIs(t, serr, scard.ErrSharingViolation, "Expected return code 0x8010000B (sharing vialation), got=0x%x", serr)
var sErr scard.Error
require.ErrorAs(t, err, &sErr, "Expected scard.Error, got %T", err)
require.ErrorIs(t, sErr, scard.ErrSharingViolation, "Expected return code 0x8010000B (sharing violation), got=0x%x", sErr)

return
}
Expand Down

0 comments on commit 6544fcf

Please sign in to comment.