diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 1999-03-22 16:00:36 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 1999-03-22 16:00:36 +0000 |
commit | 5856b6fff90bdc15915d17ae4bf38716eb8cf10b (patch) | |
tree | b8e7148e8a6bdac1b74b62473df592fc0ea2557c | |
parent | c278a285ca8ec6b761d9ebbcd97370ab76b48547 (diff) |
PGP key creation time fix by Roland Rosenfeld.
-rw-r--r-- | doc/manual.sgml.in | 23 | ||||
-rw-r--r-- | gnupgparse.c | 16 | ||||
-rw-r--r-- | pgp.h | 2 | ||||
-rw-r--r-- | pgpkey.c | 63 | ||||
-rw-r--r-- | pgppubring.c | 10 |
5 files changed, 108 insertions, 6 deletions
diff --git a/doc/manual.sgml.in b/doc/manual.sgml.in index 9f2cd204..bfd39a2c 100644 --- a/doc/manual.sgml.in +++ b/doc/manual.sgml.in @@ -3405,6 +3405,29 @@ Default: set If set, the PGP <em/+encrypttoself/ flag is used when encrypting messages. +<sect2>pgp_entry_format<label id="pgp_entry_format"> +<p> +Type: format string<newline> +Default: &dquot;%4n %t%f %4l/0x%k %-4a %2c %u&dquot; + +This variable allows you to customize the PGP key selection menu to +your personal taste. This string is similar to <ref id="index_format" +name="$index_format">, but has its own set of +printf()-like sequences: + +<tscreen><verb> +%n number +%k key id +%u user id +%a algorithm +%l key length +%f flags +%c capabilities +%t trust/validity of the key-uid association +%[<s>] date of the key where <s> is an strftime(3) expression +</verb></tscreen> + + <sect2>pgp_gpg<label id="pgp_gpg"> <p> Type: string<newline> diff --git a/gnupgparse.c b/gnupgparse.c index d4900a6e..ce8074fc 100644 --- a/gnupgparse.c +++ b/gnupgparse.c @@ -142,7 +142,23 @@ static pgp_key_t *parse_pub_line (char *buf, int *is_subkey, pgp_key_t *k) } case 6: /* timestamp (1998-02-28) */ + { + char tstr[11]; + struct tm time; + if (!p) + break; + time.tm_sec = 0; + time.tm_min = 0; + time.tm_hour = 12; + strncpy (tstr, p, 11); + tstr[4] = '\0'; + time.tm_year = atoi (tstr)-1900; + tstr[7] = '\0'; + time.tm_mon = (atoi (tstr+5))-1; + time.tm_mday = atoi (tstr+8); + k->gen_time = mutt_mktime (&time, 0); break; + } case 7: /* valid for n days */ break; case 8: /* Local id */ @@ -44,7 +44,7 @@ typedef struct pgp_keyinfo struct pgp_uid *address; int flags; short keylen; - unsigned long gen_time; + time_t gen_time; const char *algorithm; struct pgp_keyinfo *parent; struct pgp_keyinfo *next; @@ -97,12 +97,13 @@ static pgp_key_t *pgp_principal_key (pgp_key_t *key) * * %n number * %k key id %K key id of the principal key - * %u uiser id + * %u user id * %a algorithm %A algorithm of the princ. key * %l length %L length of the princ. key * %f flags %F flags of the princ. key * %c capabilities %C capabilities of the princ. key * %t trust/validity of the key-uid association + * %[...] date of key using strftime(3) */ typedef struct pgp_entry @@ -144,6 +145,66 @@ static const char *pgp_entry_fmt (char *dest, switch (tolower (op)) { + case '[': + + { + const char *cp; + char buf2[SHORT_STRING], *p; + int do_locales; + struct tm *tm; + size_t len; + + p = dest; + + cp = src; + if (*cp == '!') + { + do_locales = 0; + cp++; + } + else + do_locales = 1; + + len = destlen - 1; + while (len > 0 && *cp != ']') + { + if (*cp == '%') + { + cp++; + if (len >= 2) + { + *p++ = '%'; + *p++ = *cp; + len -= 2; + } + else + break; /* not enough space */ + cp++; + } + else + { + *p++ = *cp++; + len--; + } + } + *p = 0; + + if (do_locales && Locale) + setlocale (LC_TIME, Locale); + + tm = localtime (&key->gen_time); + + strftime (buf2, sizeof (buf2), dest, tm); + + if (do_locales) + setlocale (LC_TIME, "C"); + + snprintf (fmt, sizeof (fmt), "%%%ss", prefix); + snprintf (dest, destlen, fmt, buf2); + if (len > 0) + src = cp + 1; + } + break; case 'n': if (!optional) { diff --git a/pgppubring.c b/pgppubring.c index 39cd6358..ad001e78 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -506,7 +506,7 @@ static pgp_key_t *pgp_parse_pgp2_key (unsigned char *buff, size_t l) unsigned char alg; size_t expl; unsigned long id; - unsigned long gen_time = 0; + time_t gen_time = 0; unsigned short exp_days = 0; size_t j; int i, k; @@ -520,6 +520,8 @@ static pgp_key_t *pgp_parse_pgp2_key (unsigned char *buff, size_t l) for (i = 0, j = 2; i < 4; i++) gen_time = (gen_time << 8) + buff[j++]; + p->gen_time = gen_time; + for (i = 0; i < 2; i++) exp_days = (exp_days << 8) + buff[j++]; @@ -610,7 +612,7 @@ static pgp_key_t *pgp_parse_pgp3_key (unsigned char *buff, size_t l) unsigned char alg; unsigned char digest[SHA_DIGEST_LENGTH]; unsigned char scratch[LONG_STRING]; - unsigned long gen_time = 0; + time_t gen_time = 0; unsigned long id; int i, k; short len; @@ -680,7 +682,7 @@ static pgp_key_t *pgp_parse_keyinfo (unsigned char *buff, size_t l) static int pgp_parse_pgp2_sig (unsigned char *buff, size_t l, pgp_key_t * p) { unsigned char sigtype; - long sig_gen_time; + time_t sig_gen_time; unsigned long signerid; size_t j; int i; @@ -712,7 +714,7 @@ static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l, pgp_key_t * p) unsigned char pkalg; unsigned char hashalg; unsigned char skt; - long sig_gen_time = -1; + time_t sig_gen_time = -1; long validity = -1; long key_validity = -1; long signerid = 0; |