/* -*-c-*-
*
- * $Id: key.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
+ * $Id: key.h,v 1.5 2000/02/12 18:55:40 mdw Exp $
*
* Simple key management
*
- * (c) 1999 Mark Wooding
+ * (c) 1999 Straylight/Edgeware
*/
/*----- Licensing notice --------------------------------------------------*
/*----- Revision history --------------------------------------------------*
*
* $Log: key.h,v $
+ * Revision 1.5 2000/02/12 18:55:40 mdw
+ * Make it all compile properly.
+ *
+ * Revision 1.4 2000/02/12 18:21:02 mdw
+ * Overhaul of key management (again).
+ *
+ * Revision 1.3 1999/12/22 15:47:48 mdw
+ * Major key-management revision.
+ *
* Revision 1.2 1999/12/10 23:29:48 mdw
* Change header file guard names.
*
#include <time.h>
#include <mLib/bits.h>
+#include <mLib/dstr.h>
#include <mLib/hash.h>
#include <mLib/sym.h>
+#ifndef CATACOMB_KEY_DATA_H
+# include "key-data.h"
+#endif
+
+#ifndef CATACOMB_MP_H
+# include "mp.h"
+#endif
+
/*----- Data structures ---------------------------------------------------*/
/* --- Key attributes --- *
*/
typedef struct key {
+
+ /* --- Hashtable management --- */
+
hash_base _b; /* Symbol table data */
struct key *next; /* Next key of the same type */
+
+ /* --- Basic key attributes --- */
+
uint32 id; /* Key id used to name it */
+ char *tag; /* Textual tag name */
char *type; /* Textual key type */
- void *k; /* Actual key data */
- size_t ksz; /* Size of the key data */
time_t exp, del; /* Expiry times for keys */
+
+ /* --- The key data itself --- */
+
+ key_data k; /* The actual key data */
+
+ /* --- Other attributes and commentary --- */
+
sym_table a; /* Hashtable of key attributes */
char *c; /* Any additional comments */
} key;
/* --- The keys-by-type entries --- */
-typedef struct key_type {
+typedef struct key_ref {
sym_base _b; /* Symbol table data */
key *k; /* Pointer to first key in list */
-} key_type;
+} key_ref;
/* --- A key file --- */
typedef struct key_file {
FILE *fp; /* File pointer open on file */
- int fd; /* File descriptor open on file */
char *name; /* Filename used to create it */
unsigned f; /* Various useful flags */
hash_table byid; /* Table of keys by keyid */
sym_table bytype; /* Table of keys by type */
+ sym_table bytag; /* Table of keys by tag */
size_t idload; /* Loading on id table */
} key_file;
/* --- Various other magic numbers --- */
-#define KEXP_UNUSED ((time_t)0) /* Key has never been used */
#define KEXP_FOREVER ((time_t)-1) /* Never expire this key */
#define KEXP_EXPIRE ((time_t)-2) /* Expire this key when unused */
-/* --- Write attempt codes --- */
+/* --- Key error codes --- */
+
+enum {
+ KERR_OK = 0, /* No error */
+ KERR_BADTAG = -1, /* Malformed tag string */
+ KERR_BADTYPE = -2, /* Malformed type string */
+ KERR_BADCOMMENT = -3, /* Malformed comment string */
+ KERR_DUPID = -4, /* Duplicate keyid */
+ KERR_DUPTAG = -5, /* Duplicate key tag string */
+ KERR_READONLY = -6, /* Key file is read-only */
+ KERR_WILLEXPIRE = -7, /* Key will eventually expire */
+ KERR_EXPIRED = -8, /* Key has already expired */
+ KERR_BADFLAGS = -9, /* Error in flags string */
+ KERR_BADPASS = -10, /* Error decrypting locked key */
+ KERR_WRONGTYPE = -11, /* Key has incorrect type */
+ KERR_NOTFOUND = -12, /* Key couldn't be found */
+ KERR_MAX /* Largest possible error */
+};
+
+/* --- Write error codes --- */
enum {
KWRITE_OK, /* Everything went fine */
KWRITE_BROKEN = -2 /* Key ring needs manual fixing */
};
+/* --- Error reporting functions for @key_merge@ and @key_open@ --- */
+
+typedef void key_reporter(const char */*file*/, int /*line*/,
+ const char */*err*/, void */*p*/);
+
/* --- Macros for testing expiry --- */
#define KEY_EXPIRED(now, exp) \
((exp) == KEXP_EXPIRE || ((exp) != KEXP_FOREVER && (exp) < (now)))
-#define KEY_DELETED(now, del) ((del) == KEXP_FOREVER || (del) < (now))
+/*----- Reading and writing keys and files --------------------------------*/
-/*----- Functions provided ------------------------------------------------*/
+/* --- @key_merge@ --- *
+ *
+ * Arguments: @key_file *f@ = pointer to file structure
+ * @const char *file@ = name of file (for error messages)
+ * @FILE *fp@ = file handle to read from
+ * @key_reporter *rep@ = error reporting function
+ * @void *arg@ = argument for function
+ *
+ * Returns: Error code (one of the @KERR@ constants).
+ *
+ * Use: Reads keys from a file, and inserts them into the file.
+ */
-/* --- @key_chktype@ --- *
+extern int key_merge(key_file */*f*/, const char */*file*/, FILE */*fp*/,
+ key_reporter */*rep*/, void */*arg*/);
+
+/* --- @key_extract@ --- *
*
- * Arguments: @const char *type@ = pointer to a type string
+ * Arguments: @key_file *f@ = pointer to file structure
+ * @key *k@ = key to extract
+ * @FILE *fp@ = file to write on
+ * @const key_filter *kf@ = pointer to key selection block
*
- * Returns: Zero if OK, -1 on error.
+ * Returns: Zero if OK, EOF on error.
*
- * Use: Checks whether a type string is OK.
+ * Use: Extracts a key to an ouptut file.
*/
-extern int key_chktype(const char */*type*/);
+extern int key_extract(key_file */*f*/, key */*k*/, FILE */*fp*/,
+ const key_filter */*kf*/);
-/* --- @key_chkcomment@ --- *
+/* --- @key_open@ --- *
*
- * Arguments: @const char *comment@ = pointer to a comment string
+ * Arguments: @key_file *f@ = pointer to file structure to initialize
+ * @const char *file@ = pointer to the file name
+ * @int how@ = opening options (@KOPEN_*@).
+ * @key_reporter *rep@ = error reporting function
+ * @void *arg@ = argument for function
*
- * Returns: Zero if OK, -1 on error.
+ * Returns: Zero if it worked, nonzero otherwise.
*
- * Use: Checks whether a comment string is OK.
+ * Use: Opens a key file, reads its contents, and stores them in a
+ * structure. The file is locked appropriately until closed
+ * using @key_close@. On an error, everything is cleared away
+ * tidily. If the file is opened with @KOPEN_WRITE@, it's
+ * created if necessary, with read and write permissions for its
+ * owner only.
*/
-extern int key_chkcomment(const char */*c*/);
+extern int key_open(key_file */*f*/, const char */*file*/, int /*how*/,
+ key_reporter */*rep*/, void */*arg*/);
-/* --- @key_mkiter@ --- *
+/* --- @key_close@ --- *
*
- * Arguments: @key_iter *i@ = pointer to iterator object
- * @key_file *f@ = pointer to file structure
+ * Arguments: @key_file *f@ = pointer to key file block
*
- * Returns: ---
+ * Returns: A @KWRITE_@ code indicating how it went.
*
- * Use: Initializes a key iterator. The keys are returned by
- * @key_next@.
+ * Use: Frees all the key data, writes any changes. Make sure that
+ * all hell breaks loose if this returns @KWRITE_BROKEN@.
*/
-extern void key_mkiter(key_iter */*i*/, key_file */*f*/);
+extern int key_close(key_file */*f*/);
-/* --- @key_next@ --- *
+/* --- @key_save@ --- *
*
- * Arguments: @key_iter *i@ = pointer to iterator object
+ * Arguments: @key_file *f@ = pointer to key file block
*
- * Returns: Pointer to next key, or null.
+ * Returns: A @KWRITE_@ code indicating how well it worked.
*
- * Use: Returns the next key in some arbitrary sequence.
+ * Use: Writes a key file's data back to the actual file. This code
+ * is extremely careful about error handling. It should usually
+ * be able to back out somewhere sensible, but it can tell when
+ * it's got itself into a real pickle and starts leaving well
+ * alone.
+ *
+ * Callers, please make sure that you ring alarm bells when this
+ * function returns @KWRITE_BROKEN@.
*/
-extern key *key_next(key_iter */*i*/);
+extern int key_save(key_file */*f*/);
-/* --- @key_mkattriter@ --- *
+/* --- @key_lockfile@ --- *
*
- * Arguments: @key_attriter *i@ = pointer to attribute iterator
- * @key_file *f@ = pointer to key file
- * @key *k@ = pointer to key
+ * Arguments: @key_file *f@ = pointer to file structure to initialize
+ * @const char *file@ = pointer to the file name
+ * @int how@ = opening options (@KOPEN_*@).
*
- * Returns: ---
+ * Returns: Zero if it worked, nonzero otherwise.
*
- * Use: Initializes an attribute iterator. The attributes are
- * returned by @key_nextattr@.
+ * Use: Opens a keyfile and stores the information needed for
+ * continued access in the structure.
+ *
+ * If the file is opened with @KOPEN_WRITE@, it's created if
+ * necessary with read and write permissions for owner only, and
+ * locked for update while it's open.
+ *
+ * This is a system-dependent routine, and only really intended
+ * for the private use of @key_open@.
*/
-extern void key_mkattriter(key_attriter */*i*/, key_file */*f*/, key */*k*/);
+extern int key_lockfile(key_file */*f*/, const char */*file*/, int /*how*/);
-/* --- @key_nextattr@ --- *
+/*----- Creating and manipulating keys ------------------------------------*/
+
+/* --- @key_new@ ---
*
- * Arguments: @key_attriter *i@ = pointer to attribute iterator
- * @const char **n, **v@ = pointers to name and value
+ * Arguments: @key_file *f@ = pointer to key file
+ * @uint32 id@ = keyid to set
+ * @const char *type@ = the type of this key
+ * @time_t exp@ = when the key expires
+ * @int *err@ = where to store the error condition
*
- * Returns: Zero if no attribute available, or nonzero if returned OK.
+ * Returns: Key block containing new data, or null if it couldn't be
+ * done.
*
- * Use: Returns the next attribute.
+ * Use: Attaches a new key to a key file. You must have a writable
+ * key file for this to work.
+ *
+ * The type is a key type string. This interface doesn't care
+ * about how type strings are formatted: it just treats them as
+ * opaque gobs of text. Clients are advised to choose some
+ * standard for representing key types, though.
+ *
+ * The expiry time should either be a time in the future, or the
+ * magic value @KEXP_FOREVER@ which means `never expire this
+ * key'. Be careful with `forever' keys. If I were you, I'd
+ * use a more sophisticated key management system than this for
+ * them.
+ *
+ * You have to set the actual key yourself.
*/
-extern int key_nextattr(key_attriter */*i*/,
- const char **/*n*/, const char **/*v*/);
+extern key *key_new(key_file */*f*/, uint32 /*id*/, const char */*type*/,
+ time_t /*exp*/, int */*err*/);
-/* --- @key_bytype@ --- *
+/* --- @key_delete@ --- *
*
- * Arguments: @key_file *f@ = key file we want a key from
- * @const char *type@ = type string for desired key
+ * Arguments: @key_file *f@ = pointer to file block
+ * @key *k@ = key to delete
*
- * Returns: Pointer to the best key to use, or null.
+ * Returns: Error code (one of the @KERR@ constants).
*
- * Use: Looks up a key by its type. Returns the key with the latest
- * expiry time. This function will not return an expired key.
+ * Use: Removes the given key from the list. The key file must be
+ * writable. (Due to the horridness of the data structures,
+ * deleted keys aren't actually removed, just marked so that
+ * they can't be looked up or iterated over. One upshot of
+ * this is that they don't get written back to the file when
+ * it's closed.)
*/
-extern key *key_bytype(key_file */*f*/, const char */*type*/);
+extern int key_delete(key_file */*f*/, key */*k*/);
-/* --- @key_byid@ --- *
+/* --- @key_expire@ --- *
*
- * Arguments: @key_file *f@ = key file to find a key from
- * @uint32 id@ = id to look for
+ * Arguments: @key_file *f@ = pointer to file block
+ * @key *k@ = pointer to key block
*
- * Returns: Key with matching id.
+ * Returns: Error code (one of the @KERR@ constants).
*
- * Use: Returns a key given its id. This function will return an
- * expired key, but not a deleted one.
+ * Use: Immediately marks the key as expired. It may be removed
+ * immediately, if it is no longer required, and will be removed
+ * by a tidy operation when it is no longer required. The key
+ * file must be writable.
*/
-extern key *key_byid(key_file */*f*/, uint32 /*id*/);
+extern int key_expire(key_file */*f*/, key */*k*/);
-/* --- @key_getattr@ --- *
+/* --- @key_used@ --- *
*
- * Arguments: @key_file *f@ = pointer to file
- * @key *k@ = pointer to key
- * @const char *n@ = pointer to attribute name
+ * Arguments: @key_file *f@ = pointer to key file
+ * @key *k@ = pointer to key block
+ * @time_t t@ = when key can be removed
*
- * Returns: Pointer to attribute value, or null if not found.
+ * Returns: Zero if OK, nonzero on failure.
*
- * Use: Returns the value of a key attribute.
+ * Use: Marks a key as being required until a given time. Even
+ * though the key may expire before then (and won't be returned
+ * by type after that time), it will still be available when
+ * requested explicitly by id. The key file must be writable.
+ *
+ * The only (current) reason for failure is attempting to use
+ * a key which can expire for something which can't.
*/
-extern const char *key_getattr(key_file */*f*/, key */*k*/,
- const char */*n*/);
+extern int key_used(key_file */*f*/, key */*k*/, time_t /*t*/);
-/* --- @key_putattr@ --- *
+/*----- Setting and reading attributes ------------------------------------*/
+
+/* --- @key_chkident@ --- *
*
- * Arguments: @key_file *f@ = pointer to file
- * @key *k@ = pointer to key
- * @const char *n@ = pointer to attribute name
- * @const char *v@ = pointer to attribute value
+ * Arguments: @const char *p@ = pointer to a type string
*
- * Returns: ---
+ * Returns: Zero if OK, -1 on error.
*
- * Use: Inserts an attribute on a key. If an attribute with the same
- * name already exists, it is deleted.
+ * Use: Checks whether an identification component string is OK.
*/
-extern void key_putattr(key_file */*f*/, key */*k*/,
- const char */*n*/, const char */*v*/);
+extern int key_chkident(const char */*p*/);
+
+/* --- @key_chkcomment@ --- *
+ *
+ * Arguments: @const char *p@ = pointer to a comment string
+ *
+ * Returns: Zero if OK, -1 on error.
+ *
+ * Use: Checks whether a comment string is OK.
+ */
+
+extern int key_chkcomment(const char */*p*/);
/* --- @key_setcomment@ --- *
*
* @key *k@ = pointer to key block
* @const char *c@ = pointer to comment to set, or zero
*
- * Returns: ---
+ * Returns: Error code (one of the @KERR@ constants).
*
* Use: Replaces the key's current comment with a new one.
*/
-extern void key_setcomment(key_file */*f*/, key */*k*/, const char */*c*/);
+extern int key_setcomment(key_file */*f*/, key */*k*/, const char */*c*/);
-/* --- @key_merge@ --- *
+/* --- @key_settag@ --- *
*
- * Arguments: @key_file *f@ = pointer to file structure
- * @const char *file@ = name of file (for error messages)
- * @FILE *fp@ = file handle to read from
+ * Arguments: @key_file *f@ = pointer to key file block
+ * @key *k@ = pointer to key block
+ * @const char *tag@ = pointer to comment to set, or zero
*
- * Returns: ---
+ * Returns: Error code (one of the @KERR@ constants).
*
- * Use: Reads keys from a file, and inserts them into the file.
+ * Use: Replaces the key's current tag with a new one.
*/
-extern void key_merge(key_file */*f*/, const char */*file*/, FILE */*fp*/);
+extern int key_settag(key_file */*f*/, key */*k*/, const char */*tag*/);
-/* --- @key_extract@ --- *
+/* --- @key_fulltag@ --- *
*
- * Arguments: @key_file *f@ = pointer to file structure
- * @key *k@ = key to extract
- * @FILE *fp@ = file to write on
+ * Arguments: @key *k@ = pointer to key
+ * @dstr *d@ = pointer to destination string
*
- * Returns: Zero if OK, EOF on error.
+ * Returns: ---
*
- * Use: Extracts a key to an ouptut file.
+ * Use: Emits the key's full tag, which has the form
+ * `ID:TYPE[:TAG]'. This is used in the textual file format,
+ * and to identify passphrases for locked keys.
*/
-extern int key_extract(key_file */*f*/, key */*k*/, FILE */*fp*/);
+extern void key_fulltag(key */*k*/, dstr */*d*/);
-/* --- @key_write@ --- *
+/* --- @key_qtag@ --- *
*
- * Arguments: @key_file *f@ = pointer to key file block
+ * Arguments: @key_file *f@ = key file to find a key from
+ * @const char *tag@ = pointer to tag string
+ * @dstr *d@ = pointer to string for full tag name
+ * @key **k@ = where to store the key pointer
+ * @key_data **kd@ = where to store the key data pointer
+ *
+ * Returns: Zero if OK, nonzero if it failed.
+ *
+ * Use: Performs a full lookup on a qualified tag name. The tag is
+ * qualified by the names of subkeys, separated by dots. Hence,
+ * a qualified tag is ID|TAG[.TAG...]. The various result
+ * pointers can be null to indicate that the result isn't
+ * interesting.
+ */
+
+extern int key_qtag(key_file */*f*/, const char */*tag*/,
+ dstr */*d*/, key **/*k*/, key_data **/*kd*/);
+
+/* --- @key_getattr@ --- *
*
- * Returns: A @KWRITE_@ code indicating how well it worked.
+ * Arguments: @key_file *f@ = pointer to file
+ * @key *k@ = pointer to key
+ * @const char *n@ = pointer to attribute name
*
- * Use: Writes a key file's data back to the actual file. This code
- * is extremely careful about error handling. It should usually
- * be able to back out somewhere sensible, but it can tell when
- * it's got itself into a real pickle and starts leaving well
- * alone.
+ * Returns: Pointer to attribute value, or null if not found.
*
- * Callers, please make sure that you ring alarm bells when this
- * function returns @KWRITE_BROKEN@.
+ * Use: Returns the value of a key attribute.
*/
-extern int key_write(key_file */*f*/);
+extern const char *key_getattr(key_file */*f*/, key */*k*/,
+ const char */*n*/);
-/* --- @key_open@ --- *
+/* --- @key_putattr@ --- *
*
- * Arguments: @key_file *f@ = pointer to file structure to initialize
- * @const char *file@ = pointer to the file name
- * @int how@ = opening options (@KOPEN_*@).
+ * Arguments: @key_file *f@ = pointer to file
+ * @key *k@ = pointer to key
+ * @const char *n@ = pointer to attribute name
+ * @const char *v@ = pointer to attribute value or null
*
- * Returns: Zero if it worked, nonzero otherwise.
+ * Returns: Error code (one of the @KERR@ constants).
*
- * Use: Opens a key file, reads its contents, and stores them in a
- * structure. The file is locked appropriately until closed
- * using @key_close@. On an error, everything is cleared away
- * tidily. If the file is opened with @KOPEN_WRITE@, it's
- * created if necessary, with read and write permissions for its
- * owner only.
+ * Use: Inserts an attribute on a key. If an attribute with the same
+ * name already exists, it is deleted. Setting a null value
+ * removes the attribute.
*/
-extern int key_open(key_file */*f*/, const char */*file*/, int /*how*/);
+extern int key_putattr(key_file */*f*/, key */*k*/,
+ const char */*n*/, const char */*v*/);
-/* --- @key_close@ --- *
+/* --- @key_mkattriter@ --- *
*
- * Arguments: @key_file *f@ = pointer to key file block
+ * Arguments: @key_attriter *i@ = pointer to attribute iterator
+ * @key *k@ = pointer to key
*
- * Returns: A @KWRITE_@ code indicating how it went.
+ * Returns: ---
*
- * Use: Frees all the key data, writes any changes. Make sure that
- * all hell breaks loose if this returns @KWRITE_BROKEN@.
+ * Use: Initializes an attribute iterator. The attributes are
+ * returned by @key_nextattr@.
*/
-extern int key_close(key_file */*f*/);
+extern void key_mkattriter(key_attriter */*i*/, key */*k*/);
-/* --- @key_new@ ---
+/* --- @key_nextattr@ --- *
*
- * Arguments: @key_file *f@ = pointer to key file
- * @const char *type@ = the type of this key
- * @const void *k@ = pointer to key data
- * @size_t ksz@ = size of key data
- * @time_t exp@ = when the key expires
- * @const char *c@ = textual comment to attach
+ * Arguments: @key_attriter *i@ = pointer to attribute iterator
+ * @const char **n, **v@ = pointers to name and value
*
- * Returns: Key block containing new data, or null if it couldn't be
- * done.
+ * Returns: Zero if no attribute available, or nonzero if returned OK.
*
- * Use: Attaches a new key to a key file. You must have a writable
- * key file for this to work.
+ * Use: Returns the next attribute.
+ */
+
+extern int key_nextattr(key_attriter */*i*/,
+ const char **/*n*/, const char **/*v*/);
+
+/*----- Searching and iterating -------------------------------------------*/
+
+/* --- @key_bytype@ --- *
*
- * The type is a key type string. This interface doesn't care
- * about how type strings are formatted: it just treats them as
- * opaque gobs of text. Clients are advised to choose some
- * standard for representing key types, though.
+ * Arguments: @key_file *f@ = key file we want a key from
+ * @const char *type@ = type string for desired key
*
- * The key can be any old binary mess.
+ * Returns: Pointer to the best key to use, or null.
*
- * The expiry time should either be a time in the future, or the
- * magic value @KEXP_FOREVER@ which means `never expire this
- * key'. Be careful with `forever' keys. If I were you, I'd
- * use a more sophisticated key management system than this for
- * them.
+ * Use: Looks up a key by its type. Returns the key with the latest
+ * expiry time. This function will not return an expired key.
+ */
+
+extern key *key_bytype(key_file */*f*/, const char */*type*/);
+
+/* --- @key_byid@ --- *
*
- * The comment can be any old text not containing newlines or
- * nulls. This interface doesn't impose any length restrictions
- * on comment lengths.
+ * Arguments: @key_file *f@ = key file to find a key from
+ * @uint32 id@ = id to look for
+ *
+ * Returns: Key with matching id.
+ *
+ * Use: Returns a key given its id. This function will return an
+ * expired key, but not a deleted one.
*/
-extern key *key_new(key_file */*f*/, const char */*type*/,
- const void */*k*/, size_t /*ksz*/,
- time_t /*exp*/, const char */*c*/);
+extern key *key_byid(key_file */*f*/, uint32 /*id*/);
-/* --- @key_delete@ --- *
+/* --- @key_bytag@ --- *
*
- * Arguments: @key_file *f@ = pointer to file block
- * @key *k@ = key to delete
+ * Arguments: @key_file *f@ = key file to find a key from
+ * @const char *tag@ = pointer to tag string
*
- * Returns: ---
+ * Returns: Key with matching id or tag.
*
- * Use: Removes the given key from the list. The key file must be
- * writable. (Due to the horridness of the data structures,
- * deleted keys aren't actually removed, just marked so that
- * they can't be looked up or iterated over. One upshot of
- * this is that they don't get written back to the file when
- * it's closed.)
+ * Use: Returns a key given its tag or id. This function will return
+ * an expired key, but not a deleted one.
*/
-extern void key_delete(key_file */*f*/, key */*k*/);
+extern key *key_bytag(key_file */*f*/, const char */*tag*/);
-/* --- @key_expire@ --- *
+/* --- @key_mkiter@ --- *
*
- * Arguments: @key_file *f@ = pointer to file block
- * @key *k@ = pointer to key block
+ * Arguments: @key_iter *i@ = pointer to iterator object
+ * @key_file *f@ = pointer to file structure
*
* Returns: ---
*
- * Use: Immediately marks the key as expired. It may be removed
- * immediately, if it is no longer required, and will be removed
- * by a tidy operation when it is no longer required. The key
- * file must be writable.
+ * Use: Initializes a key iterator. The keys are returned by
+ * @key_next@.
*/
-extern void key_expire(key_file */*f*/, key */*k*/);
+extern void key_mkiter(key_iter */*i*/, key_file */*f*/);
-/* --- @key_used@ --- *
+/* --- @key_next@ --- *
*
- * Arguments: @key_file *f@ = pointer to key file
- * @key *k@ = pointer to key block
- * @time_t t@ = when key can be removed
+ * Arguments: @key_iter *i@ = pointer to iterator object
*
- * Returns: Zero if OK, nonzero on failure.
+ * Returns: Pointer to next key, or null.
*
- * Use: Marks a key as being required until a given time. Even
- * though the key may expire before then (and won't be returned
- * by type after that time), it will still be available when
- * requested explicitly by id. The key file must be writable.
+ * Use: Returns the next key in some arbitrary sequence.
+ */
+
+extern key *key_next(key_iter */*i*/);
+
+/*----- Other functions ---------------------------------------------------*/
+
+/* --- @key_moan@ --- *
*
- * The only (current) reason for failure is attempting to use
- * a key which can expire for something which can't.
+ * Arguments: @const char *file@ = name of the file
+ * @int line@ = line number in file
+ * @const char *msg@ = error message
+ * @void *p@ = argument pointer
+ *
+ * Returns: ---
+ *
+ * Use: Reports an error message about loading a key file.
*/
-extern int key_used(key_file */*f*/, key */*k*/, time_t /*t*/);
+extern void key_moan(const char */*file*/, int /*line*/,
+ const char */*msg*/, void */*p*/);
+
+/* --- @key_strerror@ --- *
+ *
+ * Arguments: @int err@ = error code from @key_new@
+ *
+ * Returns: Pointer to error string.
+ *
+ * Use: Translates a @KERR@ error code into a human-readable string.
+ */
+
+extern const char *key_strerror(int /*err*/);
/*----- That's all, folks -------------------------------------------------*/