Add support for --with-key-password to Sign

This commit is contained in:
Paul Schaub 2022-05-24 21:55:35 +02:00
parent 8406793d0e
commit 55aefb799f
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -40,6 +40,10 @@ public class SignCmd implements Runnable {
paramLabel = "KEYS") paramLabel = "KEYS")
List<File> secretKeyFile = new ArrayList<>(); List<File> secretKeyFile = new ArrayList<>();
@CommandLine.Option(names = "--with-key-password", description = "Password(s) to unlock the secret key(s) with",
paramLabel = "PASSWORD")
List<String> withKeyPassword = new ArrayList<>();
@CommandLine.Option(names = "--micalg-out", description = "Emits the digest algorithm used to the specified file in a way that can be used to populate the micalg parameter for the PGP/MIME Content-Type (RFC3156)", @CommandLine.Option(names = "--micalg-out", description = "Emits the digest algorithm used to the specified file in a way that can be used to populate the micalg parameter for the PGP/MIME Content-Type (RFC3156)",
paramLabel = "MICALG") paramLabel = "MICALG")
File micAlgOut; File micAlgOut;
@ -70,6 +74,10 @@ public class SignCmd implements Runnable {
System.exit(19); System.exit(19);
} }
for (String password : withKeyPassword) {
sign.withKeyPassword(password);
}
for (File keyFile : secretKeyFile) { for (File keyFile : secretKeyFile) {
try (FileInputStream keyIn = new FileInputStream(keyFile)) { try (FileInputStream keyIn = new FileInputStream(keyFile)) {
sign.key(keyIn); sign.key(keyIn);