Skip to content

Commit 66ce787

Browse files
stv0gericchiang
authored andcommitted
Fix formatting using go fmt
1 parent 8c3a0ff commit 66ce787

File tree

4 files changed

+38
-46
lines changed

4 files changed

+38
-46
lines changed

piv/key.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,11 @@ var retiredKeyManagementSlots = map[uint32]Slot{
415415
// RetiredKeyManagementSlot provides access to "retired" slots. Slots meant for old Key Management
416416
// keys that have been rotated. YubiKeys 4 and later support values between 0x82 and 0x95 (inclusive).
417417
//
418-
// slot, ok := RetiredKeyManagementSlot(0x82)
419-
// if !ok {
420-
// // unrecognized slot
421-
// }
422-
// pub, err := yk.GenerateKey(managementKey, slot, key)
418+
// slot, ok := RetiredKeyManagementSlot(0x82)
419+
// if !ok {
420+
// // unrecognized slot
421+
// }
422+
// pub, err := yk.GenerateKey(managementKey, slot, key)
423423
//
424424
// https://developers.yubico.com/PIV/Introduction/Certificate_slots.html#_slot_82_95_retired_key_management
425425
func RetiredKeyManagementSlot(key uint32) (Slot, bool) {
@@ -808,7 +808,6 @@ func ykGenerateKey(tx *scTx, slot Slot, o Key) (crypto.PublicKey, error) {
808808
alg, ok := algorithmsMap[o.Algorithm]
809809
if !ok {
810810
return nil, fmt.Errorf("unsupported algorithm")
811-
812811
}
813812
tp, ok := touchPolicyMap[o.TouchPolicy]
814813
if !ok {
@@ -963,12 +962,11 @@ func pinPolicy(yk *YubiKey, slot Slot) (PINPolicy, error) {
963962
// If the public key hasn't been stored externally, it can be provided by
964963
// fetching the slot's attestation certificate:
965964
//
966-
// cert, err := yk.Attest(slot)
967-
// if err != nil {
968-
// // ...
969-
// }
970-
// priv, err := yk.PrivateKey(slot, cert.PublicKey, auth)
971-
//
965+
// cert, err := yk.Attest(slot)
966+
// if err != nil {
967+
// // ...
968+
// }
969+
// priv, err := yk.PrivateKey(slot, cert.PublicKey, auth)
972970
func (yk *YubiKey) PrivateKey(slot Slot, public crypto.PublicKey, auth KeyAuth) (crypto.PrivateKey, error) {
973971
pp := PINPolicyNever
974972
if _, ok := pinPolicyMap[auth.PINPolicy]; ok {
@@ -1086,7 +1084,6 @@ func ykImportKey(tx *scTx, tags []byte, slot Slot, o Key) error {
10861084
alg, ok := algorithmsMap[o.Algorithm]
10871085
if !ok {
10881086
return fmt.Errorf("unsupported algorithm")
1089-
10901087
}
10911088
tp, ok := touchPolicyMap[o.TouchPolicy]
10921089
if !ok {

piv/key_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,6 @@ func TestSetRSAPrivateKey(t *testing.T) {
876876
slot Slot
877877
wantErr error
878878
}{
879-
880879
{
881880
name: "rsa 1024",
882881
bits: 1024,

piv/pcsc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func TestTransaction(t *testing.T) {
9393
}
9494

9595
func TestErrors(t *testing.T) {
96-
var tests = []struct {
96+
tests := []struct {
9797
sw1, sw2 byte
9898
isErrNotFound bool
9999
isAuthErr bool

piv/piv.go

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,13 @@ func ykAuthenticate(tx *scTx, key [24]byte, rand io.Reader) error {
450450
// are triple-des keys, however padding isn't verified. To generate a new key,
451451
// generate 24 random bytes.
452452
//
453-
// var newKey [24]byte
454-
// if _, err := io.ReadFull(rand.Reader, newKey[:]); err != nil {
455-
// // ...
456-
// }
457-
// if err := yk.SetManagementKey(piv.DefaultManagementKey, newKey); err != nil {
458-
// // ...
459-
// }
460-
//
461-
//
453+
// var newKey [24]byte
454+
// if _, err := io.ReadFull(rand.Reader, newKey[:]); err != nil {
455+
// // ...
456+
// }
457+
// if err := yk.SetManagementKey(piv.DefaultManagementKey, newKey); err != nil {
458+
// // ...
459+
// }
462460
func (yk *YubiKey) SetManagementKey(oldKey, newKey [24]byte) error {
463461
if err := ykAuthenticate(yk.tx, oldKey, yk.rand); err != nil {
464462
return fmt.Errorf("authenticating with old key: %w", err)
@@ -494,17 +492,16 @@ func ykSetManagementKey(tx *scTx, key [24]byte, touch bool) error {
494492
//
495493
// To generate a new PIN, use the crypto/rand package.
496494
//
497-
// // Generate a 6 character PIN.
498-
// newPINInt, err := rand.Int(rand.Reader, bit.NewInt(1_000_000))
499-
// if err != nil {
500-
// // ...
501-
// }
502-
// // Format with leading zeros.
503-
// newPIN := fmt.Sprintf("%06d", newPINInt)
504-
// if err := yk.SetPIN(piv.DefaultPIN, newPIN); err != nil {
505-
// // ...
506-
// }
507-
//
495+
// // Generate a 6 character PIN.
496+
// newPINInt, err := rand.Int(rand.Reader, bit.NewInt(1_000_000))
497+
// if err != nil {
498+
// // ...
499+
// }
500+
// // Format with leading zeros.
501+
// newPIN := fmt.Sprintf("%06d", newPINInt)
502+
// if err := yk.SetPIN(piv.DefaultPIN, newPIN); err != nil {
503+
// // ...
504+
// }
508505
func (yk *YubiKey) SetPIN(oldPIN, newPIN string) error {
509506
return ykChangePIN(yk.tx, oldPIN, newPIN)
510507
}
@@ -555,17 +552,16 @@ func ykUnblockPIN(tx *scTx, puk, newPIN string) error {
555552
//
556553
// To generate a new PUK, use the crypto/rand package.
557554
//
558-
// // Generate a 8 character PUK.
559-
// newPUKInt, err := rand.Int(rand.Reader, big.NewInt(100_000_000))
560-
// if err != nil {
561-
// // ...
562-
// }
563-
// // Format with leading zeros.
564-
// newPUK := fmt.Sprintf("%08d", newPUKInt)
565-
// if err := yk.SetPUK(piv.DefaultPUK, newPUK); err != nil {
566-
// // ...
567-
// }
568-
//
555+
// // Generate a 8 character PUK.
556+
// newPUKInt, err := rand.Int(rand.Reader, big.NewInt(100_000_000))
557+
// if err != nil {
558+
// // ...
559+
// }
560+
// // Format with leading zeros.
561+
// newPUK := fmt.Sprintf("%08d", newPUKInt)
562+
// if err := yk.SetPUK(piv.DefaultPUK, newPUK); err != nil {
563+
// // ...
564+
// }
569565
func (yk *YubiKey) SetPUK(oldPUK, newPUK string) error {
570566
return ykChangePUK(yk.tx, oldPUK, newPUK)
571567
}

0 commit comments

Comments
 (0)