Changeset View
Changeset View
Standalone View
Standalone View
g10/mainproc.c
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
add_onepass_sig (CTX c, PACKET *pkt) | add_onepass_sig (CTX c, PACKET *pkt) | ||||
{ | { | ||||
kbnode_t node; | kbnode_t node; | ||||
log_assert(!(c->sigs_only && c->signed_data.used)); | |||||
if (c->list) /* Add another packet. */ | if (c->list) /* Add another packet. */ | ||||
add_kbnode (c->list, new_kbnode (pkt)); | add_kbnode (c->list, new_kbnode (pkt)); | ||||
else /* Insert the first one. */ | else /* Insert the first one. */ | ||||
c->list = node = new_kbnode (pkt); | c->list = node = new_kbnode (pkt); | ||||
return 1; | return 1; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 385 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
proc_encrypted (CTX c, PACKET *pkt) | proc_encrypted (CTX c, PACKET *pkt) | ||||
{ | { | ||||
int result = 0; | int result = 0; | ||||
int early_plaintext = literals_seen; | int early_plaintext = literals_seen; | ||||
unsigned int compliance_de_vs = 0; | unsigned int compliance_de_vs = 0; | ||||
log_assert(!c->sigs_only || opt.list_packets); | |||||
if (pkt->pkttype == PKT_ENCRYPTED_AEAD) | if (pkt->pkttype == PKT_ENCRYPTED_AEAD) | ||||
c->seen_pkt_encrypted_aead = 1; | c->seen_pkt_encrypted_aead = 1; | ||||
if (pkt->pkttype == PKT_ENCRYPTED_MDC) | if (pkt->pkttype == PKT_ENCRYPTED_MDC) | ||||
c->seen_pkt_encrypted_mdc = 1; | c->seen_pkt_encrypted_mdc = 1; | ||||
if (early_plaintext) | if (early_plaintext) | ||||
{ | { | ||||
log_info (_("WARNING: multiple plaintexts seen\n")); | log_info (_("WARNING: multiple plaintexts seen\n")); | ||||
▲ Show 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | proc_plaintext( CTX c, PACKET *pkt ) | ||||
int any, clearsig, rc; | int any, clearsig, rc; | ||||
kbnode_t n; | kbnode_t n; | ||||
unsigned char *extrahash; | unsigned char *extrahash; | ||||
size_t extrahashlen; | size_t extrahashlen; | ||||
/* This is a literal data packet. Bump a counter for later checks. */ | /* This is a literal data packet. Bump a counter for later checks. */ | ||||
literals_seen++; | literals_seen++; | ||||
log_assert(!(c->sigs_only && c->signed_data.used)); | |||||
if (pt->namelen == 8 && !memcmp( pt->name, "_CONSOLE", 8)) | if (pt->namelen == 8 && !memcmp( pt->name, "_CONSOLE", 8)) | ||||
log_info (_("Note: sender requested \"for-your-eyes-only\"\n")); | log_info (_("Note: sender requested \"for-your-eyes-only\"\n")); | ||||
else if (opt.verbose) | else if (opt.verbose) | ||||
{ | { | ||||
/* We don't use print_utf8_buffer because that would require a | /* We don't use print_utf8_buffer because that would require a | ||||
* string change which we don't want in 2.2. It is also not | * string change which we don't want in 2.2. It is also not | ||||
* clear whether the filename is always utf-8 encoded. */ | * clear whether the filename is always utf-8 encoded. */ | ||||
char *tmp = make_printable_string (pt->name, pt->namelen, 0); | char *tmp = make_printable_string (pt->name, pt->namelen, 0); | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
proc_compressed (CTX c, PACKET *pkt) | proc_compressed (CTX c, PACKET *pkt) | ||||
{ | { | ||||
PKT_compressed *zd = pkt->pkt.compressed; | PKT_compressed *zd = pkt->pkt.compressed; | ||||
int rc; | int rc; | ||||
/*printf("zip: compressed data packet\n");*/ | /*printf("zip: compressed data packet\n");*/ | ||||
if (c->sigs_only) | if (c->sigs_only) | ||||
{ | |||||
log_assert(!c->signed_data.used); | |||||
rc = handle_compressed (c->ctrl, c, zd, proc_compressed_cb, c); | rc = handle_compressed (c->ctrl, c, zd, proc_compressed_cb, c); | ||||
} | |||||
else if( c->encrypt_only ) | else if( c->encrypt_only ) | ||||
rc = handle_compressed (c->ctrl, c, zd, proc_encrypt_cb, c); | rc = handle_compressed (c->ctrl, c, zd, proc_encrypt_cb, c); | ||||
else | else | ||||
rc = handle_compressed (c->ctrl, c, zd, NULL, NULL); | rc = handle_compressed (c->ctrl, c, zd, NULL, NULL); | ||||
if (gpg_err_code (rc) == GPG_ERR_BAD_DATA) | if (gpg_err_code (rc) == GPG_ERR_BAD_DATA) | ||||
{ | { | ||||
if (!c->any.uncompress_failed) | if (!c->any.uncompress_failed) | ||||
▲ Show 20 Lines • Show All 502 Lines • ▼ Show 20 Lines | do_proc_packets (CTX c, iobuf_t a) | ||||
rc = check_nesting (c); | rc = check_nesting (c); | ||||
if (rc) | if (rc) | ||||
return rc; | return rc; | ||||
pkt = xmalloc( sizeof *pkt ); | pkt = xmalloc( sizeof *pkt ); | ||||
c->iobuf = a; | c->iobuf = a; | ||||
init_packet(pkt); | init_packet(pkt); | ||||
init_parse_packet (&parsectx, a); | init_parse_packet (&parsectx, a); | ||||
parsectx.sigs_only = c->sigs_only && c->signed_data.used; | |||||
while ((rc=parse_packet (&parsectx, pkt)) != -1) | while ((rc=parse_packet (&parsectx, pkt)) != -1) | ||||
{ | { | ||||
any_data = 1; | any_data = 1; | ||||
if (rc) | if (rc) | ||||
{ | { | ||||
free_packet (pkt, &parsectx); | free_packet (pkt, &parsectx); | ||||
/* Stop processing when an invalid packet has been encountered | /* Stop processing when an invalid packet has been encountered | ||||
* but don't do so when we are doing a --list-packets. */ | * but don't do so when we are doing a --list-packets. */ | ||||
if (gpg_err_code (rc) == GPG_ERR_INV_PACKET | if (gpg_err_code (rc) == GPG_ERR_INV_PACKET | ||||
&& opt.list_packets == 0) | && opt.list_packets == 0) | ||||
break; | break; | ||||
if (gpg_err_code (rc) == GPG_ERR_UNEXPECTED) | |||||
{ | |||||
write_status_text( STATUS_UNEXPECTED, "0" ); | |||||
goto leave; | |||||
} | |||||
continue; | continue; | ||||
} | } | ||||
newpkt = -1; | newpkt = -1; | ||||
if (opt.list_packets) | if (opt.list_packets) | ||||
{ | { | ||||
switch (pkt->pkttype) | switch (pkt->pkttype) | ||||
{ | { | ||||
case PKT_PUBKEY_ENC: proc_pubkey_enc (c, pkt); break; | case PKT_PUBKEY_ENC: proc_pubkey_enc (c, pkt); break; | ||||
Show All 12 Lines | while ((rc=parse_packet (&parsectx, pkt)) != -1) | ||||
case PKT_PUBLIC_KEY: | case PKT_PUBLIC_KEY: | ||||
case PKT_SECRET_KEY: | case PKT_SECRET_KEY: | ||||
case PKT_USER_ID: | case PKT_USER_ID: | ||||
case PKT_SYMKEY_ENC: | case PKT_SYMKEY_ENC: | ||||
case PKT_PUBKEY_ENC: | case PKT_PUBKEY_ENC: | ||||
case PKT_ENCRYPTED: | case PKT_ENCRYPTED: | ||||
case PKT_ENCRYPTED_MDC: | case PKT_ENCRYPTED_MDC: | ||||
case PKT_ENCRYPTED_AEAD: | case PKT_ENCRYPTED_AEAD: | ||||
log_assert(!c->signed_data.used); | |||||
write_status_text( STATUS_UNEXPECTED, "0" ); | write_status_text( STATUS_UNEXPECTED, "0" ); | ||||
rc = GPG_ERR_UNEXPECTED; | rc = GPG_ERR_UNEXPECTED; | ||||
goto leave; | goto leave; | ||||
case PKT_SIGNATURE: newpkt = add_signature (c, pkt); break; | case PKT_SIGNATURE: newpkt = add_signature (c, pkt); break; | ||||
case PKT_PLAINTEXT: proc_plaintext (c, pkt); break; | case PKT_PLAINTEXT: proc_plaintext (c, pkt); break; | ||||
case PKT_COMPRESSED: rc = proc_compressed (c, pkt); break; | case PKT_COMPRESSED: rc = proc_compressed (c, pkt); break; | ||||
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig (c, pkt); break; | case PKT_ONEPASS_SIG: newpkt = add_onepass_sig (c, pkt); break; | ||||
case PKT_GPG_CONTROL: newpkt = add_gpg_control (c, pkt); break; | case PKT_GPG_CONTROL: newpkt = add_gpg_control (c, pkt); break; | ||||
default: newpkt = 0; break; | default: | ||||
log_assert(!c->signed_data.used); | |||||
newpkt = 0; break; | |||||
} | } | ||||
} | } | ||||
else if (c->encrypt_only) | else if (c->encrypt_only) | ||||
{ | { | ||||
switch (pkt->pkttype) | switch (pkt->pkttype) | ||||
{ | { | ||||
case PKT_PUBLIC_KEY: | case PKT_PUBLIC_KEY: | ||||
case PKT_SECRET_KEY: | case PKT_SECRET_KEY: | ||||
▲ Show 20 Lines • Show All 1,122 Lines • Show Last 20 Lines |