When adding GPG collaborator, include full fingerprint in commit message

Short key IDs are bad (https://evil32.com/)

Closes: #253
This commit is contained in:
Andrew Ayer
2022-06-07 12:34:04 -04:00
parent a1e6311f56
commit 08dbdcfed4
3 changed files with 2 additions and 8 deletions

View File

@@ -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<std::pair<std::string, bool> >::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 ...

View File

@@ -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 <jsmith@example.com>")
std::string gpg_get_uid (const std::string& fingerprint)
{

View File

@@ -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<std::string> gpg_lookup_key (const std::string& query);
std::vector<std::string> gpg_list_secret_keys ();