dav/pwd.h

changeset 474
017a4f09e6fa
parent 473
6740adb5fccd
child 489
fb69eae42ef0
equal deleted inserted replaced
473:6740adb5fccd 474:017a4f09e6fa
43 #define PWDSTORE_MAX_LEN 4096 43 #define PWDSTORE_MAX_LEN 4096
44 44
45 /* 45 /*
46 * File Format: 46 * File Format:
47 * 47 *
48 * file = header, enc_content 48 * file = header, index, enc_content
49 * header = magic, version, enc, pwfunc, salt, indexlen 49 * header = magic, version, enc, pwfunc, salt, indexlen
50 * magic = 1 byte 50 * magic = 1 byte
51 * version = 1 byte 51 * version = 1 byte
52 * enc = 1 byte 52 * enc = 1 byte
53 * pwfunc = 1 byte 53 * pwfunc = 1 byte
54 * salt = 16 bytes 54 * salt = 16 bytes
55 * indexlen = uint32 55 * indexlen = uint32
56 * index = { length id length location }
56 * content = { entry } 57 * content = { entry }
57 * entry = length id length location length username length password 58 * entry = length id length username length password
58 * length = uint32 59 * length = uint32
59 * id = string 60 * id = string
60 * location = string 61 * location = string
61 * username = string 62 * username = string
62 * password = string 63 * password = string
67 * All integers are big endian 68 * All integers are big endian
68 */ 69 */
69 70
70 #define PWDS_HEADER_SIZE 24 71 #define PWDS_HEADER_SIZE 24
71 72
72 typedef struct PwdStore PwdStore; 73 typedef struct PwdStore PwdStore;
73 typedef struct PwdEntry PwdEntry; 74 typedef struct PwdEntry PwdEntry;
75 typedef struct PwdIndexEntry PwdIndexEntry;
74 76
75 struct PwdStore { 77 struct PwdStore {
76 /* 78 /*
77 * map of all credentials 79 * map of all credentials
78 * key is the username 80 * key is the username
80 */ 82 */
81 UcxMap *ids; 83 UcxMap *ids;
82 84
83 /* 85 /*
84 * list of all credentials with location 86 * list of all credentials with location
85 * value is PwdEntry* 87 * value is PwdIndexEntry*
86 */ 88 */
87 UcxList *locations; 89 UcxList *locations;
90
91 /*
92 * list of all credentials without location
93 * value is PwdIndexEntry*
94 */
95 UcxList *noloc;
96
97 /*
98 * index map that contains all elements from the lists
99 * 'locations' and 'noloc'
100 */
101 UcxMap *index;
88 102
89 /* 103 /*
90 * a buffer containing the complete file content 104 * a buffer containing the complete file content
91 */ 105 */
92 UcxBuffer *content; 106 UcxBuffer *content;
114 128
115 #define PWDS_MAGIC_CHAR 'P' 129 #define PWDS_MAGIC_CHAR 'P'
116 130
117 struct PwdEntry { 131 struct PwdEntry {
118 char *id; 132 char *id;
119 char *location;
120 char *user; 133 char *user;
121 char *password; 134 char *password;
135 };
136
137 struct PwdIndexEntry {
138 char *id;
139 char *location;
122 }; 140 };
123 141
124 /* 142 /*
125 * opens the password store 143 * opens the password store
126 * the content is still encrypted and must be decrypted using pwdstore_decrypt 144 * the content is still encrypted and must be decrypted using pwdstore_decrypt
144 int pwdstore_has_id(PwdStore *s, const char *id); 162 int pwdstore_has_id(PwdStore *s, const char *id);
145 int pwdstore_has_location(PwdStore *s, const char *location); 163 int pwdstore_has_location(PwdStore *s, const char *location);
146 164
147 PwdEntry* pwdstore_get(PwdStore *p, const char *id); 165 PwdEntry* pwdstore_get(PwdStore *p, const char *id);
148 166
149 void pwdstore_put(PwdStore *p, const char *id, const char *location, const char *username, const char *password); 167 void pwdstore_put(PwdStore *p, const char *id, const char *username, const char *password);
168 void pwdstore_put_index(PwdStore *p, const char *id, const char *location);
150 169
151 int pwdstore_store(PwdStore *p, const char *file); 170 int pwdstore_store(PwdStore *p, const char *file);
152 171
153 /* private */ 172 /* private */
154 int pwdstore_getindex(PwdStore *s); 173 int pwdstore_getindex(PwdStore *s);

mercurial