| 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 | { |
| 159 | // gpg --batch -o FILENAME -r RECIPIENT -e |
| 160 | std::vector<std::string> command; |
| 161 | command.push_back(gpg_get_executable()); |
| 162 | command.push_back("--batch"); |
| 163 | if (key_is_trusted) { |
| 164 | command.push_back("--trust-model"); |
| 165 | command.push_back("always"); |
| 166 | } |
| 167 | command.push_back("-o"); |
| 168 | command.push_back(filename); |
| 169 | command.push_back("-r"); |
| 170 | command.push_back("0x" + recipient_fingerprint); |
| 171 | command.push_back("-e"); |
| 172 | if (!successful_exit(exec_command_with_input(command, p, len))) { |
| 173 | throw Gpg_error("Failed to encrypt"); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | void gpg_decrypt_from_file (const std::string& filename, std::ostream& output) |
| 178 | { |
no test coverage detected