diff options
author | Jack Lloyd <[email protected]> | 2018-01-12 16:26:22 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-01-12 16:26:22 -0500 |
commit | 6b29180686c9897a87b689261ea3a86f55d809c9 (patch) | |
tree | d02562e4f9af8f335c13c14b37d677e1dfdfcad1 /src/cli | |
parent | d0d2e426529ae3ce091cc90e7c2b314d43b22a8e (diff) |
Add --der-format flag to sign and verify cli utils
Otherwise it's not possible to verify eg OpenSSL's DSA signatures
See GH #1409
Diffstat (limited to 'src/cli')
-rw-r--r-- | src/cli/pubkey.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp index a6f77fe0c..4e7439a9a 100644 --- a/src/cli/pubkey.cpp +++ b/src/cli/pubkey.cpp @@ -121,7 +121,7 @@ std::string algo_default_emsa(const std::string& key) class PK_Sign final : public Command { public: - PK_Sign() : Command("sign --passphrase= --hash=SHA-256 --emsa= key file") {} + PK_Sign() : Command("sign --der-format --passphrase= --hash=SHA-256 --emsa= key file") {} void go() override { @@ -139,7 +139,10 @@ class PK_Sign final : public Command const std::string sig_padding = get_arg_or("emsa", algo_default_emsa(key->algo_name())) + "(" + get_arg("hash") + ")"; - Botan::PK_Signer signer(*key, rng(), sig_padding); + const Botan::Signature_Format format = + flag_set("der-format") ? Botan::DER_SEQUENCE : Botan::IEEE_1363; + + Botan::PK_Signer signer(*key, rng(), sig_padding, format); auto onData = [&signer](const uint8_t b[], size_t l) { @@ -156,7 +159,7 @@ BOTAN_REGISTER_COMMAND("sign", PK_Sign); class PK_Verify final : public Command { public: - PK_Verify() : Command("verify --hash=SHA-256 --emsa= pubkey file signature") {} + PK_Verify() : Command("verify --der-format --hash=SHA-256 --emsa= pubkey file signature") {} void go() override { @@ -169,7 +172,10 @@ class PK_Verify final : public Command const std::string sig_padding = get_arg_or("emsa", algo_default_emsa(key->algo_name())) + "(" + get_arg("hash") + ")"; - Botan::PK_Verifier verifier(*key, sig_padding); + const Botan::Signature_Format format = + flag_set("der-format") ? Botan::DER_SEQUENCE : Botan::IEEE_1363; + + Botan::PK_Verifier verifier(*key, sig_padding, format); auto onData = [&verifier](const uint8_t b[], size_t l) { verifier.update(b, l); |