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 |
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); |