Lines Matching refs:tree

54                        char *str, X509_POLICY_TREE *tree,  in tree_print()  argument
60 curr = tree->levels + tree->nlevel; in tree_print()
66 (long)(curr - tree->levels)); in tree_print()
67 for (plev = tree->levels; plev != curr; plev++) { in tree_print()
71 (long)(plev - tree->levels), plev->flags); in tree_print()
85 #define TREE_PRINT(str, tree, curr) \ argument
87 tree_print(trc_out, "before tree_prune()", tree, curr); \
100 X509_POLICY_TREE *tree; in tree_init() local
176 if ((tree = OPENSSL_zalloc(sizeof(*tree))) == NULL) in tree_init()
180 tree->node_maximum = OPENSSL_POLICY_TREE_NODES_MAX; in tree_init()
189 if ((tree->levels = OPENSSL_zalloc(sizeof(*tree->levels)*(n+1))) == NULL) { in tree_init()
190 OPENSSL_free(tree); in tree_init()
193 tree->nlevel = n+1; in tree_init()
194 level = tree->levels; in tree_init()
198 if (ossl_policy_level_add_node(level, data, NULL, tree, 1) == NULL) { in tree_init()
245 *ptree = tree; in tree_init()
249 X509_policy_tree_free(tree); in tree_init()
258 X509_POLICY_TREE *tree) in tree_link_matching_nodes() argument
268 if (ossl_policy_level_add_node(curr, data, node, tree, 0) == NULL) in tree_link_matching_nodes()
274 if (ossl_policy_level_add_node(curr, data, last->anyPolicy, tree, 0) == NULL) in tree_link_matching_nodes()
288 X509_POLICY_TREE *tree) in tree_link_nodes() argument
296 if (!tree_link_matching_nodes(curr, data, tree)) in tree_link_nodes()
311 X509_POLICY_NODE *node, X509_POLICY_TREE *tree) in tree_add_unmatched() argument
327 if (ossl_policy_level_add_node(curr, data, node, tree, 1) == NULL) { in tree_add_unmatched()
339 X509_POLICY_NODE *node, X509_POLICY_TREE *tree) in tree_link_unmatched() argument
349 if (!tree_add_unmatched(curr, cache, NULL, node, tree)) in tree_link_unmatched()
362 if (!tree_add_unmatched(curr, cache, oid, node, tree)) in tree_link_unmatched()
375 X509_POLICY_TREE *tree) in tree_link_any() argument
384 if (!tree_link_unmatched(curr, cache, node, tree)) in tree_link_any()
390 last->anyPolicy, tree, 0) == NULL) in tree_link_any()
405 static int tree_prune(X509_POLICY_TREE *tree, X509_POLICY_LEVEL *curr) in tree_prune() argument
440 if (curr == tree->levels) { in tree_prune()
480 static int tree_calculate_authority_set(X509_POLICY_TREE *tree, in tree_calculate_authority_set() argument
487 curr = tree->levels + tree->nlevel - 1; in tree_calculate_authority_set()
491 if (!tree_add_auth_node(&tree->auth_policies, curr->anyPolicy)) in tree_calculate_authority_set()
496 addnodes = &tree->auth_policies; in tree_calculate_authority_set()
498 curr = tree->levels; in tree_calculate_authority_set()
499 for (i = 1; i < tree->nlevel; i++) { in tree_calculate_authority_set()
522 *pnodes = tree->auth_policies; in tree_calculate_authority_set()
529 static int tree_calculate_user_set(X509_POLICY_TREE *tree, in tree_calculate_user_set() argument
546 anyPolicy = tree->levels[tree->nlevel - 1].anyPolicy; in tree_calculate_user_set()
551 tree->flags |= POLICY_FLAG_ANY_POLICY; in tree_calculate_user_set()
573 tree, 1); in tree_calculate_user_set()
579 if (!tree->user_policies) { in tree_calculate_user_set()
580 tree->user_policies = sk_X509_POLICY_NODE_new_null(); in tree_calculate_user_set()
581 if (!tree->user_policies) { in tree_calculate_user_set()
586 if (!sk_X509_POLICY_NODE_push(tree->user_policies, node)) { in tree_calculate_user_set()
600 static int tree_evaluate(X509_POLICY_TREE *tree) in tree_evaluate() argument
603 X509_POLICY_LEVEL *curr = tree->levels + 1; in tree_evaluate()
606 for (i = 1; i < tree->nlevel; i++, curr++) { in tree_evaluate()
608 if (!tree_link_nodes(curr, cache, tree)) in tree_evaluate()
612 && !tree_link_any(curr, cache, tree)) in tree_evaluate()
614 TREE_PRINT("before tree_prune()", tree, curr); in tree_evaluate()
615 ret = tree_prune(tree, curr); in tree_evaluate()
628 void X509_policy_tree_free(X509_POLICY_TREE *tree) in X509_policy_tree_free() argument
633 if (!tree) in X509_policy_tree_free()
636 sk_X509_POLICY_NODE_free(tree->auth_policies); in X509_policy_tree_free()
637 sk_X509_POLICY_NODE_pop_free(tree->user_policies, exnode_free); in X509_policy_tree_free()
639 for (i = 0, curr = tree->levels; i < tree->nlevel; i++, curr++) { in X509_policy_tree_free()
645 sk_X509_POLICY_DATA_pop_free(tree->extra_data, ossl_policy_data_free); in X509_policy_tree_free()
646 OPENSSL_free(tree->levels); in X509_policy_tree_free()
647 OPENSSL_free(tree); in X509_policy_tree_free()
666 X509_POLICY_TREE *tree = NULL; in X509_policy_check() local
671 init_ret = tree_init(&tree, certs, flags); in X509_policy_check()
678 X509_policy_tree_free(tree); in X509_policy_check()
688 ret = tree_evaluate(tree); in X509_policy_check()
689 TREE_PRINT("tree_evaluate()", tree, NULL); in X509_policy_check()
694 X509_policy_tree_free(tree); in X509_policy_check()
702 if ((calc_ret = tree_calculate_authority_set(tree, &auth_nodes)) == 0) in X509_policy_check()
705 ret = tree_calculate_user_set(tree, policy_oids, auth_nodes); in X509_policy_check()
711 *ptree = tree; in X509_policy_check()
714 nodes = X509_policy_tree_get0_user_policies(tree); in X509_policy_check()
721 X509_policy_tree_free(tree); in X509_policy_check()