Skip to content

Commit

Permalink
fix: switch to suported terminal input module
Browse files Browse the repository at this point in the history
  • Loading branch information
smlx committed Mar 24, 2023
1 parent bf2f982 commit 56388aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions cmd/piv-agent/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/piv-agent/setupslots.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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

0 comments on commit 56388aa

Please sign in to comment.