Add the key packing interface.
authormdw <mdw>
Sat, 17 Jun 2000 11:26:18 +0000 (11:26 +0000)
committermdw <mdw>
Sat, 17 Jun 2000 11:26:18 +0000 (11:26 +0000)
key-data.h

index 6cf2439..4ee99aa 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: key-data.h,v 1.1 2000/02/12 18:21:23 mdw Exp $
+ * $Id: key-data.h,v 1.2 2000/06/17 11:26:18 mdw Exp $
  *
  * Manipulating key data
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: key-data.h,v $
+ * Revision 1.2  2000/06/17 11:26:18  mdw
+ * Add the key packing interface.
+ *
  * Revision 1.1  2000/02/12 18:21:23  mdw
  * Overhaul of key management (again).
  *
@@ -79,6 +82,18 @@ typedef struct key_struct {
   key_data k;
 } key_struct;
 
+/* --- Packing and unpacking --- */
+
+typedef struct key_packdef {
+  void *p;                             /* Pointer to the destination */
+  key_data kd;                         /* Key data block */
+} key_packdef;
+
+typedef struct key_packstruct {
+  char *name;                          /* Pointer to name string */
+  key_packdef kp;                      /* Packing structure */
+} key_packstruct;
+
 /* --- Key binary encoding --- *
  *
  * The binary encoding consists of a header containing a 16-bit encoding type
@@ -122,6 +137,7 @@ enum {
 
   KF_BURN      = 0x10,                 /* Burn key after use */
   KF_TEMP      = 0x20,                 /* Temporary copy flag */
+  KF_OPT       = 0x40,                 /* Optional key (for @key_unpack@) */
 
   /* --- Tag end --- */
 
@@ -361,6 +377,46 @@ extern int key_decode(const void */*p*/, size_t /*sz*/, key_data */*k*/);
 extern int key_encode(key_data */*k*/, dstr */*d*/,
                      const key_filter */*kf*/);
 
+/*----- Packing and unpacking keys ----------------------------------------*/
+
+/* --- @key_pack@ --- *
+ *
+ * Arguments:  @key_packdef *kp@ = pointer to packing structure
+ *             @key_data *kd@ = pointer to destination key data
+ *             @dstr *d@ = pointer to tag string for the key data
+ *
+ * Returns:    Error code, or zero.
+ *
+ * Use:                Packs a key from a data structure.
+ */
+
+extern int key_pack(key_packdef */*kp*/, key_data */*kd*/, dstr */*d*/);
+
+/* --- @key_unpack@ --- *
+ *
+ * Arguments:  @key_packdef *kp@ = pointer to packing structure
+ *             @key_data *kd@ = pointer to source key data
+ *             @dstr *d@ = pointer to tag string for the key data
+ *
+ * Returns:    Error code, or zero.
+ *
+ * Use:                Unpacks a key into an appropriate data structure.
+ */
+
+extern int key_unpack(key_packdef */*kp*/, key_data */*kd*/, dstr */*d*/);
+
+/* --- @key_unpackdone@ --- *
+ *
+ * Arguments:  @key_packdef *kp@ = pointer to packing definition
+ *
+ * Returns:    ---
+ *
+ * Use:                Frees the key components contained within a packing
+ *             definition, created during key unpacking.
+ */
+
+extern void key_unpackdone(key_packdef */*kp*/);
+
 /*----- Passphrase encryption ---------------------------------------------*/
 
 /* --- @key_plock@ --- *