Skip to content

Use go-pinentry instead of go-pinentry-minimal#136

Draft
mchack-work wants to merge 2 commits intomainfrom
go-pinentry
Draft

Use go-pinentry instead of go-pinentry-minimal#136
mchack-work wants to merge 2 commits intomainfrom
go-pinentry

Conversation

@mchack-work
Copy link
Member

go-pinentry-minimal is archived and isn't maintained.

Description

Since go-pinentry-minimal is archived and isn't maintained, we adapt to the github.com/twpayne/go-pinentry package instead. This, however, depends on:

  • github.com/mattn/go-colorable v0.1.13
  • github.com/mattn/go-isatty v0.0.18
  • github.com/rs/zerolog v1.29.1

which we have to look into before accepting this.

Only tested on Linux so far.

Fixes #124

Type of change

  • Bugfix (non breaking change which resolve an issue)

Submission checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my changes
  • I have tested and verified my changes on target
  • My changes are well written and CI is passing
  • I have squashed my work to relevant commits and rebased on main for linear history
  • I have added a "Co-authored-by: x" if several people contributed, either pair programming or by squashing commits from different authors.
  • I have updated the documentation where relevant (readme, dev.tillitis.se etc.)
  • QEMU is updated to reflect changes

go-pinentry-minimal is archived and isn't maintained.
@mchack-work mchack-work requested review from agren and jthornblad July 17, 2025 16:49
@quite
Copy link
Contributor

quite commented Jan 27, 2026

If you use the latest go-pinentry, there are no additional dependencies. And there is only a tiny adjustment needed to deal with what GetPIN now returns. I tried it out for the sake of twpayne/go-pinentry#17

@mchack-work
Copy link
Member Author

mchack-work commented Jan 27, 2026

If you use the latest go-pinentry, there are no additional dependencies. And there is only a tiny adjustment needed to deal with what GetPIN now returns. I tried it out for the sake of twpayne/go-pinentry#17

Thanks. Seems simple enough. I got it to build with just the patch below. It did include some other Go packages, but it looks like they are only used in testing go-pinentry. They are not included as indirect deps in tkey-ssh-agent.

go: downloading github.com/twpayne/go-pinentry/v4 v4.0.1
go: downloading github.com/alecthomas/assert/v2 v2.5.0
go: downloading github.com/alecthomas/repr v0.3.0
diff --git a/cmd/tkey-ssh-agent/pinentry.go b/cmd/tkey-ssh-agent/pinentry.go
index 4e40452..32a1a05 100644
--- a/cmd/tkey-ssh-agent/pinentry.go
+++ b/cmd/tkey-ssh-agent/pinentry.go
@@ -15,7 +15,7 @@ import (
 	"strings"
 	"text/template"
 
-	"github.com/twpayne/go-pinentry"
+	"github.com/twpayne/go-pinentry/v4"
 )
 
 func getSecret(udi string, pinentryProgram string) ([]byte, error) {
@@ -66,11 +66,11 @@ func getSecret(udi string, pinentryProgram string) ([]byte, error) {
 
 	defer client.Close()
 
-	pin, _, err := client.GetPIN()
+	pin, err := client.GetPIN()
 	if err != nil {
 		return nil, fmt.Errorf("pinentry GetPin: %w", err)
 	}
-	return []byte(pin), nil
+	return []byte(pin.PIN), nil
 }
 
 func findWindowsPinentry() string {

- Use new API breaking version of go-pinenty

- Change to use new client.GetPIN() which returns different number of
  args and different types.
Copy link
Contributor

@quite quite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm thinking this will not cause any change for darwin or windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go-pinentry-minimal is archived

2 participants