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    handles: {},
19    parameters: {
20        pub bytes_requested: u16,
21    }
22}
23
24tpm_struct! {
25    #[derive(Debug, Default, PartialEq, Eq, Clone)]
26    kind: Response,
27    name: TpmGetRandomResponse,
28    cc: TpmCc::GetRandom,
29    handles: {},
30    parameters: {
31        pub random_bytes: Tpm2bDigest,
32    }
33}
34
35tpm_struct! {
36    #[derive(Debug, PartialEq, Eq, Clone)]
37    kind: Command,
38    name: TpmStirRandomCommand,
39    cc: TpmCc::StirRandom,
40    handles: {},
41    parameters: {
42        pub in_data: Tpm2bSensitiveData,
43    }
44}
45
46tpm_struct! {
47    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
48    kind: Response,
49    name: TpmStirRandomResponse,
50    cc: TpmCc::StirRandom,
51    handles: {},
52    parameters: {}
53}