chiark / gitweb /
Support expiry of other peers' public keys.
[tripe] / keymgmt.c
index 55a188bbe967ccb3e01027637b7e542967edc18b..54a31b0b981e6fb686a0cf4779743d9ef8f85459 100644 (file)
--- a/keymgmt.c
+++ b/keymgmt.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: keymgmt.c,v 1.2 2001/06/19 22:07:09 mdw Exp $
+ * $Id: keymgmt.c,v 1.3 2001/06/22 19:40:36 mdw Exp $
  *
  * Key loading and storing
  *
@@ -29,6 +29,9 @@
 /*----- 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.
  *
@@ -233,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));
@@ -272,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);
 }