MCPcopy Create free account
hub / github.com/AGWA/git-crypt / gpg_list_secret_keys

Function gpg_list_secret_keys

gpg.cpp:128–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128std::vector<std::string> gpg_list_secret_keys ()
129{
130 // gpg --batch --with-colons --list-secret-keys --fingerprint
131 std::vector<std::string> command;
132 command.push_back(gpg_get_executable());
133 command.push_back("--batch");
134 command.push_back("--with-colons");
135 command.push_back("--list-secret-keys");
136 command.push_back("--fingerprint");
137 std::stringstream command_output;
138 if (!successful_exit(exec_command(command, command_output))) {
139 throw Gpg_error("gpg --list-secret-keys failed");
140 }
141
142 std::vector<std::string> secret_keys;
143
144 while (command_output.peek() != -1) {
145 std::string line;
146 std::getline(command_output, line);
147 if (line.substr(0, 4) == "fpr:") {
148 // fpr:::::::::7A399B2DB06D039020CD1CE1D0F3702D61489532:
149 // want the 9th column (counting from 0)
150 secret_keys.push_back(gpg_nth_column(line, 9));
151 }
152 }
153
154 return secret_keys;
155}
156
157void gpg_encrypt_to_file (const std::string& filename, const std::string& recipient_fingerprint, bool key_is_trusted, const char* p, size_t len)
158{

Callers 1

unlockFunction · 0.85

Calls 5

gpg_get_executableFunction · 0.85
successful_exitFunction · 0.85
exec_commandFunction · 0.85
Gpg_errorClass · 0.85
gpg_nth_columnFunction · 0.85

Tested by

no test coverage detected