]> wimlib.net Git - wimlib/blob - include/wimlib/security.h
09d602d471bc23b21a59bfad4da2bf3bff6efa9b
[wimlib] / include / wimlib / security.h
1 #ifndef _WIMLIB_SECURITY_H
2 #define _WIMLIB_SECURITY_H
3
4 #include "wimlib/rbtree.h"
5 #include "wimlib/types.h"
6
7 /* Red-black tree that maps SHA1 message digests of security descriptors to
8  * security IDs, which are themselves indices into the table of security
9  * descriptors in the 'struct wim_security_data'. */
10 struct wim_sd_set {
11         struct wim_security_data *sd;
12         struct rb_root rb_root;
13         int32_t orig_num_entries;
14 };
15
16 /* Table of security descriptors for a WIM image. */
17 struct wim_security_data {
18         /* The total length of the security data, in bytes.  If there are no
19          * security descriptors, this field, when read from the on-disk metadata
20          * resource, may be either 8 (which is correct) or 0 (which is
21          * interpreted as 0). */
22         u32 total_length;
23
24         /* The number of security descriptors in the array @descriptors, below.
25          * It is really an unsigned int on-disk, but it must fit into an int
26          * because the security ID's are signed.  (Not like you would ever have
27          * more than a few hundred security descriptors anyway.) */
28         int32_t num_entries;
29
30         /* Array of sizes of the descriptors in the array @descriptors. */
31         u64 *sizes;
32
33         /* Array of descriptors. */
34         u8 **descriptors;
35 };
36
37 extern void
38 destroy_sd_set(struct wim_sd_set *sd_set, bool rollback);
39
40 extern int
41 lookup_sd(struct wim_sd_set *set, const u8 hash[]);
42
43 extern int
44 sd_set_add_sd(struct wim_sd_set *sd_set, const char descriptor[],
45               size_t size);
46
47 extern int
48 init_sd_set(struct wim_sd_set *sd_set, struct wim_security_data *sd);
49
50 extern struct wim_security_data *
51 new_wim_security_data(void);
52
53 extern int
54 read_security_data(const u8 metadata_resource[],
55                    u64 metadata_resource_len, struct wim_security_data **sd_p);
56 extern void
57 print_security_data(const struct wim_security_data *sd);
58
59 extern u8 *
60 write_security_data(const struct wim_security_data * restrict sd,
61                     u8 * restrict p);
62
63 extern void
64 free_security_data(struct wim_security_data *sd);
65
66 #endif /* _WIMLIB_SECURITY_H */