Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable OpenPGP support via pinentry #142

Merged
merged 6 commits into from
Aug 14, 2018
Merged

Conversation

wsargent
Copy link
Contributor

@wsargent wsargent commented Aug 13, 2018

Adds a pinentry option to sbt-pgp, by using the --pinentry-mode loopback option specified in https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase

Adds a useGpgPinentry boolean key that if set with useGpg and useGpgAgent set, will use a specialized signer CommandLineGpgPinentrySigner.

This is useful when using GPG with gpg-agent and a smartcard device with OpenPGP support. In this situation, there is no local secring on the hard drive, and the secret key is kept on the card itself.

TODO

Testing

This is currently missing ways to effectively test for pinentry. https://lists.gnupg.org/pipermail/gnupg-users/2017-July/058741.html suggests PINENTRY_USER_DATA and fake-pinentries.

Right now I'm testing this locally:

useGpg := true
useGpgAgent := true
useGpgPinentry := true    

and then killing gpg-agent to ensure that the PIN is not cached, and running publishLocalSigned:

gpgconf --kill gpg-agent && gpgconf --launch gpg-agent
sbt publishLocalSigned   

@wsargent wsargent changed the title Use pinentry Enable OpenPGP support via pinentry Aug 13, 2018
Copy link
Member

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Cool stuff :-)

.gitignore Outdated
@@ -4,3 +4,4 @@ boot/
.classpath
.project
.scala_dependencies
.idea/
Copy link
Member

Choose a reason for hiding this comment

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

This should go to global gitignore - https://help.github.com/articles/ignoring-files/

Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

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

overall LGTM too, except minor nitpick on .gitignore.

val pinentryargs: Seq[String] = Seq("--pinentry-mode", "loopback")
val passargs: Seq[String] = (optPassphrase map { passArray => passArray mkString "" } map { pass => Seq("--passphrase", pass) }) getOrElse Seq.empty
val keyargs: Seq[String] = optKey map (k => Seq("--default-key", "0x%x" format(k))) getOrElse Seq.empty
val args = passargs ++ pinentryargs ++ Seq("--detach-sign", "--armor") ++ (if(agent) Seq("--use-agent") else Seq.empty) ++ keyargs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

agent is pretty much required here

@@ -28,6 +28,7 @@ object PgpKeys {
val gpgCommand = SettingKey[String]("gpg-command", "The path of the GPG command to run", BSetting)
val useGpg = SettingKey[Boolean]("use-gpg", "If this is set to true, the GPG command line will be used.", ASetting)
val useGpgAgent = SettingKey[Boolean]("use-gpg-agent", "If this is set to true, the GPG command line will expect a GPG agent for the password.", BSetting)
val useGpgPinentry = SettingKey[Boolean]("use-gpg-pinentry", "If this is set to true, the GPG command line will expect pinentry will be used with gpg-agent.", ASetting)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is ASetting vs BSetting?

Copy link
Member

Choose a reason for hiding this comment

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

The rank is optional, and it affects the help display iirc. We should probably refactor it to sbt 0.13/1.x settingKey[Boolean] style.

@eed3si9n eed3si9n merged commit e64e689 into sbt:master Aug 14, 2018
@wsargent wsargent deleted the add-pinentry branch August 14, 2018 04:36
@eed3si9n eed3si9n added this to the 2.0.0 milestone Sep 15, 2019
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.

3 participants