1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-28 18:03:36 +00:00

actions: list secrets

This commit is contained in:
Mirek Kratochvil 2013-04-21 10:52:02 +02:00
parent 9ead59dbad
commit 86d3afc213
3 changed files with 32 additions and 6 deletions

@ -180,6 +180,32 @@ int action_rename (bool yes,
int action_list_sec (bool nice_fingerprint, const std::string&filter,
keyring&KR)
{
for (keyring::keypair_storage::iterator
i = KR.pairs.begin(), e = KR.pairs.end();
i != e; ++i) {
if (!keyspec_matches (filter, i->second.pub.name, i->first) )
continue;
if (!nice_fingerprint)
out ("keypair\t"
<< i->second.pub.alg << '\t'
<< '@' << i->first.substr (0, 22) << "...\t"
<< "\"" << i->second.pub.name << "\"");
else {
out ("key pair with algorithm " << i->second.pub.alg
<< ", name `" << i->second.pub.name << "'");
std::cout << " fingerprint ";
for (size_t j = 0; j < i->first.length(); ++j) {
std::cout << i->first[j];
if (! ( (j + 1) % 4) &&
j < i->first.length() - 1)
std::cout << ':';
}
std::cout << std::endl << std::endl;
}
}
return 0;
}

@ -30,9 +30,9 @@ bool algorithm_name_matches (const std::string& search,
return true;
}
bool key_matches (const std::string&search,
const std::string&name,
const std::string&keyid)
bool keyspec_matches (const std::string&search,
const std::string&name,
const std::string&keyid)
{
if (!search.length() ) return true;
if (search[0] == '@') { //match for keyID

@ -24,8 +24,8 @@
bool algorithm_name_matches (const std::string& search,
const std::string&name);
bool key_matches (const std::string&search,
const std::string&name,
const std::string&keyid);
bool keyspec_matches (const std::string&search,
const std::string&name,
const std::string&keyid);
#endif