/* -*-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
*
/*----- 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.
*
*
* 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));
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);
}