Skip to content

Commit

Permalink
Check literals_seen before decryption to avoid problem with leading p…
Browse files Browse the repository at this point in the history
…laintext.
  • Loading branch information
lambdafu committed May 30, 2018
1 parent 8311895 commit 30623bc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion legacy/gnupg/g10/mainproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,14 @@ static void print_pkenc_list(ctrl_t ctrl, struct kidlist_item *list,
}

static void proc_encrypted(CTX c, PACKET *pkt) {
bool fail = false;
int result = 0;

if (literals_seen > 0) {
log_info(_("WARNING: plaintext seen before decryption\n"));
fail = true;
}

if (!opt.quiet) {
if (c->symkeys > 1)
log_info(_("encrypted with %lu passphrases\n"), c->symkeys);
Expand All @@ -436,7 +442,6 @@ static void proc_encrypted(CTX c, PACKET *pkt) {
}

/* FIXME: Figure out the session key by looking at all pkenc packets. */

write_status(STATUS_BEGIN_DECRYPTION);

/*log_debug("dat: %sencrypted data\n", c->dek?"":"conventional ");*/
Expand Down Expand Up @@ -527,6 +532,9 @@ static void proc_encrypted(CTX c, PACKET *pkt) {

if (!result) result = decrypt_data(c->ctrl, c, pkt->pkt.encrypted, c->dek);

if (!result && fail)
result = GPG_ERR_UNEXPECTED;

if (result == -1)
;
else if (!result && !pkt->pkt.encrypted->mdc_method) {
Expand Down

0 comments on commit 30623bc

Please sign in to comment.