1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include "decryptor.ih"
void Decryptor::decrypt(PGPSection const &pgpSection) const
{
size_t attempt = 0;
while (true)
{
d_pgpMessage->seekg(0);
int ret;
if
(
ret = d_gpgHandler.process(d_pgpMessage->fileName());
ret == 0
)
break;
if (attempt++ == 3)
{
auto [begin, end] = pgpSection.range();
string msg{ "In " + g_filename + " lines " +
to_string(begin) + " to " + to_string(end) +
": cannot decrypt PGP section" };
if (not d_options.noErrors()) // allow unkown passphr.
{
*g_verbose << msg << endl;
cout << msg << '\n';
break;
}
error(ret, msg);
}
d_gpgHandler.getPassphrase(attempt);
}
}
|