/* -*-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
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 {
*/
extern int key_write(key_data */*k*/, dstr */*d*/,
- const key_filter */*kf*/);
+ const key_filter */*kf*/);
/*----- Key binary encoding -----------------------------------------------*/
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@ --- *
*
* @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.
*/
* @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.
*/