Uprating of the passphrase pixie.
[u/mdw/catacomb] / key-data.h
index 40b8b4b..5644834 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: key-data.h,v 1.4 2004/04/08 01:36:15 mdw Exp $
+ * $Id$
  *
  * Manipulating key data
  *
 #include <mLib/dstr.h>
 #include <mLib/sym.h>
 
+#ifndef CATACOMB_KEY_ERROR_H
+#  include "key-error.h"
+#endif
+
 #ifndef CATACOMB_MP_H
 #  include "mp.h"
 #endif
@@ -141,6 +145,13 @@ enum {
   KENC_MAX                             /* Dummy limit constant */
 };
 
+/* --- Key locking return codes --- */
+
+#define KL_OK 0                                /* All good */
+#define KL_IOERR -1                    /* I/O problem (e.g., getting pp) */
+#define KL_KEYERR -2                   /* Wrong key supplied */
+#define KL_DATAERR -3                  /* Data format error */
+
 /* --- Key flag filtering --- */
 
 typedef struct key_filter {
@@ -367,7 +378,7 @@ extern int key_read(const char */*p*/, key_data */*k*/, char **/*pp*/);
  */
 
 extern int key_write(key_data */*k*/, dstr */*d*/,
-                     const key_filter */*kf*/);
+                    const key_filter */*kf*/);
 
 /*----- Key binary encoding -----------------------------------------------*/
 
@@ -438,7 +449,37 @@ extern int key_unpack(key_packdef */*kp*/, key_data */*kd*/, dstr */*d*/);
 
 extern void key_unpackdone(key_packdef */*kp*/);
 
-/*----- Passphrase encryption ---------------------------------------------*/
+/*----- Key encryption ----------------------------------------------------*/
+
+/* --- @key_lock@ --- *
+ *
+ * Arguments:  @key_data *kt@ = destination block
+ *             @key_data *k@ = source key data block
+ *             @const void *e@ = secret to encrypt key with
+ *             @size_t esz@ = size of the secret
+ *
+ * Returns:    ---
+ *
+ * Use:                Encrypts a key data block using a secret.
+ */
+
+extern void key_lock(key_data */*kt*/, key_data */*k*/,
+                    const void */*e*/, size_t /*esz*/);
+
+/* --- @key_unlock@ --- *
+ *
+ * Arguments:  @key_data *kt@ = target block
+ *             @key_data *k@ = source key data block
+ *             @const void *e@ = secret to decrypt the block with
+ *             @size_t esz@ = size of the secret
+ *
+ * Returns:    Zero for success, or a @KERR_@ error code.
+ *
+ * Use:                Unlocks a key using a secret.
+ */
+
+extern int key_unlock(key_data */*kt*/, key_data */*k*/,
+                     const void */*e*/, size_t /*esz*/);
 
 /* --- @key_plock@ --- *
  *
@@ -446,7 +487,7 @@ extern void key_unpackdone(key_packdef */*kp*/);
  *             @key_data *k@ = source key data block
  *             @key_data *kt@ = target key data block
  *
- * Returns:    Zero if successful, nonzero if there was a problem.
+ * Returns:    Zero if successful, a @KERR@ error code on failure.
  *
  * Use:                Locks a key by encrypting it with a passphrase.
  */
@@ -459,7 +500,7 @@ extern int key_plock(const char */*tag*/, key_data */*k*/, key_data */*kt*/);
  *             @key_data *k@ = source key data block
  *             @key_data *kt@ = target key data block
  *
- * Returns:    Zero if it worked, nonzero if it didn't.
+ * Returns:    Zero if successful, a @KERR@ error code on failure.
  *
  * Use:                Unlocks a passphrase-locked key.
  */