]> git.saurik.com Git - apple/security.git/blob - OSX/authd/authitems.h
Security-58286.1.32.tar.gz
[apple/security.git] / OSX / authd / authitems.h
1 /* Copyright (c) 2012 Apple Inc. All Rights Reserved. */
2
3 #ifndef _SECURITY_AUTH_ITEMS_H_
4 #define _SECURITY_AUTH_ITEMS_H_
5
6 #include <Security/Authorization.h>
7 #include <xpc/xpc.h>
8
9 #if defined(__cplusplus)
10 extern "C" {
11 #endif
12
13 enum {
14 AI_TYPE_UNKNOWN = 0,
15 AI_TYPE_RIGHT,
16 AI_TYPE_STRING,
17 AI_TYPE_INT,
18 AI_TYPE_UINT,
19 AI_TYPE_INT64,
20 AI_TYPE_UINT64,
21 AI_TYPE_DOUBLE,
22 AI_TYPE_BOOL,
23 AI_TYPE_DATA
24 };
25
26 #pragma mark -
27 #pragma mark auth_items_t
28
29 /* unordered items */
30
31 #ifdef __BLOCKS__
32 typedef bool (^auth_items_iterator_t)(const char *key);
33 #endif /* __BLOCKS__ */
34
35 CFTypeID auth_items_get_type_id(void);
36
37 AUTH_WARN_RESULT AUTH_MALLOC AUTH_RETURNS_RETAINED
38 auth_items_t auth_items_create(void);
39
40 AUTH_WARN_RESULT AUTH_MALLOC AUTH_NONNULL_ALL AUTH_RETURNS_RETAINED
41 auth_items_t auth_items_create_with_xpc(const xpc_object_t data);
42
43 AUTH_WARN_RESULT AUTH_MALLOC AUTH_NONNULL_ALL AUTH_RETURNS_RETAINED
44 auth_items_t auth_items_create_copy(auth_items_t);
45
46 AUTH_WARN_RESULT AUTH_NONNULL_ALL
47 size_t auth_items_get_count(auth_items_t);
48
49 AUTH_WARN_RESULT AUTH_NONNULL_ALL
50 AuthorizationItemSet * auth_items_get_item_set(auth_items_t);
51
52 AUTH_WARN_RESULT AUTH_NONNULL_ALL
53 xpc_object_t auth_items_export_xpc(auth_items_t);
54
55 AUTH_NONNULL_ALL
56 void auth_items_set_flags(auth_items_t, const char *key, uint32_t flags);
57
58 AUTH_NONNULL_ALL
59 void auth_items_clear_flags(auth_items_t, const char *key, uint32_t flags);
60
61 AUTH_WARN_RESULT AUTH_NONNULL_ALL
62 uint32_t auth_items_get_flags(auth_items_t, const char *key);
63
64 AUTH_NONNULL_ALL
65 bool auth_items_check_flags(auth_items_t, const char *key, uint32_t flags);
66
67 AUTH_NONNULL_ALL
68 void auth_items_set_key(auth_items_t, const char *key);
69
70 AUTH_NONNULL_ALL
71 bool auth_items_exist(auth_items_t, const char *key);
72
73 AUTH_NONNULL_ALL
74 void auth_items_remove(auth_items_t, const char *key);
75
76 AUTH_NONNULL_ALL
77 void auth_items_remove_with_flags(auth_items_t, uint32_t flags);
78
79 AUTH_NONNULL_ALL
80 void auth_items_clear(auth_items_t);
81
82 AUTH_NONNULL_ALL
83 void auth_items_copy(auth_items_t, auth_items_t src);
84
85 AUTH_NONNULL_ALL
86 void auth_items_content_copy(auth_items_t items, auth_items_t src);
87
88 AUTH_NONNULL_ALL
89 void auth_items_copy_xpc(auth_items_t, const xpc_object_t src);
90
91 AUTH_NONNULL_ALL
92 void auth_items_copy_with_flags(auth_items_t, auth_items_t src, uint32_t flags);
93
94 AUTH_NONNULL_ALL
95 void auth_items_content_copy_with_flags(auth_items_t items, auth_items_t src, uint32_t flags);
96
97 AUTH_NONNULL_ALL
98 bool auth_items_iterate(auth_items_t, auth_items_iterator_t iter);
99
100 AUTH_NONNULL_ALL
101 void auth_items_set_string(auth_items_t, const char *key, const char *value);
102
103 AUTH_WARN_RESULT AUTH_NONNULL_ALL
104 const char * auth_items_get_string(auth_items_t, const char *key);
105
106 AUTH_NONNULL_ALL
107 void auth_items_set_data(auth_items_t, const char *key, const void *value, size_t len);
108
109 AUTH_WARN_RESULT AUTH_NONNULL_ALL
110 const void * auth_items_get_data(auth_items_t, const char *key, size_t * len);
111
112 AUTH_WARN_RESULT AUTH_NONNULL_ALL
113 const void * auth_items_get_data_with_flags(auth_items_t items, const char *key, size_t *len, uint32_t flags);
114
115 AUTH_NONNULL_ALL
116 void auth_items_set_bool(auth_items_t, const char *key, bool value);
117
118 AUTH_WARN_RESULT AUTH_NONNULL_ALL
119 bool auth_items_get_bool(auth_items_t, const char *key);
120
121 AUTH_NONNULL_ALL
122 void auth_items_set_int(auth_items_t, const char *key, int32_t value);
123
124 AUTH_WARN_RESULT AUTH_NONNULL_ALL
125 int32_t auth_items_get_int(auth_items_t, const char *key);
126
127 AUTH_NONNULL_ALL
128 void auth_items_set_uint(auth_items_t, const char *key, uint32_t value);
129
130 AUTH_WARN_RESULT AUTH_NONNULL_ALL
131 uint32_t auth_items_get_uint(auth_items_t, const char *key);
132
133 AUTH_NONNULL_ALL
134 void auth_items_set_int64(auth_items_t, const char *key, int64_t value);
135
136 AUTH_WARN_RESULT AUTH_NONNULL_ALL
137 int64_t auth_items_get_int64(auth_items_t, const char *key);
138
139 AUTH_NONNULL_ALL
140 void auth_items_set_uint64(auth_items_t, const char *key, uint64_t value);
141
142 AUTH_WARN_RESULT AUTH_NONNULL_ALL
143 uint64_t auth_items_get_uint64(auth_items_t, const char *key);
144
145 AUTH_NONNULL_ALL
146 void auth_items_set_double(auth_items_t, const char *key, double value);
147
148 AUTH_WARN_RESULT AUTH_NONNULL_ALL
149 double auth_items_get_double(auth_items_t, const char *key);
150
151 AUTH_WARN_RESULT AUTH_NONNULL_ALL
152 uint32_t auth_items_get_type(auth_items_t, const char *key);
153
154 AUTH_WARN_RESULT AUTH_NONNULL_ALL
155 size_t auth_items_get_length(auth_items_t, const char *key);
156
157 AUTH_NONNULL_ALL
158 void auth_items_set_value(auth_items_t, const char *key, uint32_t type, uint32_t flags, const void *value, size_t len);
159
160 AUTH_NONNULL_ALL
161 void auth_items_encrypt(auth_items_t items, CFDataRef encryption_key);
162
163 AUTH_NONNULL_ALL
164 void auth_items_decrypt(auth_items_t items, CFDataRef encryption_key);
165
166 #pragma mark -
167 #pragma mark auth_rights_t
168
169 /* ordered items */
170
171 AUTH_WARN_RESULT AUTH_MALLOC AUTH_RETURNS_RETAINED
172 auth_rights_t auth_rights_create(void);
173
174 AUTH_WARN_RESULT AUTH_MALLOC AUTH_RETURNS_RETAINED
175 auth_rights_t auth_rights_create_with_xpc(const xpc_object_t data);
176
177 AUTH_WARN_RESULT AUTH_NONNULL_ALL
178 xpc_object_t auth_rights_export_xpc(auth_rights_t);
179
180 AUTH_NONNULL_ALL
181 void auth_rights_set_flags(auth_rights_t, const char *key, uint32_t flags);
182
183 AUTH_NONNULL_ALL
184 void auth_rights_clear_flags(auth_rights_t, const char *key, uint32_t flags);
185
186 AUTH_WARN_RESULT AUTH_NONNULL_ALL
187 uint32_t auth_rights_get_flags(auth_rights_t, const char *key);
188
189 AUTH_NONNULL_ALL
190 bool auth_rights_check_flags(auth_rights_t, const char *key, uint32_t flags);
191
192 AUTH_WARN_RESULT AUTH_NONNULL_ALL
193 size_t auth_rights_get_count(auth_rights_t);
194
195 AUTH_NONNULL_ALL
196 void auth_rights_add(auth_rights_t, const char *key);
197
198 AUTH_NONNULL_ALL
199 bool auth_rights_exist(auth_rights_t, const char *key);
200
201 AUTH_NONNULL_ALL
202 void auth_rights_remove(auth_rights_t, const char *key);
203
204 AUTH_NONNULL_ALL
205 void auth_rights_clear(auth_rights_t);
206
207 AUTH_NONNULL_ALL
208 bool auth_rights_iterate(auth_rights_t rights, bool(^iter)(const char * key));
209
210 #if defined(__cplusplus)
211 }
212 #endif
213
214 #endif /* !_SECURITY_AUTH_ITEMS_H_ */