diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cli/pubkey.cpp | 7 | ||||
-rwxr-xr-x | src/scripts/test_cli.py | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp index e141339ca..39923bc1f 100644 --- a/src/cli/pubkey.cpp +++ b/src/cli/pubkey.cpp @@ -159,11 +159,14 @@ class PK_Fingerprint final : public Command for(std::string key_file : get_arg_list("keys")) { - std::unique_ptr<Botan::Public_Key> key(Botan::X509::load_key(key_file)); + std::unique_ptr<Botan::Public_Key> key( + key_file == "-" + ? Botan::X509::load_key(this->slurp_file("-", 4096)) + : Botan::X509::load_key(key_file)); const std::string fprint = key->fingerprint_public(hash_algo); - if(no_fsname) + if(no_fsname || key_file == "-") { output() << fprint << "\n"; } else { output() << key_file << ": " << fprint << "\n"; } diff --git a/src/scripts/test_cli.py b/src/scripts/test_cli.py index e4da5a898..993284951 100755 --- a/src/scripts/test_cli.py +++ b/src/scripts/test_cli.py @@ -314,6 +314,18 @@ mlLtJ5JvZ0/p6zP3x+Y9yPIrAR8L/acG5ItSrAKXzzuqQQZMv4aN test_cli("fingerprint", ['--no-fsname', pub_der_key], "83:FC:67:87:30:C7:0C:9C:54:9A:E7:A1:FA:25:83:4C:77:A4:43:16:33:6D:47:3C:CE:4B:91:62:30:97:62:D4") + test_cli("fingerprint", ['--no-fsname', pub_key, pub_der_key], + "83:FC:67:87:30:C7:0C:9C:54:9A:E7:A1:FA:25:83:4C:77:A4:43:16:33:6D:47:3C:CE:4B:91:62:30:97:62:D4\n" + "83:FC:67:87:30:C7:0C:9C:54:9A:E7:A1:FA:25:83:4C:77:A4:43:16:33:6D:47:3C:CE:4B:91:62:30:97:62:D4") + + test_cli("fingerprint", [pub_der_key], + pub_der_key + + ": 83:FC:67:87:30:C7:0C:9C:54:9A:E7:A1:FA:25:83:4C:77:A4:43:16:33:6D:47:3C:CE:4B:91:62:30:97:62:D4") + + test_cli("fingerprint", ['-'], + "83:FC:67:87:30:C7:0C:9C:54:9A:E7:A1:FA:25:83:4C:77:A4:43:16:33:6D:47:3C:CE:4B:91:62:30:97:62:D4", + open(pub_key, 'rb').read().decode()) + valid_sig = "nI4mI1ec14Y7nYUWs2edysAVvkob0TWpmGh5rrYWDA+/W9Fj0ZM21qJw8qa3/avAOIVBO6hoMEVmfJYXlS+ReA==" test_cli("sign", "--provider=base %s %s" % (priv_key, pub_key), valid_sig) |