]> wimlib.net Git - wimlib/blob - include/wimlib/security.h
8043d7d2c8e87534ed1e546928359b214dd2f53b
[wimlib] / include / wimlib / security.h
1 #ifndef _WIMLIB_SECURITY_H
2 #define _WIMLIB_SECURITY_H
3
4 #include "wimlib/types.h"
5
6 struct wim_security_data;
7 struct avl_tree_node;
8
9 /* Map from SHA1 message digests of security descriptors to security IDs, which
10  * are themselves indices into the table of security descriptors in the 'struct
11  * wim_security_data'. */
12 struct wim_sd_set {
13         struct wim_security_data *sd;
14         struct avl_tree_node *root;
15         int32_t orig_num_entries;
16 };
17
18 /* Table of security descriptors for a WIM image. */
19 struct wim_security_data {
20         /* The total length of the security data, in bytes.  If there are no
21          * security descriptors, this field, when read from the on-disk metadata
22          * resource, may be either 8 (which is correct) or 0 (which is
23          * interpreted as 8). */
24         u32 total_length;
25
26         /* The number of security descriptors in the array @descriptors. */
27         u32 num_entries;
28
29         /* Array of sizes of the descriptors, in bytes, in the array
30          * @descriptors. */
31         u64 *sizes;
32
33         /* Array of pointers to the security descriptors in the
34          * SECURITY_DESCRIPTOR_RELATIVE format. */
35         u8 **descriptors;
36 };
37
38 extern void
39 destroy_sd_set(struct wim_sd_set *sd_set, bool rollback);
40
41 extern int
42 sd_set_add_sd(struct wim_sd_set *sd_set, const char descriptor[],
43               size_t size);
44
45 extern int
46 init_sd_set(struct wim_sd_set *sd_set, struct wim_security_data *sd);
47
48 extern struct wim_security_data *
49 new_wim_security_data(void);
50
51 extern int
52 read_wim_security_data(const u8 metadata_resource[], size_t
53                        metadata_resource_len, struct wim_security_data **sd_p);
54
55 extern u8 *
56 write_wim_security_data(const struct wim_security_data * restrict sd, u8 *
57                         restrict p);
58
59 extern void
60 print_wim_security_data(const struct wim_security_data *sd);
61
62 extern void
63 free_wim_security_data(struct wim_security_data *sd);
64
65 #endif /* _WIMLIB_SECURITY_H */