1use crate::{
6 data::{
7 Tpm2b, Tpm2bAttest, Tpm2bAuth, Tpm2bCreationData, Tpm2bData, Tpm2bDigest, Tpm2bEccPoint,
8 Tpm2bEncryptedSecret, Tpm2bIdObject, Tpm2bMaxBuffer, Tpm2bName, Tpm2bPrivate, Tpm2bPublic,
9 Tpm2bPublicKeyRsa, Tpm2bSensitive, Tpm2bSensitiveCreate, Tpm2bSensitiveData, TpmAlgId,
10 TpmCap, TpmCc, TpmEccCurve, TpmRc, TpmRh, TpmSe, TpmSu, TpmiYesNo, TpmlAlg,
11 TpmlPcrSelection, TpmsAlgorithmDetailEcc, TpmsAuthCommand, TpmsAuthResponse,
12 TpmsCapabilityData, TpmsContext, TpmtRsaDecrypt, TpmtSignature, TpmtSymDef,
13 TpmtSymDefObject, TpmtTkCreation, TpmtTkHashcheck, TpmtTkVerified,
14 },
15 tpm_dispatch, tpm_response, tpm_struct, TpmBuild, TpmList, TpmParse, TpmPersistent, TpmSession,
16 TpmSized, TpmTransient,
17};
18use core::fmt::Debug;
19
20pub mod build;
21pub mod integrity;
22pub mod non_volatile;
23pub mod parse;
24pub mod policy;
25pub mod sequence;
26
27pub use build::*;
28pub use integrity::*;
29pub use non_volatile::*;
30pub use parse::*;
31pub use policy::*;
32pub use sequence::*;
33
34pub const MAX_HANDLES: usize = 8;
36pub const MAX_SESSIONS: usize = 8;
38
39pub type TpmHandles = TpmList<u32, MAX_HANDLES>;
41pub type TpmAuthCommands = TpmList<TpmsAuthCommand, MAX_SESSIONS>;
43pub type TpmAuthResponses = TpmList<TpmsAuthResponse, MAX_SESSIONS>;
45
46pub trait TpmHeader: TpmBuild + TpmParse + Debug {
48 const COMMAND: TpmCc;
49 const NO_SESSIONS: bool;
50 const WITH_SESSIONS: bool;
51 const HANDLES: usize;
52}
53
54pub const TPM_HEADER_SIZE: usize = 10;
55
56tpm_struct! {
57 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
58 TpmStartupCommand,
59 TpmCc::Startup,
60 true,
61 false,
62 0,
63 {
64 pub startup_type: TpmSu,
65 }
66}
67
68tpm_struct! {
69 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
70 TpmStartupResponse,
71 TpmCc::Startup,
72 true,
73 false,
74 0,
75 {}
76}
77
78tpm_struct! {
79 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
80 TpmShutdownCommand,
81 TpmCc::Shutdown,
82 true,
83 true,
84 0,
85 {
86 pub shutdown_type: TpmSu,
87 }
88}
89
90tpm_struct! {
91 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
92 TpmShutdownResponse,
93 TpmCc::Shutdown,
94 true,
95 true,
96 0,
97 {}
98}
99
100tpm_struct! {
101 #[derive(Debug, PartialEq, Eq, Clone)]
102 TpmContextLoadCommand,
103 TpmCc::ContextLoad,
104 true,
105 false,
106 0,
107 {
108 pub context: TpmsContext,
109 }
110}
111
112tpm_struct! {
113 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
114 TpmContextSaveCommand,
115 TpmCc::ContextSave,
116 true,
117 false,
118 1,
119 {}
120}
121
122tpm_struct! {
123 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
124 TpmDictionaryAttackLockResetCommand,
125 TpmCc::DictionaryAttackLockReset,
126 false,
127 true,
128 1,
129 {}
130}
131
132tpm_struct! {
133 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
134 TpmFlushContextCommand,
135 TpmCc::FlushContext,
136 true,
137 false,
138 0,
139 {
140 pub flush_handle: u32,
141 }
142}
143
144tpm_struct! {
145 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
146 TpmUnsealCommand,
147 TpmCc::Unseal,
148 false,
149 true,
150 1,
151 {}
152}
153
154macro_rules! tpm_create {
155 ($name:ident, $cc:expr) => {
156 tpm_struct! {
157 #[derive(Debug, Default, PartialEq, Eq, Clone)]
158 $name,
159 $cc,
160 false,
161 true,
162 1,
163 {
164 pub in_sensitive: Tpm2bSensitiveCreate,
165 pub in_public: Tpm2bPublic,
166 pub outside_info: Tpm2b,
167 pub creation_pcr: TpmlPcrSelection,
168 }
169 }
170 };
171}
172
173tpm_create!(TpmCreateCommand, TpmCc::Create);
174tpm_create!(TpmCreatePrimaryCommand, TpmCc::CreatePrimary);
175
176tpm_struct! {
177 #[derive(Debug, PartialEq, Eq, Clone)]
178 TpmEvictControlCommand,
179 TpmCc::EvictControl,
180 false,
181 true,
182 2,
183 {
184 pub persistent_handle: TpmPersistent,
185 }
186}
187
188tpm_struct! {
189 #[derive(Debug, PartialEq, Eq, Clone)]
190 TpmGetCapabilityCommand,
191 TpmCc::GetCapability,
192 true,
193 true,
194 0,
195 {
196 pub cap: TpmCap,
197 pub property: u32,
198 pub property_count: u32,
199 }
200}
201
202tpm_struct! {
203 #[derive(Debug, PartialEq, Eq, Clone)]
204 TpmHashCommand,
205 TpmCc::Hash,
206 true,
207 false,
208 0,
209 {
210 pub data: Tpm2bMaxBuffer,
211 pub hash_alg: TpmAlgId,
212 pub hierarchy: TpmRh,
213 }
214}
215
216tpm_struct! {
217 #[derive(Debug, PartialEq, Eq, Clone)]
218 TpmImportCommand,
219 TpmCc::Import,
220 false,
221 true,
222 1,
223 {
224 pub encryption_key: Tpm2b,
225 pub object_public: Tpm2bPublic,
226 pub duplicate: Tpm2bPrivate,
227 pub in_sym_seed: Tpm2bEncryptedSecret,
228 pub symmetric_alg: TpmtSymDef,
229 }
230}
231
232tpm_struct! {
233 #[derive(Debug, Default, PartialEq, Eq, Clone)]
234 TpmLoadCommand,
235 TpmCc::Load,
236 false,
237 true,
238 1,
239 {
240 pub in_private: Tpm2bPrivate,
241 pub in_public: Tpm2bPublic,
242 }
243}
244
245tpm_struct! {
246 #[derive(Debug, Default, PartialEq, Eq, Clone)]
247 TpmObjectChangeAuthCommand,
248 TpmCc::ObjectChangeAuth,
249 false,
250 true,
251 2,
252 {
253 pub new_auth: Tpm2bAuth,
254 }
255}
256
257#[derive(Debug, Default, PartialEq, Eq, Clone)]
258pub struct TpmPolicyGetDigestResponse {
259 pub policy_digest: Tpm2bDigest,
260}
261impl TpmHeader for TpmPolicyGetDigestResponse {
262 const COMMAND: TpmCc = TpmCc::PolicyGetDigest;
263 const NO_SESSIONS: bool = false;
264 const WITH_SESSIONS: bool = true;
265 const HANDLES: usize = 0;
266}
267impl crate::TpmSized for TpmPolicyGetDigestResponse {
268 const SIZE: usize = <Tpm2bDigest>::SIZE;
269 fn len(&self) -> usize {
270 TpmSized::len(&self.policy_digest)
271 }
272}
273impl crate::TpmBuild for TpmPolicyGetDigestResponse {
274 fn build(&self, writer: &mut crate::TpmWriter) -> crate::TpmResult<()> {
275 TpmBuild::build(&self.policy_digest, writer)
276 }
277}
278impl crate::TpmParse for TpmPolicyGetDigestResponse {
279 fn parse(buf: &[u8]) -> crate::TpmResult<(Self, &[u8])> {
280 if buf.is_empty() {
281 return Ok((Self::default(), buf));
282 }
283 let (policy_digest, buf) = Tpm2bDigest::parse(buf)?;
284 Ok((Self { policy_digest }, buf))
285 }
286}
287
288tpm_struct! {
289 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
290 TpmReadPublicCommand,
291 TpmCc::ReadPublic,
292 true,
293 true,
294 1,
295 {}
296}
297
298tpm_struct! {
299 #[derive(Debug, Default, PartialEq, Eq, Clone)]
300 TpmStartAuthSessionCommand,
301 TpmCc::StartAuthSession,
302 true,
303 true,
304 2,
305 {
306 pub nonce_caller: Tpm2b,
307 pub encrypted_salt: Tpm2b,
308 pub session_type: TpmSe,
309 pub symmetric: TpmtSymDefObject,
310 pub auth_hash: TpmAlgId,
311 }
312}
313
314tpm_struct! {
315 #[derive(Debug, PartialEq, Eq, Clone)]
316 TpmVendorTcgTestCommand,
317 TpmCc::VendorTcgTest,
318 true,
319 false,
320 0,
321 {
322 pub input_data: Tpm2bData,
323 }
324}
325
326tpm_struct! {
327 #[derive(Debug, PartialEq, Eq, Clone)]
328 TpmContextLoadResponse,
329 TpmCc::ContextLoad,
330 true,
331 false,
332 0,
333 {
334 pub loaded_handle: TpmTransient,
335 }
336}
337
338tpm_struct! {
339 #[derive(Debug, PartialEq, Eq, Clone)]
340 TpmContextSaveResponse,
341 TpmCc::ContextSave,
342 true,
343 false,
344 0,
345 {
346 pub context: TpmsContext,
347 }
348}
349
350tpm_struct! {
351 #[derive(Debug, PartialEq, Eq, Clone)]
352 TpmHashResponse,
353 TpmCc::Hash,
354 true,
355 false,
356 0,
357 {
358 pub out_hash: Tpm2bDigest,
359 pub validation: TpmtTkHashcheck,
360 }
361}
362
363tpm_struct! {
364 #[derive(Debug, Default, PartialEq, Eq, Clone)]
365 TpmImportResponse,
366 TpmCc::Import,
367 false,
368 true,
369 0,
370 {
371 pub out_private: Tpm2bPrivate,
372 }
373}
374
375tpm_response! {
376 #[derive(Debug, Default, PartialEq, Eq, Clone)]
377 TpmObjectChangeAuthResponse,
378 TpmCc::ObjectChangeAuth,
379 false,
380 true,
381 {
382 pub out_private: Tpm2bPrivate,
383 }
384}
385
386tpm_response! {
387 #[derive(Debug, Default, PartialEq, Eq, Clone)]
388 TpmReadPublicResponse,
389 TpmCc::ReadPublic,
390 true,
391 false,
392 {
393 pub out_public: Tpm2bPublic,
394 pub name: Tpm2bName,
395 pub qualified_name: Tpm2bName,
396 }
397}
398
399tpm_struct! {
400 #[derive(Debug, Default, PartialEq, Eq, Clone)]
401 TpmStartAuthSessionResponse,
402 TpmCc::StartAuthSession,
403 true,
404 false,
405 0,
406 {
407 pub session_handle: TpmSession,
408 pub nonce_tpm: Tpm2b,
409 }
410}
411
412tpm_struct! {
413 #[derive(Debug, PartialEq, Eq, Clone)]
414 TpmVendorTcgTestResponse,
415 TpmCc::VendorTcgTest,
416 true,
417 false,
418 0,
419 {
420 pub output_data: Tpm2bData,
421 }
422}
423
424tpm_response! {
425 #[derive(Debug, PartialEq, Eq, Clone)]
426 TpmCreatePrimaryResponse,
427 TpmCc::CreatePrimary,
428 false,
429 true,
430 pub object_handle: TpmTransient,
431 {
432 pub out_public: Tpm2bPublic,
433 pub creation_data: Tpm2bCreationData,
434 pub creation_hash: Tpm2bDigest,
435 pub creation_ticket: TpmtTkCreation,
436 pub name: Tpm2bName,
437 }
438}
439
440tpm_response! {
441 #[derive(Debug, PartialEq, Eq, Clone)]
442 TpmCreateResponse,
443 TpmCc::Create,
444 false,
445 true,
446 {
447 pub out_private: Tpm2bPrivate,
448 pub out_public: Tpm2bPublic,
449 pub creation_data: Tpm2bCreationData,
450 pub creation_hash: Tpm2bDigest,
451 pub creation_ticket: TpmtTkCreation,
452 }
453}
454
455tpm_struct! {
456 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
457 TpmDictionaryAttackLockResetResponse,
458 TpmCc::DictionaryAttackLockReset,
459 false,
460 true,
461 0,
462 {}
463}
464
465tpm_struct! {
466 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
467 TpmEvictControlResponse,
468 TpmCc::EvictControl,
469 false,
470 true,
471 0,
472 {}
473}
474
475tpm_struct! {
476 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
477 TpmFlushContextResponse,
478 TpmCc::FlushContext,
479 true,
480 false,
481 0,
482 {}
483}
484
485tpm_struct! {
486 #[derive(Debug, PartialEq, Eq, Clone)]
487 TpmGetCapabilityResponse,
488 TpmCc::GetCapability,
489 true,
490 false,
491 0,
492 {
493 pub more_data: TpmiYesNo,
494 pub capability_data: TpmsCapabilityData,
495 }
496}
497
498tpm_response! {
499 #[derive(Debug, PartialEq, Eq, Clone)]
500 TpmLoadResponse,
501 TpmCc::Load,
502 false,
503 true,
504 pub object_handle: TpmTransient,
505 {
506 pub name: Tpm2bName,
507 }
508}
509
510tpm_response! {
511 #[derive(Debug, Default, PartialEq, Eq, Clone)]
512 TpmUnsealResponse,
513 TpmCc::Unseal,
514 false,
515 true,
516 {
517 pub out_data: Tpm2b,
518 }
519}
520
521tpm_struct! {
522 #[derive(Debug, PartialEq, Eq, Clone)]
523 TpmNvCertifyResponse,
524 TpmCc::NvCertify,
525 false,
526 true,
527 0,
528 {
529 pub certify_info: Tpm2bAttest,
530 pub signature: TpmtSignature,
531 }
532}
533
534tpm_struct! {
535 #[derive(Debug, PartialEq, Eq, Clone)]
536 TpmCertifyCommand,
537 TpmCc::Certify,
538 false,
539 true,
540 2,
541 {
542 pub qualifying_data: Tpm2bData,
543 pub in_scheme: TpmtSignature,
544 }
545}
546
547tpm_response! {
548 #[derive(Debug, PartialEq, Eq, Clone)]
549 TpmCertifyResponse,
550 TpmCc::Certify,
551 false,
552 true,
553 {
554 pub certify_info: Tpm2bAttest,
555 pub signature: TpmtSignature,
556 }
557}
558
559tpm_struct! {
560 #[derive(Debug, PartialEq, Eq, Clone)]
561 TpmCertifyCreationCommand,
562 TpmCc::CertifyCreation,
563 false,
564 true,
565 2,
566 {
567 pub qualifying_data: Tpm2bData,
568 pub creation_hash: Tpm2bDigest,
569 pub in_scheme: TpmtSignature,
570 pub creation_ticket: TpmtTkCreation,
571 }
572}
573
574tpm_response! {
575 #[derive(Debug, PartialEq, Eq, Clone)]
576 TpmCertifyCreationResponse,
577 TpmCc::CertifyCreation,
578 false,
579 true,
580 {
581 pub certify_info: Tpm2bAttest,
582 pub signature: TpmtSignature,
583 }
584}
585
586tpm_struct! {
587 #[derive(Debug, PartialEq, Eq, Clone)]
588 TpmQuoteCommand,
589 TpmCc::Quote,
590 false,
591 true,
592 1,
593 {
594 pub qualifying_data: Tpm2bData,
595 pub in_scheme: TpmtSignature,
596 pub pcr_select: TpmlPcrSelection,
597 }
598}
599
600tpm_response! {
601 #[derive(Debug, PartialEq, Eq, Clone)]
602 TpmQuoteResponse,
603 TpmCc::Quote,
604 false,
605 true,
606 {
607 pub quoted: Tpm2bAttest,
608 pub signature: TpmtSignature,
609 }
610}
611
612tpm_struct! {
613 #[derive(Debug, PartialEq, Eq, Clone)]
614 TpmGetSessionAuditDigestCommand,
615 TpmCc::GetSessionAuditDigest,
616 false,
617 true,
618 3,
619 {
620 pub qualifying_data: Tpm2bData,
621 pub in_scheme: TpmtSignature,
622 }
623}
624
625tpm_response! {
626 #[derive(Debug, PartialEq, Eq, Clone)]
627 TpmGetSessionAuditDigestResponse,
628 TpmCc::GetSessionAuditDigest,
629 false,
630 true,
631 {
632 pub audit_info: Tpm2bAttest,
633 pub signature: TpmtSignature,
634 }
635}
636
637tpm_struct! {
638 #[derive(Debug, PartialEq, Eq, Clone)]
639 TpmGetCommandAuditDigestCommand,
640 TpmCc::GetCommandAuditDigest,
641 false,
642 true,
643 2,
644 {
645 pub qualifying_data: Tpm2bData,
646 pub in_scheme: TpmtSignature,
647 }
648}
649
650tpm_response! {
651 #[derive(Debug, PartialEq, Eq, Clone)]
652 TpmGetCommandAuditDigestResponse,
653 TpmCc::GetCommandAuditDigest,
654 false,
655 true,
656 {
657 pub audit_info: Tpm2bAttest,
658 pub signature: TpmtSignature,
659 }
660}
661
662tpm_struct! {
663 #[derive(Debug, PartialEq, Eq, Clone)]
664 TpmGetTimeCommand,
665 TpmCc::GetTime,
666 false,
667 true,
668 2,
669 {
670 pub qualifying_data: Tpm2bData,
671 pub in_scheme: TpmtSignature,
672 }
673}
674
675tpm_response! {
676 #[derive(Debug, PartialEq, Eq, Clone)]
677 TpmGetTimeResponse,
678 TpmCc::GetTime,
679 false,
680 true,
681 {
682 pub time_info: Tpm2bAttest,
683 pub signature: TpmtSignature,
684 }
685}
686
687tpm_struct! {
688 #[derive(Debug, PartialEq, Eq, Clone)]
689 TpmSignCommand,
690 TpmCc::Sign,
691 false,
692 true,
693 1,
694 {
695 pub digest: Tpm2bDigest,
696 pub in_scheme: TpmtSignature,
697 pub validation: TpmtTkHashcheck,
698 }
699}
700
701tpm_response! {
702 #[derive(Debug, PartialEq, Eq, Clone)]
703 TpmSignResponse,
704 TpmCc::Sign,
705 false,
706 true,
707 {
708 pub signature: TpmtSignature,
709 }
710}
711
712tpm_struct! {
713 #[derive(Debug, PartialEq, Eq, Clone)]
714 TpmVerifySignatureCommand,
715 TpmCc::VerifySignature,
716 true,
717 false,
718 1,
719 {
720 pub digest: Tpm2bDigest,
721 pub signature: TpmtSignature,
722 }
723}
724
725tpm_response! {
726 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
727 TpmVerifySignatureResponse,
728 TpmCc::VerifySignature,
729 true,
730 false,
731 {
732 pub validation: TpmtTkVerified,
733 }
734}
735
736tpm_struct! {
737 #[derive(Debug, PartialEq, Eq, Clone)]
738 TpmMakeCredentialCommand,
739 TpmCc::MakeCredential,
740 true,
741 true,
742 1,
743 {
744 pub credential: Tpm2bDigest,
745 pub object_name: Tpm2bName,
746 }
747}
748
749tpm_response! {
750 #[derive(Debug, PartialEq, Eq, Clone)]
751 TpmMakeCredentialResponse,
752 TpmCc::MakeCredential,
753 true,
754 true,
755 {
756 pub credential_blob: Tpm2bIdObject,
757 pub secret: Tpm2bEncryptedSecret,
758 }
759}
760
761tpm_struct! {
762 #[derive(Debug, PartialEq, Eq, Clone)]
763 TpmLoadExternalCommand,
764 TpmCc::LoadExternal,
765 true,
766 true,
767 0,
768 {
769 pub in_private: Tpm2bSensitive,
770 pub in_public: Tpm2bPublic,
771 pub hierarchy: TpmRh,
772 }
773}
774
775tpm_response! {
776 #[derive(Debug, PartialEq, Eq, Clone)]
777 TpmLoadExternalResponse,
778 TpmCc::LoadExternal,
779 true,
780 true,
781 pub object_handle: TpmTransient,
782 {
783 pub name: Tpm2bName,
784 }
785}
786
787tpm_struct! {
788 #[derive(Debug, PartialEq, Eq, Clone)]
789 TpmActivateCredentialCommand,
790 TpmCc::ActivateCredential,
791 true,
792 true,
793 2,
794 {
795 pub credential_blob: Tpm2bIdObject,
796 pub secret: Tpm2bEncryptedSecret,
797 }
798}
799
800tpm_response! {
801 #[derive(Debug, PartialEq, Eq, Clone)]
802 TpmActivateCredentialResponse,
803 TpmCc::ActivateCredential,
804 true,
805 true,
806 {
807 pub cert_info: Tpm2bDigest,
808 }
809}
810
811tpm_struct! {
812 #[derive(Debug, PartialEq, Eq, Clone)]
813 TpmSelfTestCommand,
814 TpmCc::SelfTest,
815 true,
816 true,
817 0,
818 {
819 pub full_test: TpmiYesNo,
820 }
821}
822
823tpm_response! {
824 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
825 TpmSelfTestResponse,
826 TpmCc::SelfTest,
827 true,
828 true,
829 {}
830}
831
832tpm_struct! {
833 #[derive(Debug, PartialEq, Eq, Clone)]
834 TpmIncrementalSelfTestCommand,
835 TpmCc::IncrementalSelfTest,
836 true,
837 true,
838 0,
839 {
840 pub to_test: TpmlAlg,
841 }
842}
843
844tpm_response! {
845 #[derive(Debug, Default, PartialEq, Eq, Clone)]
846 TpmIncrementalSelfTestResponse,
847 TpmCc::IncrementalSelfTest,
848 true,
849 true,
850 {
851 pub to_do_list: TpmlAlg,
852 }
853}
854
855tpm_struct! {
856 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
857 TpmGetTestResultCommand,
858 TpmCc::GetTestResult,
859 true,
860 true,
861 0,
862 {}
863}
864
865tpm_response! {
866 #[derive(Debug, PartialEq, Eq, Clone)]
867 TpmGetTestResultResponse,
868 TpmCc::GetTestResult,
869 true,
870 true,
871 {
872 pub out_data: Tpm2bMaxBuffer,
873 pub test_result: TpmRc,
874 }
875}
876
877tpm_struct! {
878 #[derive(Debug, PartialEq, Eq, Clone)]
879 TpmDuplicateCommand,
880 TpmCc::Duplicate,
881 false,
882 true,
883 2,
884 {
885 pub encryption_key_in: Tpm2bData,
886 pub symmetric_alg: TpmtSymDefObject,
887 }
888}
889
890tpm_response! {
891 #[derive(Debug, PartialEq, Eq, Clone)]
892 TpmDuplicateResponse,
893 TpmCc::Duplicate,
894 false,
895 true,
896 {
897 pub encryption_key_out: Tpm2bData,
898 pub duplicate: Tpm2bPrivate,
899 pub out_sym_seed: Tpm2bEncryptedSecret,
900 }
901}
902
903tpm_struct! {
904 #[derive(Debug, PartialEq, Eq, Clone)]
905 TpmRewrapCommand,
906 TpmCc::Rewrap,
907 false,
908 true,
909 2,
910 {
911 pub in_duplicate: Tpm2bPrivate,
912 pub name: Tpm2bName,
913 pub in_sym_seed: Tpm2bEncryptedSecret,
914 }
915}
916
917tpm_response! {
918 #[derive(Debug, PartialEq, Eq, Clone)]
919 TpmRewrapResponse,
920 TpmCc::Rewrap,
921 false,
922 true,
923 {
924 pub out_duplicate: Tpm2bPrivate,
925 pub out_sym_seed: Tpm2bEncryptedSecret,
926 }
927}
928
929tpm_struct! {
930 #[derive(Debug, PartialEq, Eq, Clone)]
931 TpmRsaEncryptCommand,
932 TpmCc::RsaEncrypt,
933 true,
934 true,
935 1,
936 {
937 pub message: Tpm2bPublicKeyRsa,
938 pub in_scheme: TpmtRsaDecrypt,
939 pub label: Tpm2bData,
940 }
941}
942
943tpm_response! {
944 #[derive(Debug, PartialEq, Eq, Clone)]
945 TpmRsaEncryptResponse,
946 TpmCc::RsaEncrypt,
947 true,
948 true,
949 {
950 pub out_data: Tpm2bPublicKeyRsa,
951 }
952}
953
954tpm_struct! {
955 #[derive(Debug, PartialEq, Eq, Clone)]
956 TpmRsaDecryptCommand,
957 TpmCc::RsaDecrypt,
958 false,
959 true,
960 1,
961 {
962 pub cipher_text: Tpm2bPublicKeyRsa,
963 pub in_scheme: TpmtRsaDecrypt,
964 pub label: Tpm2bData,
965 }
966}
967
968tpm_response! {
969 #[derive(Debug, PartialEq, Eq, Clone)]
970 TpmRsaDecryptResponse,
971 TpmCc::RsaDecrypt,
972 false,
973 true,
974 {
975 pub message: Tpm2bPublicKeyRsa,
976 }
977}
978
979tpm_struct! {
980 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
981 TpmEcdhKeyGenCommand,
982 TpmCc::EcdhKeyGen,
983 true,
984 true,
985 1,
986 {}
987}
988
989tpm_response! {
990 #[derive(Debug, PartialEq, Eq, Clone)]
991 TpmEcdhKeyGenResponse,
992 TpmCc::EcdhKeyGen,
993 true,
994 true,
995 {
996 pub z_point: Tpm2bEccPoint,
997 pub pub_point: Tpm2bEccPoint,
998 }
999}
1000
1001tpm_struct! {
1002 #[derive(Debug, PartialEq, Eq, Clone, Copy)]
1003 TpmEcdhZGenCommand,
1004 TpmCc::EcdhZGen,
1005 false,
1006 true,
1007 1,
1008 {
1009 pub in_point: Tpm2bEccPoint,
1010 }
1011}
1012
1013tpm_response! {
1014 #[derive(Debug, PartialEq, Eq, Clone)]
1015 TpmEcdhZGenResponse,
1016 TpmCc::EcdhZGen,
1017 false,
1018 true,
1019 {
1020 pub out_point: Tpm2bEccPoint,
1021 }
1022}
1023
1024tpm_struct! {
1025 #[derive(Debug, PartialEq, Eq, Copy, Clone)]
1026 TpmEccParametersCommand,
1027 TpmCc::EccParameters,
1028 true,
1029 true,
1030 0,
1031 {
1032 pub curve_id: TpmEccCurve,
1033 }
1034}
1035
1036tpm_response! {
1037 #[derive(Debug, PartialEq, Eq, Clone)]
1038 TpmEccParametersResponse,
1039 TpmCc::EccParameters,
1040 true,
1041 true,
1042 {
1043 pub parameters: TpmsAlgorithmDetailEcc,
1044 }
1045}
1046
1047tpm_struct! {
1048 #[derive(Debug, PartialEq, Eq, Clone)]
1049 TpmEncryptDecrypt2Command,
1050 TpmCc::EncryptDecrypt2,
1051 false,
1052 true,
1053 1,
1054 {
1055 pub in_data: Tpm2bMaxBuffer,
1056 pub decrypt: TpmiYesNo,
1057 pub mode: TpmAlgId,
1058 pub iv_in: Tpm2b,
1059 }
1060}
1061
1062tpm_response! {
1063 #[derive(Debug, PartialEq, Eq, Clone)]
1064 TpmEncryptDecrypt2Response,
1065 TpmCc::EncryptDecrypt2,
1066 false,
1067 true,
1068 {
1069 pub out_data: Tpm2bMaxBuffer,
1070 pub iv_out: Tpm2b,
1071 }
1072}
1073
1074tpm_struct! {
1075 #[derive(Debug, PartialEq, Eq, Clone, Copy)]
1076 TpmGetRandomCommand,
1077 TpmCc::GetRandom,
1078 true,
1079 true,
1080 0,
1081 {
1082 pub bytes_requested: u16,
1083 }
1084}
1085
1086tpm_response! {
1087 #[derive(Debug, Default, PartialEq, Eq, Clone)]
1088 TpmGetRandomResponse,
1089 TpmCc::GetRandom,
1090 true,
1091 true,
1092 {
1093 pub random_bytes: Tpm2bDigest,
1094 }
1095}
1096
1097tpm_struct! {
1098 #[derive(Debug, PartialEq, Eq, Clone)]
1099 TpmStirRandomCommand,
1100 TpmCc::StirRandom,
1101 true,
1102 true,
1103 0,
1104 {
1105 pub in_data: Tpm2bSensitiveData,
1106 }
1107}
1108
1109tpm_response! {
1110 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1111 TpmStirRandomResponse,
1112 TpmCc::StirRandom,
1113 true,
1114 true,
1115 {}
1116}
1117
1118tpm_struct! {
1119 #[derive(Debug, PartialEq, Eq, Clone)]
1120 TpmHierarchyControlCommand,
1121 TpmCc::HierarchyControl,
1122 false,
1123 true,
1124 1,
1125 {
1126 pub enable: TpmRh,
1127 pub state: TpmiYesNo,
1128 }
1129}
1130
1131tpm_response! {
1132 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1133 TpmHierarchyControlResponse,
1134 TpmCc::HierarchyControl,
1135 false,
1136 true,
1137 {}
1138}
1139
1140tpm_struct! {
1141 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1142 TpmChangePpsCommand,
1143 TpmCc::ChangePps,
1144 false,
1145 true,
1146 1,
1147 {}
1148}
1149
1150tpm_response! {
1151 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1152 TpmChangePpsResponse,
1153 TpmCc::ChangePps,
1154 false,
1155 true,
1156 {}
1157}
1158
1159tpm_struct! {
1160 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1161 TpmChangeEpsCommand,
1162 TpmCc::ChangeEps,
1163 false,
1164 true,
1165 1,
1166 {}
1167}
1168
1169tpm_response! {
1170 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1171 TpmChangeEpsResponse,
1172 TpmCc::ChangeEps,
1173 false,
1174 true,
1175 {}
1176}
1177
1178tpm_struct! {
1179 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1180 TpmClearCommand,
1181 TpmCc::Clear,
1182 false,
1183 true,
1184 1,
1185 {}
1186}
1187
1188tpm_response! {
1189 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1190 TpmClearResponse,
1191 TpmCc::Clear,
1192 false,
1193 true,
1194 {}
1195}
1196
1197tpm_struct! {
1198 #[derive(Debug, PartialEq, Eq, Clone)]
1199 TpmClearControlCommand,
1200 TpmCc::ClearControl,
1201 false,
1202 true,
1203 1,
1204 {
1205 pub disable: TpmiYesNo,
1206 }
1207}
1208
1209tpm_response! {
1210 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1211 TpmClearControlResponse,
1212 TpmCc::ClearControl,
1213 false,
1214 true,
1215 {}
1216}
1217
1218tpm_struct! {
1219 #[derive(Debug, PartialEq, Eq, Clone)]
1220 TpmHierarchyChangeAuthCommand,
1221 TpmCc::HierarchyChangeAuth,
1222 false,
1223 true,
1224 1,
1225 {
1226 pub new_auth: Tpm2bAuth,
1227 }
1228}
1229
1230tpm_response! {
1231 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
1232 TpmHierarchyChangeAuthResponse,
1233 TpmCc::HierarchyChangeAuth,
1234 false,
1235 true,
1236 {}
1237}
1238
1239tpm_dispatch! {
1240 (TpmNvUndefineSpaceSpecialCommand, TpmNvUndefineSpaceSpecialResponse, NvUndefineSpaceSpecial),
1241 (TpmEvictControlCommand, TpmEvictControlResponse, EvictControl),
1242 (TpmHierarchyControlCommand, TpmHierarchyControlResponse, HierarchyControl),
1243 (TpmNvUndefineSpaceCommand, TpmNvUndefineSpaceResponse, NvUndefineSpace),
1244 (TpmChangeEpsCommand, TpmChangeEpsResponse, ChangeEps),
1245 (TpmChangePpsCommand, TpmChangePpsResponse, ChangePps),
1246 (TpmClearCommand, TpmClearResponse, Clear),
1247 (TpmClearControlCommand, TpmClearControlResponse, ClearControl),
1248 (TpmHierarchyChangeAuthCommand, TpmHierarchyChangeAuthResponse, HierarchyChangeAuth),
1249 (TpmNvDefineSpaceCommand, TpmNvDefineSpaceResponse, NvDefineSpace),
1250 (TpmPcrAllocateCommand, TpmPcrAllocateResponse, PcrAllocate),
1251 (TpmPcrSetAuthPolicyCommand, TpmPcrSetAuthPolicyResponse, PcrSetAuthPolicy),
1252 (TpmSetPrimaryPolicyCommand, TpmSetPrimaryPolicyResponse, SetPrimaryPolicy),
1253 (TpmCreatePrimaryCommand, TpmCreatePrimaryResponse, CreatePrimary),
1254 (TpmNvGlobalWriteLockCommand, TpmNvGlobalWriteLockResponse, NvGlobalWriteLock),
1255 (TpmGetCommandAuditDigestCommand, TpmGetCommandAuditDigestResponse, GetCommandAuditDigest),
1256 (TpmNvIncrementCommand, TpmNvIncrementResponse, NvIncrement),
1257 (TpmNvSetBitsCommand, TpmNvSetBitsResponse, NvSetBits),
1258 (TpmNvExtendCommand, TpmNvExtendResponse, NvExtend),
1259 (TpmNvWriteCommand, TpmNvWriteResponse, NvWrite),
1260 (TpmNvWriteLockCommand, TpmNvWriteLockResponse, NvWriteLock),
1261 (TpmDictionaryAttackLockResetCommand, TpmDictionaryAttackLockResetResponse, DictionaryAttackLockReset),
1262 (TpmNvChangeAuthCommand, TpmNvChangeAuthResponse, NvChangeAuth),
1263 (TpmPcrEventCommand, TpmPcrEventResponse, PcrEvent),
1264 (TpmPcrResetCommand, TpmPcrResetResponse, PcrReset),
1265 (TpmSequenceCompleteCommand, TpmSequenceCompleteResponse, SequenceComplete),
1266 (TpmIncrementalSelfTestCommand, TpmIncrementalSelfTestResponse, IncrementalSelfTest),
1267 (TpmSelfTestCommand, TpmSelfTestResponse, SelfTest),
1268 (TpmStartupCommand, TpmStartupResponse, Startup),
1269 (TpmShutdownCommand, TpmShutdownResponse, Shutdown),
1270 (TpmStirRandomCommand, TpmStirRandomResponse, StirRandom),
1271 (TpmActivateCredentialCommand, TpmActivateCredentialResponse, ActivateCredential),
1272 (TpmCertifyCommand, TpmCertifyResponse, Certify),
1273 (TpmCertifyCreationCommand, TpmCertifyCreationResponse, CertifyCreation),
1274 (TpmDuplicateCommand, TpmDuplicateResponse, Duplicate),
1275 (TpmGetTimeCommand, TpmGetTimeResponse, GetTime),
1276 (TpmGetSessionAuditDigestCommand, TpmGetSessionAuditDigestResponse, GetSessionAuditDigest),
1277 (TpmNvReadCommand, TpmNvReadResponse, NvRead),
1278 (TpmNvReadLockCommand, TpmNvReadLockResponse, NvReadLock),
1279 (TpmObjectChangeAuthCommand, TpmObjectChangeAuthResponse, ObjectChangeAuth),
1280 (TpmPolicySecretCommand, TpmPolicySecretResponse, PolicySecret),
1281 (TpmRewrapCommand, TpmRewrapResponse, Rewrap),
1282 (TpmCreateCommand, TpmCreateResponse, Create),
1283 (TpmEcdhZGenCommand, TpmEcdhZGenResponse, EcdhZGen),
1284 (TpmImportCommand, TpmImportResponse, Import),
1285 (TpmLoadCommand, TpmLoadResponse, Load),
1286 (TpmQuoteCommand, TpmQuoteResponse, Quote),
1287 (TpmRsaDecryptCommand, TpmRsaDecryptResponse, RsaDecrypt),
1288 (TpmSequenceUpdateCommand, TpmSequenceUpdateResponse, SequenceUpdate),
1289 (TpmSignCommand, TpmSignResponse, Sign),
1290 (TpmUnsealCommand, TpmUnsealResponse, Unseal),
1291 (TpmPolicySignedCommand, TpmPolicySignedResponse, PolicySigned),
1292 (TpmContextLoadCommand, TpmContextLoadResponse, ContextLoad),
1293 (TpmContextSaveCommand, TpmContextSaveResponse, ContextSave),
1294 (TpmEcdhKeyGenCommand, TpmEcdhKeyGenResponse, EcdhKeyGen),
1295 (TpmFlushContextCommand, TpmFlushContextResponse, FlushContext),
1296 (TpmLoadExternalCommand, TpmLoadExternalResponse, LoadExternal),
1297 (TpmMakeCredentialCommand, TpmMakeCredentialResponse, MakeCredential),
1298 (TpmNvReadPublicCommand, TpmNvReadPublicResponse, NvReadPublic),
1299 (TpmPolicyAuthValueCommand, TpmPolicyAuthValueResponse, PolicyAuthValue),
1300 (TpmPolicyCommandCodeCommand, TpmPolicyCommandCodeResponse, PolicyCommandCode),
1301 (TpmPolicyCpHashCommand, TpmPolicyCpHashResponse, PolicyCpHash),
1302 (TpmPolicyLocalityCommand, TpmPolicyLocalityResponse, PolicyLocality),
1303 (TpmPolicyOrCommand, TpmPolicyOrResponse, PolicyOr),
1304 (TpmPolicyTicketCommand, TpmPolicyTicketResponse, PolicyTicket),
1305 (TpmReadPublicCommand, TpmReadPublicResponse, ReadPublic),
1306 (TpmRsaEncryptCommand, TpmRsaEncryptResponse, RsaEncrypt),
1307 (TpmStartAuthSessionCommand, TpmStartAuthSessionResponse, StartAuthSession),
1308 (TpmVerifySignatureCommand, TpmVerifySignatureResponse, VerifySignature),
1309 (TpmEccParametersCommand, TpmEccParametersResponse, EccParameters),
1310 (TpmGetCapabilityCommand, TpmGetCapabilityResponse, GetCapability),
1311 (TpmGetRandomCommand, TpmGetRandomResponse, GetRandom),
1312 (TpmGetTestResultCommand, TpmGetTestResultResponse, GetTestResult),
1313 (TpmHashCommand, TpmHashResponse, Hash),
1314 (TpmPcrReadCommand, TpmPcrReadResponse, PcrRead),
1315 (TpmPolicyPcrCommand, TpmPolicyPcrResponse, PolicyPcr),
1316 (TpmPolicyRestartCommand, TpmPolicyRestartResponse, PolicyRestart),
1317 (TpmPcrExtendCommand, TpmPcrExtendResponse, PcrExtend),
1318 (TpmPcrSetAuthValueCommand, TpmPcrSetAuthValueResponse, PcrSetAuthValue),
1319 (TpmNvCertifyCommand, TpmNvCertifyResponse, NvCertify),
1320 (TpmEventSequenceCompleteCommand, TpmEventSequenceCompleteResponse, EventSequenceComplete),
1321 (TpmHashSequenceStartCommand, TpmHashSequenceStartResponse, HashSequenceStart),
1322 (TpmPolicyPhysicalPresenceCommand, TpmPolicyPhysicalPresenceResponse, PolicyPhysicalPresence),
1323 (TpmPolicyGetDigestCommand, TpmPolicyGetDigestResponse, PolicyGetDigest),
1324 (TpmPolicyPasswordCommand, TpmPolicyPasswordResponse, PolicyPassword),
1325 (TpmEncryptDecrypt2Command, TpmEncryptDecrypt2Response, EncryptDecrypt2),
1326 (TpmVendorTcgTestCommand, TpmVendorTcgTestResponse, VendorTcgTest),
1327}