]>
Commit | Line | Data |
---|---|---|
b1ab9ed8 A |
1 | /* |
2 | * Copyright (c) 2009-2010 Apple Inc. All Rights Reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | /*! | |
25 | @header policytree | |
26 | The functions provided in policytree.h provide an interface to | |
27 | a policy_tree implementation as specified in section 6 of rfc5280. | |
28 | */ | |
29 | ||
30 | #ifndef _SECURITY_POLICYTREE_H_ | |
31 | #define _SECURITY_POLICYTREE_H_ | |
32 | ||
33 | #include <libDER/libDER.h> | |
34 | #include <sys/queue.h> | |
35 | #include <stdbool.h> | |
36 | #include <Security/certextensions.h> | |
37 | ||
427c49bc | 38 | __BEGIN_DECLS |
b1ab9ed8 A |
39 | |
40 | ||
41 | #define oid_equal(oid1, oid2) DEROidCompare(&oid1, &oid2) | |
42 | typedef DERItem oid_t; | |
43 | typedef DERItem der_t; | |
44 | ||
45 | typedef struct policy_set *policy_set_t; | |
46 | struct policy_set { | |
47 | oid_t oid; | |
48 | policy_set_t oid_next; | |
49 | }; | |
50 | ||
51 | typedef const DERItem *policy_qualifier_t; | |
52 | ||
53 | typedef struct policy_tree *policy_tree_t; | |
54 | struct policy_tree { | |
55 | oid_t valid_policy; | |
56 | policy_qualifier_t qualifier_set; | |
57 | policy_set_t expected_policy_set; | |
58 | policy_tree_t children; | |
59 | policy_tree_t siblings; | |
60 | }; | |
61 | ||
62 | void policy_set_add(policy_set_t *policy_set, const oid_t *p_oid); | |
63 | void policy_set_intersect(policy_set_t *policy_set, policy_set_t other_set); | |
64 | bool policy_set_contains(policy_set_t policy_set, const oid_t *oid); | |
65 | void policy_set_free(policy_set_t policy_set); | |
66 | ||
67 | policy_tree_t policy_tree_create(const oid_t *p_oid, policy_qualifier_t p_q); | |
68 | ||
69 | bool policy_tree_walk_depth(policy_tree_t root, int depth, | |
70 | bool(*callback)(policy_tree_t, void *), void *ctx); | |
71 | ||
72 | void policy_tree_prune(policy_tree_t *node); | |
73 | void policy_tree_prune_childless(policy_tree_t *root, int depth); | |
74 | void policy_tree_add_child(policy_tree_t parent, | |
75 | const oid_t *p_oid, policy_qualifier_t p_q); | |
76 | void policy_tree_set_expected_policy(policy_tree_t node, | |
77 | policy_set_t p_expected); | |
78 | ||
79 | /* noop unless !defined NDEBUG */ | |
80 | void policy_tree_dump(policy_tree_t node); | |
81 | ||
427c49bc | 82 | __END_DECLS |
b1ab9ed8 A |
83 | |
84 | #endif /* !_SECURITY_POLICYTREE_H_ */ |