dav/pwd.h

Sat, 19 Oct 2019 10:47:46 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 19 Oct 2019 10:47:46 +0200
changeset 661
1baec7ff8931
parent 654
8f2b8f2a5cde
child 731
e0358fa1a3b1
permissions
-rw-r--r--

add first metadata sync test

470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2018 Olaf Wintermann. All rights reserved.
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #ifndef PWD_H
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define PWD_H
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include <stdlib.h>
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include <inttypes.h>
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 #include <ucx/map.h>
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include <ucx/buffer.h>
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include <libidav/crypto.h>
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 #ifdef __cplusplus
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 extern "C" {
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #endif
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
43 #define PWDSTORE_MAX_LEN 4096
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 /*
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 * File Format:
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 *
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
48 * file = header, index, enc_content
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
49 * header = magic, version, enc, pwfunc, salt, indexlen
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 * magic = 1 byte
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 * version = 1 byte
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 * enc = 1 byte
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 * pwfunc = 1 byte
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 * salt = 16 bytes
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
55 * indexlen = uint32
653
f503c272bd70 update secret store format description
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
56 * index = { itype length id locations zero }
f503c272bd70 update secret store format description
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
57 * enc_content = iv bytes
f503c272bd70 update secret store format description
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
58 * iv = 16 bytes
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 * content = { entry }
653
f503c272bd70 update secret store format description
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
60 * entry = itype length id length username length password
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
61 * length = uint32
489
fb69eae42ef0 credentials can have multiple locations now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
62 * zero = 4 zero bytes
653
f503c272bd70 update secret store format description
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 489
diff changeset
63 * itype = 1 byte
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
64 * id = string
489
fb69eae42ef0 credentials can have multiple locations now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
65 * locations = { length string }
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 * username = string
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 * password = string
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 * The content is AES encrypted with a key derived from a password
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 * and the salt. The first 16 bytes are the aes iv.
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 *
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 * All integers are big endian
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
75 #define PWDS_HEADER_SIZE 24
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
77 typedef struct PwdStore PwdStore;
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
78 typedef struct PwdEntry PwdEntry;
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
79 typedef struct PwdIndexEntry PwdIndexEntry;
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 struct PwdStore {
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 /*
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
83 * map of all credentials
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 * key is the username
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 * value is PwdEntry*
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 */
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
87 UcxMap *ids;
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
88
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
89 /*
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
90 * list of all credentials with location
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
91 * value is PwdIndexEntry*
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
92 */
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
93 UcxList *locations;
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95 /*
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
96 * list of all credentials without location
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
97 * value is PwdIndexEntry*
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
98 */
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
99 UcxList *noloc;
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
100
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
101 /*
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
102 * index map that contains all elements from the lists
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
103 * 'locations' and 'noloc'
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
104 */
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
105 UcxMap *index;
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
106
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
107 /*
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 * a buffer containing the complete file content
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 UcxBuffer *content;
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 /*
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113 * key used for encryption/decryption
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 DavKey *key;
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 /*
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
118 * start offset of the encrypted buffer
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
119 */
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
120 uint32_t encoffset;
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
121
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
122 /*
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 * indicates if the PwdStore is decrypted with pwdstore_decrypt
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 uint8_t isdecrypted;
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 };
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 #define PWDS_MAGIC(p) (p)->content->space[0]
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129 #define PWDS_VERSION(p) (p)->content->space[1]
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 #define PWDS_ENC(p) (p)->content->space[2]
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 #define PWDS_PWFUNC(p) (p)->content->space[3]
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133 #define PWDS_MAGIC_CHAR 'P'
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 struct PwdEntry {
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
136 char *id;
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 char *user;
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 char *password;
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 };
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
141 struct PwdIndexEntry {
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
142 char *id;
489
fb69eae42ef0 credentials can have multiple locations now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
143 UcxList *locations;
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
144 };
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
145
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 /*
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 * opens the password store
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148 * the content is still encrypted and must be decrypted using pwdstore_decrypt
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 PwdStore* pwdstore_open(const char *file);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 PwdStore* pwdstore_new(void);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 /*
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 * decrypts the password store with a password
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156 */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 int pwdstore_decrypt(PwdStore *p);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 int pwdstore_setpassword(PwdStore *p, const char *password);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 void pwdstore_encsettings(PwdStore *p, uint8_t enc, uint8_t pwfunc);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162
473
6740adb5fccd adds support for location credentials
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 472
diff changeset
163 void pwdstore_free_entry(PwdEntry *e);
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 void pwdstore_free(PwdStore* p);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
166 int pwdstore_has_id(PwdStore *s, const char *id);
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
167 int pwdstore_has_location(PwdStore *s, const char *location);
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
169 PwdEntry* pwdstore_get(PwdStore *p, const char *id);
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
170
474
017a4f09e6fa improves secret store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 473
diff changeset
171 void pwdstore_put(PwdStore *p, const char *id, const char *username, const char *password);
489
fb69eae42ef0 credentials can have multiple locations now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 474
diff changeset
172 void pwdstore_put_index(PwdStore *p, char *id, UcxList *locations);
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173
654
8f2b8f2a5cde add remove-user and list-users commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 653
diff changeset
174 void pwdstore_remove_entry(PwdStore *s, const char *id);
8f2b8f2a5cde add remove-user and list-users commands
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 653
diff changeset
175
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 int pwdstore_store(PwdStore *p, const char *file);
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177
472
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
178 /* private */
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
179 int pwdstore_getindex(PwdStore *s);
08d2d1263429 new secrets store file format
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 470
diff changeset
180
470
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 #ifdef __cplusplus
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 }
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 #endif
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 #endif /* PWD_H */
6bf798ad3aec adds encrypted password store
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186

mercurial