-
Notifications
You must be signed in to change notification settings - Fork 56
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
77266cd
Use pinentry
wsargent e0003f1
Update documentation
wsargent 7bf2471
Rename pinentry to not have caps
wsargent c14c8db
Update with exposed key
wsargent 4e5bd38
fix links in documentation to be clearer
wsargent c12e3b0
remove .idea from .gitignore
wsargent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,34 @@ class CommandLineGpgSigner(command: String, agent: Boolean, secRing: String, opt | |
|
||
override val toString: String = "GPG-Command(" + command + ")" | ||
} | ||
|
||
/** | ||
* A GpgSigner that uses the command-line to run gpg with a GPG smartcard. | ||
* | ||
* Yubikey 4 has OpenPGP support: https://developers.yubico.com/PGP/ so we can call | ||
* it directly, and the secret key resides on the card. This means we need pinentry | ||
* to be used, and there is no secret key ring. | ||
*/ | ||
class CommandLineGpgPinentrySigner(command: String, agent: Boolean, optKey: Option[Long], optPassphrase: Option[Array[Char]]) extends PgpSigner { | ||
def sign(file: File, signatureFile: File, s: TaskStreams): File = { | ||
if (signatureFile.exists) IO.delete(signatureFile) | ||
// (the PIN code is the passphrase) | ||
// https://wiki.archlinux.org/index.php/GnuPG#Unattended_passphrase | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agent is pretty much required here |
||
val allArguments: Seq[String] = args ++ Seq("--output", signatureFile.getAbsolutePath, file.getAbsolutePath) | ||
sys.process.Process(command, allArguments) ! s.log match { | ||
case 0 => () | ||
case n => sys.error(s"Failure running '${command + " " + allArguments.mkString(" ")}'. Exit code: " + n) | ||
} | ||
signatureFile | ||
} | ||
|
||
override val toString: String = "GPG-Agent-Command(" + command + ")" | ||
} | ||
|
||
/** A GpgSigner that uses bouncy castle. */ | ||
class BouncyCastlePgpSigner(ctx: PgpCommandContext, optKey: Option[Long]) extends PgpSigner { | ||
import ctx.{secretKeyRing => secring, withPassphrase} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
ASetting
vsBSetting
?There was a problem hiding this comment.
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.xsettingKey[Boolean]
style.