X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/410c8acf139e945dce28bbc0c8b17dcfd0815643..110d564e1b2a4d97b99cc34e1481fa6279ad9695:/keymgmt.c diff --git a/keymgmt.c b/keymgmt.c index 960b9c93..54a31b0b 100644 --- a/keymgmt.c +++ b/keymgmt.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: keymgmt.c,v 1.1 2001/02/03 20:26:37 mdw Exp $ + * $Id: keymgmt.c,v 1.3 2001/06/22 19:40:36 mdw Exp $ * * Key loading and storing * @@ -29,6 +29,12 @@ /*----- Revision history --------------------------------------------------* * * $Log: keymgmt.c,v $ + * Revision 1.3 2001/06/22 19:40:36 mdw + * Support expiry of other peers' public keys. + * + * Revision 1.2 2001/06/19 22:07:09 mdw + * Cosmetic fixes. + * * Revision 1.1 2001/02/03 20:26:37 mdw * Initial checkin. * @@ -53,7 +59,7 @@ static fwatch w_priv, w_pub; /* --- @keymoan@ --- * * - * Arguments: @@const char *file@ = name of the file + * Arguments: @const char *file@ = name of the file * @int line@ = line number in file * @const char *msg@ = error message * @void *p@ = argument pointer @@ -230,21 +236,26 @@ void km_init(const char *priv, const char *pub, const char *tag) * * Arguments: @const char *tag@ = public key tag to load * @dh_pub *kpub@ = where to put the public key + * @time_t *t_exp@ = where to put the expiry time * * Returns: Zero if OK, nonzero if it failed. * * Use: Fetches a public key from the keyring. */ -int km_getpubkey(const char *tag, dh_pub *kpub) +int km_getpubkey(const char *tag, dh_pub *kpub, time_t *t_exp) { key_packstruct kps[DH_PUBFETCHSZ]; key_packdef *kp; + key *k; dh_pub dp; int e; kp = key_fetchinit(dh_pubfetch, kps, &dp); - e = key_fetchbyname(kp, kf_pub, tag); + if ((k = key_bytag(kf_pub, tag)) == 0) + e = KERR_NOTFOUND; + else + e = key_fetch(kp, k); key_fetchdone(kp); if (e) { a_warn("error loading public key `%s': %s", tag, key_strerror(e)); @@ -269,6 +280,7 @@ int km_getpubkey(const char *tag, dh_pub *kpub) kpub->dp.q = MP_COPY(dp.dp.q); kpub->dp.g = MP_COPY(dp.dp.g); kpub->y = MP_COPY(dp.y); + *t_exp = k->exp; return (0); }