From 56388aa72d152c6c32dfa84e714cbcf8f58c7b46 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Fri, 24 Mar 2023 21:32:47 +0800 Subject: [PATCH] fix: switch to suported terminal input module --- cmd/piv-agent/setup.go | 6 +++--- cmd/piv-agent/setupslots.go | 4 ++-- go.mod | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/piv-agent/setup.go b/cmd/piv-agent/setup.go index d431763..ffaccfa 100644 --- a/cmd/piv-agent/setup.go +++ b/cmd/piv-agent/setup.go @@ -9,7 +9,7 @@ import ( "github.com/smlx/piv-agent/internal/pinentry" "github.com/smlx/piv-agent/internal/securitykey" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" ) // SetupCmd represents the setup command. @@ -24,7 +24,7 @@ type SetupCmd struct { // interactiveNewPIN prompts twice for a new PIN. func interactiveNewPIN() (uint64, error) { fmt.Print("Enter a new PIN/PUK (6-8 digits): ") - rawPIN, err := terminal.ReadPassword(int(os.Stdin.Fd())) + rawPIN, err := term.ReadPassword(int(os.Stdin.Fd())) fmt.Println() if err != nil { return 0, fmt.Errorf("couldn't read PIN/PUK: %w", err) @@ -34,7 +34,7 @@ func interactiveNewPIN() (uint64, error) { return 0, fmt.Errorf("invalid characters: %w", err) } fmt.Print("Repeat PIN/PUK: ") - repeat, err := terminal.ReadPassword(int(os.Stdin.Fd())) + repeat, err := term.ReadPassword(int(os.Stdin.Fd())) fmt.Println() if err != nil { return 0, fmt.Errorf("couldn't read PIN/PUK: %w", err) diff --git a/cmd/piv-agent/setupslots.go b/cmd/piv-agent/setupslots.go index c31648d..e74d876 100644 --- a/cmd/piv-agent/setupslots.go +++ b/cmd/piv-agent/setupslots.go @@ -8,7 +8,7 @@ import ( "github.com/smlx/piv-agent/internal/pinentry" "github.com/smlx/piv-agent/internal/securitykey" - "golang.org/x/crypto/ssh/terminal" + "golang.org/x/term" ) // SetupSlotsCmd represents the setup command. @@ -23,7 +23,7 @@ type SetupSlotsCmd struct { // interactivePIN prompts once for an existing PIN. func interactivePIN() (uint64, error) { fmt.Print("Enter the PIN/PUK (6-8 digits): ") - rawPIN, err := terminal.ReadPassword(int(os.Stdin.Fd())) + rawPIN, err := term.ReadPassword(int(os.Stdin.Fd())) fmt.Println() if err != nil { return 0, fmt.Errorf("couldn't read PIN/PUK: %w", err) diff --git a/go.mod b/go.mod index 8811ac4..a809951 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( go.uber.org/zap v1.24.0 golang.org/x/crypto v0.7.0 golang.org/x/sync v0.1.0 + golang.org/x/term v0.6.0 ) require ( @@ -30,7 +31,6 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect golang.org/x/sys v0.6.0 // indirect - golang.org/x/term v0.6.0 // indirect ) replace github.com/ProtonMail/go-crypto => github.com/smlx/go-crypto v0.0.0-20230324130354-fc893cd601c2