mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01: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:
parent
3341f8a55d
commit
5f116e9540
15
sm/ChangeLog
15
sm/ChangeLog
@ -1,3 +1,18 @@
|
||||
2001-12-20 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* 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.
|
||||
|
||||
2001-12-19 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* call-agent.c (start_agent): Add new argument to assuan_pipe_connect.
|
||||
|
52
sm/base64.c
52
sm/base64.c
@ -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;
|
||||
|
@ -33,20 +33,24 @@
|
||||
#include "gpgsm.h"
|
||||
#include "keydb.h"
|
||||
|
||||
static void
|
||||
print_sexp (KsbaConstSexp p)
|
||||
/* print the first element of an S-Expression */
|
||||
void
|
||||
gpgsm_dump_serial (KsbaConstSexp p)
|
||||
{
|
||||
unsigned long n;
|
||||
KsbaConstSexp endp;
|
||||
|
||||
if (!p)
|
||||
log_printf ("none");
|
||||
else if (*p != '(')
|
||||
log_printf ("ERROR - not an S-expression");
|
||||
else
|
||||
{
|
||||
p++;
|
||||
n = strtoul (p, (char**)&endp, 10);
|
||||
p = endp;
|
||||
if (*p!=':')
|
||||
log_printf ("ERROR - invalid value");
|
||||
log_printf ("ERROR - invalid S-expression");
|
||||
else
|
||||
{
|
||||
for (p++; n; n--, p++)
|
||||
@ -57,8 +61,8 @@ print_sexp (KsbaConstSexp p)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
print_time (time_t t)
|
||||
void
|
||||
gpgsm_dump_time (time_t t)
|
||||
{
|
||||
|
||||
if (!t)
|
||||
@ -77,6 +81,7 @@ print_time (time_t t)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
print_dn (char *p)
|
||||
{
|
||||
@ -100,17 +105,17 @@ gpgsm_dump_cert (const char *text, KsbaCert cert)
|
||||
{
|
||||
sexp = ksba_cert_get_serial (cert);
|
||||
log_debug (" serial: ");
|
||||
print_sexp (sexp);
|
||||
gpgsm_dump_serial (sexp);
|
||||
ksba_free (sexp);
|
||||
log_printf ("\n");
|
||||
|
||||
t = ksba_cert_get_validity (cert, 0);
|
||||
log_debug (" notBefore: ");
|
||||
print_time (t);
|
||||
gpgsm_dump_time (t);
|
||||
log_printf ("\n");
|
||||
t = ksba_cert_get_validity (cert, 1);
|
||||
log_debug (" notAfter: ");
|
||||
print_time (t);
|
||||
gpgsm_dump_time (t);
|
||||
log_printf ("\n");
|
||||
|
||||
dn = ksba_cert_get_issuer (cert, 0);
|
||||
@ -133,3 +138,5 @@ gpgsm_dump_cert (const char *text, KsbaCert cert)
|
||||
}
|
||||
log_debug ("END Certificate\n");
|
||||
}
|
||||
|
||||
|
||||
|
23
sm/decrypt.c
23
sm/decrypt.c
@ -50,27 +50,6 @@ struct decrypt_filter_parm_s {
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
print_integer_sexp (unsigned char *p)
|
||||
{
|
||||
unsigned long len;
|
||||
|
||||
if (!p)
|
||||
log_printf ("none");
|
||||
else
|
||||
{
|
||||
len = gcry_sexp_canon_len (p, 0, NULL, NULL);
|
||||
if (!len)
|
||||
log_printf ("invalid encoding");
|
||||
else
|
||||
{
|
||||
for (; len && *p != ':'; len--, p++)
|
||||
;
|
||||
for (p++; len; len--, p++)
|
||||
log_printf ("%02X", *p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* decrypt the session key and fill in the parm structure. The
|
||||
algo and the IV is expected to be already in PARM. */
|
||||
@ -370,7 +349,7 @@ gpgsm_decrypt (CTRL ctrl, int in_fd, FILE *out_fp)
|
||||
log_debug ("recp %d - issuer: `%s'\n",
|
||||
recp, issuer? issuer:"[NONE]");
|
||||
log_debug ("recp %d - serial: ", recp);
|
||||
print_integer_sexp (serial);
|
||||
gpgsm_dump_serial (serial);
|
||||
log_printf ("\n");
|
||||
|
||||
keydb_search_reset (kh);
|
||||
|
@ -138,6 +138,8 @@ void gpgsm_destroy_writer (Base64Context ctx);
|
||||
|
||||
/*-- certdump.c --*/
|
||||
void gpgsm_dump_cert (const char *text, KsbaCert cert);
|
||||
void gpgsm_dump_serial (KsbaConstSexp p);
|
||||
void gpgsm_dump_time (time_t t);
|
||||
|
||||
/*-- certcheck.c --*/
|
||||
int gpgsm_check_cert_sig (KsbaCert issuer_cert, KsbaCert cert);
|
||||
|
@ -842,7 +842,11 @@ keydb_search_issuer_sn (KEYDB_HANDLE hd,
|
||||
|
||||
memset (&desc, 0, sizeof desc);
|
||||
desc.mode = KEYDB_SEARCH_MODE_ISSUER_SN;
|
||||
for (s=serial,desc.snlen = 0; digitp (s); s++)
|
||||
s = serial;
|
||||
if (*s !='(')
|
||||
return GNUPG_Invalid_Value;
|
||||
s++;
|
||||
for (desc.snlen = 0; digitp (s); s++)
|
||||
desc.snlen = 10*desc.snlen + atoi_1 (s);
|
||||
if (*s !=':')
|
||||
return GNUPG_Invalid_Value;
|
||||
|
@ -150,11 +150,15 @@ list_cert_colon (KsbaCert cert, FILE *fp)
|
||||
int len;
|
||||
const unsigned char *s = sexp;
|
||||
|
||||
if (*s == '(')
|
||||
{
|
||||
s++;
|
||||
for (len=0; *s && *s != ':' && digitp (s); s++)
|
||||
len = len*10 + atoi_1 (s);
|
||||
if (*s == ':')
|
||||
for (s++; len; len--, s++)
|
||||
fprintf (fp,"%02X", *s);
|
||||
}
|
||||
xfree (sexp);
|
||||
}
|
||||
putc (':', fp);
|
||||
|
49
sm/verify.c
49
sm/verify.c
@ -84,49 +84,6 @@ store_cert (KsbaCert cert)
|
||||
|
||||
|
||||
|
||||
static void
|
||||
print_integer_sexp (unsigned char *p)
|
||||
{
|
||||
unsigned long len;
|
||||
|
||||
if (!p)
|
||||
log_printf ("none");
|
||||
else
|
||||
{
|
||||
len = gcry_sexp_canon_len (p, 0, NULL, NULL);
|
||||
if (!len)
|
||||
log_printf ("invalid encoding");
|
||||
else
|
||||
{
|
||||
for (; len && *p != ':'; len--, p++)
|
||||
;
|
||||
for (p++; len; len--, p++)
|
||||
log_printf ("%02X", *p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
print_time (time_t t)
|
||||
{
|
||||
|
||||
if (!t)
|
||||
log_printf ("none");
|
||||
else if ( t == (time_t)(-1) )
|
||||
log_printf ("error");
|
||||
else
|
||||
{
|
||||
struct tm *tp;
|
||||
|
||||
tp = gmtime (&t);
|
||||
log_printf ("%04d-%02d-%02d %02d:%02d:%02d",
|
||||
1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
|
||||
tp->tm_hour, tp->tm_min, tp->tm_sec);
|
||||
assert (!tp->tm_isdst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
@ -307,7 +264,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd)
|
||||
break;
|
||||
log_debug ("signer %d - issuer: `%s'\n", signer, issuer? issuer:"[NONE]");
|
||||
log_debug ("signer %d - serial: ", signer);
|
||||
print_integer_sexp (serial);
|
||||
gpgsm_dump_serial (serial);
|
||||
log_printf ("\n");
|
||||
|
||||
err = ksba_cms_get_signing_time (cms, signer, &sigtime);
|
||||
@ -317,7 +274,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd)
|
||||
sigtime = (time_t)-1;
|
||||
}
|
||||
log_debug ("signer %d - sigtime: ", signer);
|
||||
print_time (sigtime);
|
||||
gpgsm_dump_time (sigtime);
|
||||
log_printf ("\n");
|
||||
|
||||
|
||||
@ -341,7 +298,7 @@ gpgsm_verify (CTRL ctrl, int in_fd, int data_fd)
|
||||
log_error ("no signature value available\n");
|
||||
goto next_signer;
|
||||
}
|
||||
log_debug ("signer %d - signature: `%s'\n", signer, sigval);
|
||||
log_debug ("signer %d - signature available", signer);
|
||||
|
||||
/* Find the certificate of the signer */
|
||||
keydb_search_reset (kh);
|
||||
|
Loading…
x
Reference in New Issue
Block a user