/* -*-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
*
/*----- 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).
*
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
KF_BURN = 0x10, /* Burn key after use */
KF_TEMP = 0x20, /* Temporary copy flag */
+ KF_OPT = 0x40, /* Optional key (for @key_unpack@) */
/* --- Tag end --- */
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@ --- *