Skip to content

Commit 4997324

Browse files
author
Muxi Yan
committed
Enrich documentation to tr_sess_get_nonce_tpm
1 parent 29cdfe2 commit 4997324

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tss-esapi/src/context/session_administration.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ impl Context {
5454
}
5555

5656
/// Get the TPM nonce from a session.
57+
///
58+
/// # Arguments
59+
/// * `session` - An [AuthSession] handle to the authentication session from
60+
/// which to retrieve the TPM nonce.
61+
///
62+
/// # Returns
63+
/// The TPM nonce as a [Nonce] struct on success.
64+
///
65+
/// # Details
66+
/// This function retrieves the nonceTPM value from an authentication session.
67+
///
68+
/// Extracted nonceTPM can be useful in some scenarios. For example, a TPM object protected by a
69+
/// PolicySigned policy requires the nonceTPM value to be extracted and included in the signed
70+
/// digest to satisfy the policy.
71+
///
72+
/// # Example
73+
/// ```rust
74+
/// # use tss_esapi::{Context, AuthSession};
75+
/// let mut context = Context::new()?;
76+
/// let session = context.start_auth_session(None, None, None, SessionType::Policy, SymmetricDefinition::AES_256_CFB, HashingAlgorithm::Sha256)?;
77+
/// let nonce_tpm = context.tr_sess_get_nonce_tpm(session)?;
78+
/// // Use the nonce_tpm value as needed
79+
/// ```
5780
pub fn tr_sess_get_nonce_tpm(&mut self, session: AuthSession) -> Result<Nonce> {
5881
let mut nonce_ptr = std::ptr::null_mut();
5982
ReturnCode::ensure_success(

0 commit comments

Comments
 (0)