dav/pwd.h

changeset 474
017a4f09e6fa
parent 473
6740adb5fccd
child 489
fb69eae42ef0
--- a/dav/pwd.h	Thu Sep 20 17:14:55 2018 +0200
+++ b/dav/pwd.h	Sun Sep 23 08:13:50 2018 +0200
@@ -45,7 +45,7 @@
 /*
  * File Format:
  * 
- * file = header, enc_content
+ * file = header, index, enc_content
  * header = magic, version, enc, pwfunc, salt, indexlen
  * magic = 1 byte
  * version = 1 byte
@@ -53,8 +53,9 @@
  * pwfunc = 1 byte
  * salt = 16 bytes
  * indexlen = uint32
+ * index = { length id length location }
  * content = { entry }
- * entry = length id length location length username length password
+ * entry = length id length username length password
  * length = uint32
  * id = string
  * location = string
@@ -69,8 +70,9 @@
     
 #define PWDS_HEADER_SIZE 24
     
-typedef struct PwdStore PwdStore;
-typedef struct PwdEntry PwdEntry;
+typedef struct PwdStore        PwdStore;
+typedef struct PwdEntry        PwdEntry;
+typedef struct PwdIndexEntry   PwdIndexEntry;
 
 struct PwdStore {
     /*
@@ -82,11 +84,23 @@
     
     /*
      * list of all credentials with location
-     * value is PwdEntry*
+     * value is PwdIndexEntry*
      */
     UcxList *locations;
     
     /*
+     * list of all credentials without location
+     * value is PwdIndexEntry*
+     */
+    UcxList *noloc;
+    
+    /*
+     * index map that contains all elements from the lists
+     * 'locations' and 'noloc'
+     */
+    UcxMap *index;
+    
+    /*
      * a buffer containing the complete file content
      */
     UcxBuffer *content;
@@ -116,11 +130,15 @@
 
 struct PwdEntry {
     char *id;
-    char *location;
     char *user;
     char *password;
 };
 
+struct PwdIndexEntry {
+    char *id;
+    char *location;
+};
+
 /*
  * opens the password store
  * the content is still encrypted and must be decrypted using pwdstore_decrypt
@@ -146,7 +164,8 @@
 
 PwdEntry* pwdstore_get(PwdStore *p, const char *id);
 
-void pwdstore_put(PwdStore *p, const char *id, const char *location, const char *username, const char *password);
+void pwdstore_put(PwdStore *p, const char *id, const char *username, const char *password);
+void pwdstore_put_index(PwdStore *p, const char *id, const char *location);
 
 int pwdstore_store(PwdStore *p, const char *file);
 

mercurial