14
14
15
15
#include <stddef.h>
16
16
17
+ #include "libos_checkpoint.h" // ofr include of uthash.h _and_ consistent uthash_fatal macros
17
18
#include "libos_types.h"
18
19
#include "list.h"
19
20
#include "pal.h"
@@ -34,6 +35,40 @@ struct libos_encrypted_files_key {
34
35
LIST_TYPE (libos_encrypted_files_key ) list ;
35
36
};
36
37
38
+ typedef enum {
39
+ PF_FILE_IN_USE_NEW = 0 , // file is currently in-use but did not exist at open time
40
+ PF_FILE_IN_USE_EXISTING = 1 , // file is currently in-use and existed at open time
41
+ PF_FILE_CLOSED = 2 , // file was provisously seend with known (good committed) state
42
+ PF_FILE_DELETED = 3 , // the old path of renames is also considered deleted
43
+ PF_FILE_ERROR = 4 , // file is in non-determined state due to some errors
44
+ } libos_encrypted_file_state_t ;
45
+
46
+ /*
47
+ * Map mapping file URIs to state providing information on files, in particular whether we have seen
48
+ * them before and what the last seen root-hash is. This is necessary to provide rollback
49
+ */
50
+ struct libos_encrypted_volume_state_map {
51
+ char * uri ; // assumptions: all paths canonicalized, symlinks are resolved & no hard links
52
+ libos_encrypted_file_state_t state ;
53
+ pf_mac_t last_seen_root_gmac ;
54
+ UT_hash_handle hh ;
55
+ };
56
+
57
+ typedef enum {
58
+ PF_ENCLAVE_LIFE_RB_PROTECTION_NONE = 0 ,
59
+ PF_ENCLAVE_LIFE_RB_PROTECTION_NON_STRICT = 1 ,
60
+ PF_ENCLAVE_LIFE_RB_PROTECTION_STRICT = 2 ,
61
+ } libos_encrypted_files_mode_t ;
62
+
63
+ struct libos_encrypted_volume {
64
+ libos_encrypted_files_mode_t protection_mode ;
65
+
66
+ struct libos_encrypted_volume_state_map * files_state_map ;
67
+ struct libos_lock files_state_map_lock ;
68
+
69
+ struct libos_encrypted_files_key * key ;
70
+ };
71
+
37
72
/*
38
73
* Represents a specific encrypted file. The file is open as long as `use_count` is greater than 0.
39
74
* Note that the file can be open and closed multiple times before it's destroyed.
@@ -44,7 +79,7 @@ struct libos_encrypted_files_key {
44
79
struct libos_encrypted_file {
45
80
size_t use_count ;
46
81
char * uri ;
47
- struct libos_encrypted_files_key * key ;
82
+ struct libos_encrypted_volume * volume ;
48
83
49
84
/* `pf` and `pal_handle` are non-null as long as `use_count` is greater than 0 */
50
85
pf_context_t * pf ;
@@ -110,29 +145,29 @@ void update_encrypted_files_key(struct libos_encrypted_files_key* key, const pf_
110
145
* \brief Open an existing encrypted file.
111
146
*
112
147
* \param uri PAL URI to open, has to begin with "file:".
113
- * \param key Key , has to be already set.
148
+ * \param volume Volume assocated with file , has to be already set.
114
149
* \param[out] out_enc On success, set to a newly created `libos_encrypted_file` object.
115
150
*
116
151
* `uri` has to correspond to an existing file that can be decrypted with `key`.
117
152
*
118
153
* The newly created `libos_encrypted_file` object will have `use_count` set to 1.
119
154
*/
120
- int encrypted_file_open (const char * uri , struct libos_encrypted_files_key * key ,
155
+ int encrypted_file_open (const char * uri , struct libos_encrypted_volume * volume ,
121
156
struct libos_encrypted_file * * out_enc );
122
157
123
158
/*
124
159
* \brief Create a new encrypted file.
125
160
*
126
161
* \param uri PAL URI to open, has to begin with "file:".
127
162
* \param perm Permissions for the new file.
128
- * \param key Key , has to be already set.
163
+ * \param volume Volume assocated with file , has to be already set.
129
164
* \param[out] out_enc On success, set to a newly created `libos_encrypted_file` object.
130
165
*
131
166
* `uri` must not correspond to an existing file.
132
167
*
133
168
* The newly created `libos_encrypted_file` object will have `use_count` set to 1.
134
169
*/
135
- int encrypted_file_create (const char * uri , mode_t perm , struct libos_encrypted_files_key * key ,
170
+ int encrypted_file_create (const char * uri , mode_t perm , struct libos_encrypted_volume * volume ,
136
171
struct libos_encrypted_file * * out_enc );
137
172
138
173
/*
0 commit comments