tpm2_protocol/message/
random_number.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3
4//! 16.1 `TPM2_GetRandom`
5//! 16.2 `TPM2_StirRandom`
6
7use crate::{
8    data::{Tpm2bDigest, Tpm2bSensitiveData, TpmCc},
9    tpm_struct,
10};
11use core::fmt::Debug;
12
13tpm_struct! {
14    #[derive(Debug, PartialEq, Eq, Clone, Copy)]
15    kind: Command,
16    name: TpmGetRandomCommand,
17    cc: TpmCc::GetRandom,
18    no_sessions: true,
19    with_sessions: true,
20    handles: {},
21    parameters: {
22        pub bytes_requested: u16,
23    }
24}
25
26tpm_struct! {
27    #[derive(Debug, Default, PartialEq, Eq, Clone)]
28    kind: Response,
29    name: TpmGetRandomResponse,
30    cc: TpmCc::GetRandom,
31    no_sessions: true,
32    with_sessions: true,
33    handles: {},
34    parameters: {
35        pub random_bytes: Tpm2bDigest,
36    }
37}
38
39tpm_struct! {
40    #[derive(Debug, PartialEq, Eq, Clone)]
41    kind: Command,
42    name: TpmStirRandomCommand,
43    cc: TpmCc::StirRandom,
44    no_sessions: true,
45    with_sessions: true,
46    handles: {},
47    parameters: {
48        pub in_data: Tpm2bSensitiveData,
49    }
50}
51
52tpm_struct! {
53    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
54    kind: Response,
55    name: TpmStirRandomResponse,
56    cc: TpmCc::StirRandom,
57    no_sessions: true,
58    with_sessions: true,
59    handles: {},
60    parameters: {}
61}