From 08dbdcfed4fb182c0efaacb32a6c46481ced095b Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Tue, 7 Jun 2022 12:34:04 -0400 Subject: [PATCH] When adding GPG collaborator, include full fingerprint in commit message Short key IDs are bad (https://evil32.com/) Closes: #253 --- commands.cpp | 3 ++- gpg.cpp | 6 ------ gpg.hpp | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/commands.cpp b/commands.cpp index 81c401d..6b3c498 100644 --- a/commands.cpp +++ b/commands.cpp @@ -1297,7 +1297,8 @@ int add_gpg_user (int argc, const char** argv) std::ostringstream commit_message_builder; commit_message_builder << "Add " << collab_keys.size() << " git-crypt collaborator" << (collab_keys.size() != 1 ? "s" : "") << "\n\nNew collaborators:\n\n"; for (std::vector >::const_iterator collab(collab_keys.begin()); collab != collab_keys.end(); ++collab) { - commit_message_builder << '\t' << gpg_shorten_fingerprint(collab->first) << ' ' << gpg_get_uid(collab->first) << '\n'; + commit_message_builder << " " << collab->first << '\n'; + commit_message_builder << " " << gpg_get_uid(collab->first) << '\n'; } // git commit -m MESSAGE NEW_FILE ... diff --git a/gpg.cpp b/gpg.cpp index bec5892..901ffaf 100644 --- a/gpg.cpp +++ b/gpg.cpp @@ -61,12 +61,6 @@ static std::string gpg_nth_column (const std::string& line, unsigned int col) line.substr(pos); } -// given a key fingerprint, return the last 8 nibbles -std::string gpg_shorten_fingerprint (const std::string& fingerprint) -{ - return fingerprint.size() == 40 ? fingerprint.substr(32) : fingerprint; -} - // given a key fingerprint, return the key's UID (e.g. "John Smith ") std::string gpg_get_uid (const std::string& fingerprint) { diff --git a/gpg.hpp b/gpg.hpp index 77997b1..be98aed 100644 --- a/gpg.hpp +++ b/gpg.hpp @@ -41,7 +41,6 @@ struct Gpg_error { explicit Gpg_error (std::string m) : message(m) { } }; -std::string gpg_shorten_fingerprint (const std::string& fingerprint); std::string gpg_get_uid (const std::string& fingerprint); std::vector gpg_lookup_key (const std::string& query); std::vector gpg_list_secret_keys ();