1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

* base64.c (base64_reader_cb): Try to detect an S/MIME body part.

* certdump.c (print_sexp): Renamed to gpgsm_dump_serial, made
global.
(print_time): Renamed to gpgsm_dump_time, made global.
(gpgsm_dump_serial): Take a real S-Expression as argument and
print the first item.
* keylist.c (list_cert_colon): Ditto.
* keydb.c (keydb_search_issuer_sn): Ditto.
* decrypt.c (print_integer_sexp): Removed and made callers
use gpgsm_dump_serial.
* verify.c (print_time): Removed, made callers use gpgsm_dump_time.
This commit is contained in:
Werner Koch 2001-12-20 13:25:08 +00:00
parent 3341f8a55d
commit 5f116e9540
8 changed files with 101 additions and 83 deletions

View file

@ -49,12 +49,13 @@ struct reader_cb_parm_s {
int autodetect; /* try to detect the input encoding */
int assume_pem; /* assume input encoding is PEM */
int assume_base64; /* assume inpout is base64 encoded */
int assume_base64; /* assume input is base64 encoded */
int identified;
int is_pem;
int is_base64;
int stop_seen;
int might_be_smime;
struct {
int idx;
@ -121,6 +122,31 @@ static unsigned char asctobin[256] = {
};
static int
has_only_base64 (const unsigned char *line, int linelen)
{
if (linelen < 20)
return 0;
for (; linelen; line++, linelen--)
{
if (*line == '\n' || (linelen > 1 && *line == '\r' && line[1] == '\n'))
break;
if ( !strchr (bintoasc, *line) )
return 0;
}
return 1; /* yes */
}
static int
is_empty_line (const unsigned char *line, int linelen)
{
if (linelen >= 2 && *line == '\r' && line[1] == '\n')
return 1;
if (linelen >= 1 && *line == '\n')
return 1;
return 0;
}
static int
base64_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
@ -197,6 +223,30 @@ base64_reader_cb (void *cb_value, char *buffer, size_t count, size_t *nread)
parm->is_pem = 1;
parm->linelen = parm->readpos = 0;
}
else if ( parm->have_lf && parm->line_counter == 1
&& !strncmp (parm->line, "Content-Type:", 13))
{ /* Might be a S/MIME body */
parm->might_be_smime = 1;
parm->linelen = parm->readpos = 0;
goto next;
}
else if (parm->might_be_smime == 1
&& is_empty_line (parm->line, parm->linelen))
{
parm->might_be_smime = 2;
parm->linelen = parm->readpos = 0;
goto next;
}
else if (parm->might_be_smime == 2)
{
parm->might_be_smime = 0;
if ( !has_only_base64 (parm->line, parm->linelen))
{
parm->linelen = parm->readpos = 0;
goto next;
}
parm->is_pem = 1;
}
else
{
parm->linelen = parm->readpos = 0;