Sun, 10 Nov 2024 09:12:30 +0100
toolkit update, small UI adjustments
55
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2024 Olaf Wintermann. All rights reserved. |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
1ce14068ef31
update libidav, unify config.c with cmdutils
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 |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #ifndef LIBIDAV_PWDSTORE_H |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #define LIBIDAV_PWDSTORE_H |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | #ifdef __cplusplus |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | extern "C" { |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #endif |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | #include <stdlib.h> |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | #include <inttypes.h> |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | #include <cx/map.h> |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | #include <cx/buffer.h> |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | #include <cx/linked_list.h> |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | #include "crypto.h" |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | #ifdef __cplusplus |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | extern "C" { |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | #endif |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | #define PWDSTORE_MAX_LEN 4096 |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | * File Format: |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | * file = header, index, enc_content |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | * header = magic, version, enc, pwfunc, salt, indexlen |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | * magic = 1 byte |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | * version = 1 byte |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | * enc = 1 byte |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | * pwfunc = 1 byte |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | * salt = 16 bytes |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
60 | * indexlen = uint32 |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | * index = { itype length id locations zero } |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | * enc_content = iv bytes |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | * iv = 16 bytes |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | * content = { entry } |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | * entry = itype length id length username length password |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | * length = uint32 |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | * zero = 4 zero bytes |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | * itype = 1 byte |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | * id = string |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | * locations = { length string } |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | * username = string |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | * password = string |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | * The content is AES encrypted with a key derived from a password |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | * and the salt. The first 16 bytes are the aes iv. |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | * |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | * All integers are big endian |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | #define PWDS_HEADER_SIZE 24 |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | typedef struct PwdStore PwdStore; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | typedef struct PwdEntry PwdEntry; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | typedef struct PwdIndexEntry PwdIndexEntry; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | struct PwdStore { |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | * map of all credentials |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | * key is the username |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | * value is PwdEntry* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | CxMap *ids; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
94 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | * list of all credentials with location |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | * value is PwdIndexEntry* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
98 | CxList *locations; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | * list of all credentials without location |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | * value is PwdIndexEntry* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | CxList *noloc; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | * index map that contains all elements from the lists |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | * 'locations' and 'noloc' |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | CxMap *index; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
111 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | * a buffer containing the complete file content |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | CxBuffer *content; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | * key used for encryption/decryption |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | DavKey *key; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | * optional shell command, that is used for getting the master password |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | char *unlock_cmd; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | * optional shell command, that is exected when the secretstore is closed |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | char *lock_cmd; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | * start offset of the encrypted buffer |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | uint32_t encoffset; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | * indicates if the PwdStore is decrypted with pwdstore_decrypt |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | uint8_t isdecrypted; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | }; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | #define PWDS_MAGIC(p) (p)->content->space[0] |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | #define PWDS_VERSION(p) (p)->content->space[1] |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | #define PWDS_ENC(p) (p)->content->space[2] |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | #define PWDS_PWFUNC(p) (p)->content->space[3] |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | #define PWDS_MAGIC_CHAR 'P' |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | struct PwdEntry { |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | char *id; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | char *user; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | char *password; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | }; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | struct PwdIndexEntry { |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
157 | char *id; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | CxList *locations; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | }; |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
161 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | * opens the password store |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | * the content is still encrypted and must be decrypted using pwdstore_decrypt |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | PwdStore* pwdstore_open(const char *file); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
166 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
167 | PwdStore* pwdstore_new(void); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
168 | |
65
48f43130b4a2
implement UI for credentials settings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
169 | PwdStore* pwdstore_clone(PwdStore *p); |
48f43130b4a2
implement UI for credentials settings
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
55
diff
changeset
|
170 | |
55
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | /* |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
172 | * decrypts the password store with the previously set password |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
173 | */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | int pwdstore_decrypt(PwdStore *p); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | int pwdstore_setpassword(PwdStore *p, const char *password); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
177 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | void pwdstore_encsettings(PwdStore *p, uint8_t enc, uint8_t pwfunc); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
180 | void pwdstore_free_entry(PwdEntry *e); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
181 | void pwdstore_free(PwdStore* p); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
182 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | int pwdstore_has_id(PwdStore *s, const char *id); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | int pwdstore_has_location(PwdStore *s, const char *location); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | PwdEntry* pwdstore_get(PwdStore *p, const char *id); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | void pwdstore_put(PwdStore *p, const char *id, const char *username, const char *password); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | void pwdstore_put_index(PwdStore *p, char *id, CxList *locations); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
190 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
191 | void pwdstore_remove_entry(PwdStore *s, const char *id); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
192 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | int pwdstore_store(PwdStore *p, const char *file); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | int pwdstore_decrypt_secrets(PwdStore *secrets); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
197 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
201 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
202 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | typedef char*(*pwdstore_pwinput_func)(void *userdata); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
205 | void pwdstore_set_pwinput_func(pwdstore_pwinput_func func, void *userdata); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
206 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
207 | char * pwdstore_default_pwinput(char *prompt); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
210 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
211 | /* private */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
212 | int pwdstore_getindex(PwdStore *s); |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | #ifdef __cplusplus |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | } |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
216 | #endif |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | #endif /* LIBIDAV_PWDSTORE_H */ |
1ce14068ef31
update libidav, unify config.c with cmdutils
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 |