Skip to content

Commit bf96eff

Browse files
committed
ea_commands: add policy_authorize_nv
Although binding is already present, policy_authorize_nv was missing from the supported enhanced authorization commands. Add a simple implementation to fill the gap. Signed-off-by: Julien Gomes <julien@arista.com>
1 parent bab313a commit bf96eff

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

tss-esapi/src/context/tpm_commands/enhanced_authorization_ea_commands.rs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
use crate::{
44
attributes::LocalityAttributes,
55
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},
88
structures::{
99
AuthTicket, Digest, DigestList, Name, Nonce, PcrSelectionList, Signature, Timeout,
1010
VerifiedTicket,
1111
},
1212
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,
1515
Esys_PolicyNameHash, Esys_PolicyNvWritten, Esys_PolicyOR, Esys_PolicyPCR,
1616
Esys_PolicyPassword, Esys_PolicyPhysicalPresence, Esys_PolicySecret, Esys_PolicySigned,
1717
Esys_PolicyTemplate,
@@ -593,5 +593,30 @@ impl Context {
593593
},
594594
)
595595
}
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+
}
597622
}

0 commit comments

Comments
 (0)