Lines Matching full:policy
29 /** Create a new policy on policy stack.
31 * The structures for policy and callback execution are allocated
38 TPMS_POLICY *policy, in new_policy() argument
41 LOG_DEBUG("ADD POLICY"); in new_policy()
75 pol_exec_ctx->policy = policy; in new_policy()
76 if (!context->policy.policyutil_stack) { in new_policy()
77 context->policy.policyutil_stack = *current_policy; in new_policy()
78 context->policy.util_current_policy = *current_policy; in new_policy()
80 context->policy.util_current_policy->next = *current_policy; in new_policy()
81 (*current_policy)->prev = context->policy.util_current_policy; in new_policy()
86 /** Compute a new session which will be uses as policy session.
100 switch (context->policy.create_session_state) { in create_session()
113 context->policy.create_session_state = WAIT_FOR_CREATE_SESSION; in create_session()
120 context->policy.create_session_state = CREATE_SESSION_INIT; in create_session()
133 /** Cleanup the current policy and adapt the policy stack.
139 LOG_DEBUG("CLEAR POLICY"); in clear_current_policy()
141 if (!context->policy.util_current_policy) { in clear_current_policy()
142 return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "No current policy."); in clear_current_policy()
144 prev_pol = context->policy.util_current_policy->prev; in clear_current_policy()
146 SAFE_FREE(context->policy.util_current_policy->pol_exec_ctx->app_data); in clear_current_policy()
147 SAFE_FREE(context->policy.util_current_policy->pol_exec_ctx); in clear_current_policy()
148 SAFE_FREE(context->policy.util_current_policy); in clear_current_policy()
151 context->policy.policyutil_stack = NULL; in clear_current_policy()
158 /** Cleanup the policy stack.
167 IFAPI_POLICYUTIL_STACK *policy = context->policy.policyutil_stack; in clear_all_policies() local
170 while (policy) { in clear_all_policies()
171 next_policy = policy->next; in clear_all_policies()
172 SAFE_FREE(policy->pol_exec_ctx->app_data); in clear_all_policies()
173 if (policy->pol_exec_ctx->session) in clear_all_policies()
174 Esys_FlushContext(context->esys, policy->pol_exec_ctx->session); in clear_all_policies()
175 SAFE_FREE(policy->pol_exec_ctx); in clear_all_policies()
177 SAFE_FREE(policy); in clear_all_policies()
178 policy = next_policy; in clear_all_policies()
180 context->policy.policyutil_stack = NULL; in clear_all_policies()
183 /** Prepare the execution of a new policy on policy stack.
185 * The context for the policy utility, the policy execution and the needed
187 * The policy execution will be prepared. In this step the list of policies
189 * @param[in,out] context The fapi context with the pointer to the policy stack.
190 * @param[in] hash_alg The hash algorithm used for the policy computation.
191 * @param[in,out] policy The policy to be executed. Some policy elements will
192 * be used to store computed parameters needed for policy
210 TPMS_POLICY *policy) in ifapi_policyutil_execute_prepare() argument
217 r = new_policy(context, policy, ¤t_policy); in ifapi_policyutil_execute_prepare()
218 goto_if_error(r, "Create new policy.", error); in ifapi_policyutil_execute_prepare()
220 r = ifapi_policyeval_execute_prepare(current_policy->pol_exec_ctx, hash_alg, policy); in ifapi_policyutil_execute_prepare()
221 goto_if_error(r, "Prepare policy execution.", error); in ifapi_policyutil_execute_prepare()
226 while (context->policy.policyutil_stack) { in ifapi_policyutil_execute_prepare()
232 /** State machine to Execute the TPM policy commands needed for the current policy.
235 * In the second step the policy engine will execute the policy.
237 * @param[in,out] context The fapi context with the pointer to the policy stack.
238 * @param[in,out] session The policy session to be extended or if the value is
244 * @retval TSS2_FAPI_RC_IO_ERROR If an error occurs during access to the policy
246 * @retval TSS2_FAPI_RC_POLICY_UNKNOWN If policy search for a certain policy digest was
248 * @retval TSS2_FAPI_RC_BAD_TEMPLATE In a invalid policy is loaded during execution.
249 * @retval TPM2_RC_BAD_AUTH If the authentication for an object needed for policy
272 if (context->policy.util_current_policy) { in ifapi_policyutil_execute()
273 pol_util_ctx = context->policy.util_current_policy->next; in ifapi_policyutil_execute()
274 context->policy.util_current_policy = context->policy.util_current_policy->next; in ifapi_policyutil_execute()
276 pol_util_ctx = context->policy.policyutil_stack; in ifapi_policyutil_execute()
277 context->policy.util_current_policy = pol_util_ctx; in ifapi_policyutil_execute()
282 return_error(TSS2_FAPI_RC_GENERAL_FAILURE, "No policy util stack."); in ifapi_policyutil_execute()
289 /* Create a new policy session for the current policy execution */ in ifapi_policyutil_execute()
294 context->policy.util_current_policy = pol_util_ctx->prev; in ifapi_policyutil_execute()
297 goto_if_error(r, "Create policy session", error); in ifapi_policyutil_execute()
309 context->policy.util_current_policy = pol_util_ctx->prev; in ifapi_policyutil_execute()
312 goto_if_error(r, "Execute policy.", error); in ifapi_policyutil_execute()
323 goto_if_error(r, "Clear policy.", error); in ifapi_policyutil_execute()
325 context->policy.util_current_policy = pol_util_ctx; in ifapi_policyutil_execute()
331 while (context->policy.policyutil_stack) { in ifapi_policyutil_execute()