|
3 | 3 | use crate::{ |
4 | 4 | attributes::LocalityAttributes, |
5 | 5 | constants::CommandCode, |
6 | | - handles::{AuthHandle, ObjectHandle, SessionHandle}, |
7 | | - interface_types::{session_handles::PolicySession, YesNo}, |
| 6 | + handles::{AuthHandle, NvIndexHandle, ObjectHandle, SessionHandle}, |
| 7 | + interface_types::{resource_handles::NvAuth, session_handles::PolicySession, YesNo}, |
8 | 8 | structures::{ |
9 | 9 | AuthTicket, Digest, DigestList, Name, Nonce, PcrSelectionList, Signature, Timeout, |
10 | 10 | VerifiedTicket, |
11 | 11 | }, |
12 | 12 | tss2_esys::{ |
13 | | - Esys_PolicyAuthValue, Esys_PolicyAuthorize, Esys_PolicyCommandCode, Esys_PolicyCpHash, |
14 | | - Esys_PolicyDuplicationSelect, Esys_PolicyGetDigest, Esys_PolicyLocality, |
| 13 | + Esys_PolicyAuthValue, Esys_PolicyAuthorize, Esys_PolicyAuthorizeNV, Esys_PolicyCommandCode, |
| 14 | + Esys_PolicyCpHash, Esys_PolicyDuplicationSelect, Esys_PolicyGetDigest, Esys_PolicyLocality, |
15 | 15 | Esys_PolicyNameHash, Esys_PolicyNvWritten, Esys_PolicyOR, Esys_PolicyPCR, |
16 | 16 | Esys_PolicyPassword, Esys_PolicyPhysicalPresence, Esys_PolicySecret, Esys_PolicySigned, |
17 | 17 | Esys_PolicyTemplate, |
@@ -593,5 +593,30 @@ impl Context { |
593 | 593 | }, |
594 | 594 | ) |
595 | 595 | } |
596 | | - // Missing function: PolicyAuthorizeNV |
| 596 | + |
| 597 | + /// Cause conditional gating of a policy based on an authorized policy |
| 598 | + /// stored in non-volatile memory. |
| 599 | + pub fn policy_authorize_nv( |
| 600 | + &mut self, |
| 601 | + policy_session: PolicySession, |
| 602 | + auth_handle: NvAuth, |
| 603 | + nv_index_handle: NvIndexHandle, |
| 604 | + ) -> Result<()> { |
| 605 | + ReturnCode::ensure_success( |
| 606 | + unsafe { |
| 607 | + Esys_PolicyAuthorizeNV( |
| 608 | + self.mut_context(), |
| 609 | + AuthHandle::from(auth_handle).into(), |
| 610 | + nv_index_handle.into(), |
| 611 | + SessionHandle::from(policy_session).into(), |
| 612 | + self.optional_session_1(), |
| 613 | + self.optional_session_2(), |
| 614 | + self.optional_session_3(), |
| 615 | + ) |
| 616 | + }, |
| 617 | + |ret| { |
| 618 | + error!("Error when computing policy authorize NV: {:#010X}", ret); |
| 619 | + }, |
| 620 | + ) |
| 621 | + } |
597 | 622 | } |
0 commit comments