| 126 | } |
| 127 | |
| 128 | std::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 | |
| 157 | void gpg_encrypt_to_file (const std::string& filename, const std::string& recipient_fingerprint, bool key_is_trusted, const char* p, size_t len) |
| 158 | { |
no test coverage detected