]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Include/Library/TcgStorageCoreLib.h
213140de3265c7bcd1424940b3ba09858f734339
[mirror_edk2.git] / SecurityPkg / Include / Library / TcgStorageCoreLib.h
1 /** @file
2 Public API for the Tcg Core library to perform the lowest level TCG Data encoding.
3
4 (TCG Storage Architecture Core Specification, Version 2.01, Revision 1.00,
5 https://trustedcomputinggroup.org/tcg-storage-architecture-core-specification/)
6
7 Check http://trustedcomputinggroup.org for latest specification updates.
8
9 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 **/
19
20 #ifndef _TCG_CORE_H_
21 #define _TCG_CORE_H_
22
23 #include <IndustryStandard/TcgStorageCore.h>
24
25 #define ERROR_CHECK(arg) \
26 { \
27 TCG_RESULT ret = (arg); \
28 if (ret != TcgResultSuccess) { \
29 DEBUG ((DEBUG_INFO, "ERROR_CHECK failed at %a:%u\n", __FILE__, __LINE__)); \
30 return ret; \
31 } \
32 }
33
34 #define METHOD_STATUS_ERROR_CHECK(arg, failRet) \
35 if ((arg) != TCG_METHOD_STATUS_CODE_SUCCESS) { \
36 DEBUG ((DEBUG_INFO, "Method Status error: 0x%02X (%a)\n", arg, TcgMethodStatusString(arg))); \
37 return (failRet); \
38 }
39
40 #define NULL_CHECK(arg) \
41 do { \
42 if ((arg) == NULL) { \
43 DEBUG ((DEBUG_INFO, "NULL_CHECK(%a) failed at %a:%u\n", #arg, __FILE__, __LINE__)); \
44 return TcgResultFailureNullPointer; \
45 } \
46 } while (0)
47
48 #pragma pack(1)
49
50 /**
51 Tcg result codes.
52
53 The result code indicates if the Tcg function call was successful or not
54 **/
55 typedef enum {
56 //
57 // This is the return result upon successful completion of a Tcg function call
58 //
59 TcgResultSuccess,
60
61 //
62 // This is the return "catchall" result for the failure of a Tcg function call
63 //
64 TcgResultFailure,
65
66 //
67 // This is the return result if a required parameter was Null for a Tcg function call
68 //
69 TcgResultFailureNullPointer,
70
71 //
72 // This is the return result if a required buffersize was 0 for a Tcg function call
73 //
74 TcgResultFailureZeroSize,
75
76 //
77 // This is the return result if a Tcg function call was executed out of order.
78 // For instance, starting a Tcg subpacket before starting its Tcg packet.
79 //
80 TcgResultFailureInvalidAction,
81
82 //
83 // This is the return result if the buffersize provided is not big enough to add a requested Tcg encoded item.
84 //
85 TcgResultFailureBufferTooSmall,
86
87 //
88 // This is the return result for a Tcg parse function if the end of the parsed Buffer is reached, yet Data is still attempted to be retrieved.
89 // For instance, attempting to retrieve another Tcg token from the Buffer after it has reached the end of the Tcg subpacket payload.
90 //
91 TcgResultFailureEndBuffer,
92
93 //
94 // This is the return result for a Tcg parse function if the Tcg Token item requested is not the expected type.
95 // For instance, the caller requested to receive an integer and the Tcg token was a byte sequence.
96 //
97 TcgResultFailureInvalidType,
98 } TCG_RESULT;
99
100 //
101 // Structure that is used to build the Tcg ComPacket. It contains the start Buffer pointer and the current position of the
102 // Tcg ComPacket, current Tcg Packet and Tcg SubPacket. This structure must be initialized
103 // by calling tcgInitTcgCreateStruct before it is used as parameter to any other Tcg function.
104 // This structure should NOT be directly modified by the client of this library.
105 //
106 // NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES
107 // INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY
108 //
109 // tcgInitTcgCreateStruct
110 //
111 typedef struct {
112 //
113 // Buffer allocated and freed by the client of the Tcg library.
114 // This is the Buffer that shall contain the final Tcg encoded compacket.
115 //
116 VOID *Buffer;
117
118 //
119 // Size of the Buffer provided.
120 //
121 UINT32 BufferSize;
122
123 //
124 //Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.
125 //
126 TCG_COM_PACKET *ComPacket;
127
128 //
129 // Current Tcg Packet that is being created. It should point to a location within Buffer.
130 //
131 TCG_PACKET *CurPacket;
132
133 //
134 // Current Tcg SubPacket that is being created. It should point to a location within Buffer.
135 //
136 TCG_SUB_PACKET *CurSubPacket;
137
138 //
139 // Flag used to indicate if the Buffer of the structure should be filled out.
140 // This is intended to be used to support a use-case where the client of library
141 // can perform all the desired tcg calls to determine what the actual Size of the final compacket will be.
142 // Then the client can allocate the required Buffer Size and re-run the tcg calls.
143 // THIS MAY NOT BE IMPLEMENTED... REQUIRES MORE THOUGHT BECAUSE YOU CANNOT SOLVE ISSUE FOR RECEIVE
144 //
145 BOOLEAN DryRun;
146 } TCG_CREATE_STRUCT;
147
148 //
149 // Structure that is used to parse the Tcg response received. It contains the response Buffer pointer
150 // and the current position of the Tcg ComPacket, current Tcg Packet and Tcg SubPacket being parsed.
151 // This structure must be initialized by calling tcgInitTcgParseStruct before it is used as parameter to any other Tcg parse function.
152 // This structure should NOT be directly modified by the client of this library.
153 //
154 // NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES
155 // INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY
156 //
157 // @sa tcgInitTcgParseStruct
158 //
159 typedef struct {
160 //
161 // Buffer allocated and freed by the client of the Tcg library.
162 // This is the Buffer that contains the Tcg response to decode/parse.
163 //
164 const VOID* Buffer;
165
166 //
167 //Size of the Buffer provided.
168 //
169 UINT32 BufferSize;
170
171 //
172 // Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.
173 //
174 TCG_COM_PACKET *ComPacket;
175
176 //
177 // Current Tcg Packet that is being created. It should point to a location within Buffer.
178 //
179 TCG_PACKET *CurPacket;
180
181 //
182 // Current Tcg SubPacket that is being created. It should point to a location within Buffer.
183 //
184 TCG_SUB_PACKET *CurSubPacket;
185
186 //
187 // Current pointer within the current subpacket payload.
188 //
189 UINT8 *CurPtr;
190 } TCG_PARSE_STRUCT ;
191
192
193 //
194 // Structure that is used to represent a Tcg Token that is retrieved by Tcg parse functions.
195 //
196 typedef struct {
197 //
198 // Describes the type of Tcg token the Hdr start points to.
199 //
200 TCG_TOKEN_TYPE Type;
201
202 //
203 // Pointer to the beginning of the Header of the Tcg token
204 //
205 UINT8 *HdrStart;
206 } TCG_TOKEN ;
207
208 /**
209
210 Required to be called before calling any other Tcg functions with the TCG_CREATE_STRUCT.
211 Initializes the packet variables to NULL. Additionally, the buffer will be memset.
212
213 @param[in/out] CreateStruct Structure to initialize
214 @param[in] Buffer Buffer allocated by client of library. It will contain the Tcg encoded packet. This cannot be null.
215 @param[in] BufferSize Size of buffer provided. It cannot be 0.
216
217 **/
218 TCG_RESULT
219 EFIAPI
220 TcgInitTcgCreateStruct(
221 TCG_CREATE_STRUCT *CreateStruct,
222 VOID *Buffer,
223 UINT32 BufferSize
224 );
225
226
227 /**
228
229 Encodes the ComPacket header to the data structure.
230
231 @param[in/out] CreateStruct Structure to initialize
232 @param[in] ComId ComID of the Tcg ComPacket.
233 @param[in] ComIdExtension ComID Extension of the Tcg ComPacket.
234
235 **/
236 TCG_RESULT
237 EFIAPI
238 TcgStartComPacket(
239 TCG_CREATE_STRUCT *CreateStruct,
240 UINT16 ComId,
241 UINT16 ComIdExtension
242 );
243
244
245 /**
246
247 Starts a new ComPacket in the Data structure.
248
249 @param[in/out] CreateStruct Structure used to add Tcg Packet
250 @param[in] Tsn Packet Tper session number
251 @param[in] Hsn Packet Host session number
252 @param[in] SeqNumber Packet Sequence Number
253 @param[in] AckType Packet Acknowledge Type
254 @param[in] Ack Packet Acknowledge
255
256 **/
257 TCG_RESULT
258 EFIAPI
259 TcgStartPacket(
260 TCG_CREATE_STRUCT *CreateStruct,
261 UINT32 Tsn,
262 UINT32 Hsn,
263 UINT32 SeqNumber,
264 UINT16 AckType,
265 UINT32 Ack
266 );
267
268 /**
269
270 Starts a new SubPacket in the Data structure.
271
272 @param[in/out] CreateStruct Structure used to start Tcg SubPacket
273 @param[in] Kind SubPacket kind
274
275 **/
276 TCG_RESULT
277 EFIAPI
278 TcgStartSubPacket(
279 TCG_CREATE_STRUCT *CreateStruct,
280 UINT16 Kind
281 );
282
283
284 /**
285
286 Ends the current SubPacket in the Data structure. This function will also perform the 4-byte padding
287 required for Subpackets.
288
289 @param[in/out] CreateStruct Structure used to end the current Tcg SubPacket
290
291 **/
292 TCG_RESULT
293 EFIAPI
294 TcgEndSubPacket(
295 TCG_CREATE_STRUCT *CreateStruct
296 );
297
298
299 /**
300
301 Ends the current Packet in the Data structure.
302
303 @param[in/out] CreateStruct Structure used to end the current Tcg Packet
304
305 **/
306 TCG_RESULT
307 EFIAPI
308 TcgEndPacket(
309 TCG_CREATE_STRUCT *CreateStruct
310 );
311
312
313 /**
314
315 Ends the ComPacket in the Data structure and ret
316
317 @param[in/out] CreateStruct Structure used to end the Tcg ComPacket
318 @param[in/out] Size Describes the Size of the entire ComPacket (Header and payload). Filled out by function.
319
320 **/
321 TCG_RESULT
322 EFIAPI
323 TcgEndComPacket(
324 TCG_CREATE_STRUCT *CreateStruct,
325 UINT32 *Size
326 );
327
328 /**
329 Adds a single raw token byte to the Data structure.
330
331 @param[in/out] CreateStruct Structure used to add the byte
332 @param [in] Byte Byte to add
333
334 **/
335 TCG_RESULT
336 EFIAPI
337 TcgAddRawByte(
338 TCG_CREATE_STRUCT *CreateStruct,
339 UINT8 Byte
340 );
341
342
343 /**
344
345 Adds the Data parameter as a byte sequence to the Data structure.
346
347 @param [in/out] CreateStruct Structure used to add the byte sequence
348 @param[in] Data Byte sequence that will be encoded and copied into Data structure
349 @param[in] DataSize Length of Data provided
350 @param[in] Continued TRUE if byte sequence is continued or
351 FALSE if the Data contains the entire byte sequence to be encoded
352
353 **/
354 TCG_RESULT
355 EFIAPI
356 TcgAddByteSequence(
357 TCG_CREATE_STRUCT *CreateStruct,
358 const VOID *Data,
359 UINT32 DataSize,
360 BOOLEAN Continued
361 );
362
363
364 /**
365
366 Adds an arbitrary-Length integer to the Data structure.
367
368 The integer will be encoded using the shortest possible atom.
369
370 @param[in/out] CreateStruct Structure used to add the integer
371 @param[in] Data Integer in host byte order that will be encoded and copied into Data structure
372 @param[in] DataSize Length in bytes of the Data provided
373 @param[in] SignedInteger TRUE if the integer is signed or FALSE if the integer is unsigned
374
375 **/
376 TCG_RESULT
377 EFIAPI
378 TcgAddInteger(
379 TCG_CREATE_STRUCT *CreateStruct,
380 const VOID *Data,
381 UINT32 DataSize,
382 BOOLEAN SignedInteger
383 );
384
385
386 /**
387 Adds an 8-bit unsigned integer to the Data structure.
388
389 @param[in/out] CreateStruct Structure used to add the integer
390 @param[in] Value Integer Value to add
391
392 **/
393 TCG_RESULT
394 EFIAPI
395 TcgAddUINT8(
396 TCG_CREATE_STRUCT *CreateStruct,
397 UINT8 Value
398 );
399
400 /**
401
402 Adds a 16-bit unsigned integer to the Data structure.
403
404 @param[in/out] CreateStruct Structure used to add the integer
405 @param[in] Value Integer Value to add
406
407 **/
408 TCG_RESULT
409 EFIAPI
410 TcgAddUINT16 (
411 TCG_CREATE_STRUCT *CreateStruct,
412 UINT16 Value
413 );
414
415 /**
416
417 Adds a 32-bit unsigned integer to the Data structure.
418
419 @param[in/out] CreateStruct Structure used to add the integer
420 @param[in] Value Integer Value to add
421
422 **/
423 TCG_RESULT
424 EFIAPI
425 TcgAddUINT32(
426 TCG_CREATE_STRUCT *CreateStruct,
427 UINT32 Value
428 );
429
430
431 /**
432
433 Adds a 64-bit unsigned integer to the Data structure.
434
435 @param[in/out] CreateStruct Structure used to add the integer
436 @param[in] Value Integer Value to add
437
438 **/
439 TCG_RESULT
440 EFIAPI
441 TcgAddUINT64(
442 TCG_CREATE_STRUCT *CreateStruct,
443 UINT64 Value
444 );
445
446 /**
447 Adds a BOOLEAN to the Data structure.
448
449 @param[in/out] CreateStruct Structure used to add the integer
450 @param[in] Value BOOLEAN Value to add
451
452 **/
453 TCG_RESULT
454 EFIAPI
455 TcgAddBOOLEAN(
456 TCG_CREATE_STRUCT *CreateStruct,
457 BOOLEAN Value
458 );
459
460 /**
461 Add tcg uid info.
462
463 @param [in/out] CreateStruct Structure used to add the integer
464 @param Uid Input uid info.
465
466 @retval return the action result.
467
468 **/
469 TCG_RESULT
470 EFIAPI
471 TcgAddTcgUid(
472 TCG_CREATE_STRUCT *CreateStruct,
473 TCG_UID Uid
474 );
475
476 /**
477 Adds a Start List token to the Data structure.
478
479 @param[in/out] CreateStruct Structure used to add the token
480
481 **/
482 TCG_RESULT
483 EFIAPI
484 TcgAddStartList(
485 TCG_CREATE_STRUCT *CreateStruct
486 );
487
488
489 /**
490
491 Adds an End List token to the Data structure.
492
493 @param [in/out] CreateStruct Structure used to add the token
494
495 **/
496 TCG_RESULT
497 EFIAPI
498 TcgAddEndList(
499 TCG_CREATE_STRUCT *CreateStruct
500 );
501
502
503 /**
504 Adds a Start Name token to the Data structure.
505
506 @param[in/out] CreateStruct Structure used to add the token
507
508 **/
509 TCG_RESULT
510 EFIAPI
511 TcgAddStartName(
512 TCG_CREATE_STRUCT *CreateStruct
513 );
514
515
516 /**
517
518 Adds an End Name token to the Data structure.
519
520 @param [in/out] CreateStruct Structure used to add the token
521
522 **/
523 TCG_RESULT
524 EFIAPI
525 TcgAddEndName(
526 TCG_CREATE_STRUCT *CreateStruct
527 );
528
529
530 /**
531 Adds a Call token to the Data structure.
532
533 @param [in/out] CreateStruct Structure used to add the token
534
535 **/
536 TCG_RESULT
537 EFIAPI
538 TcgAddCall(
539 TCG_CREATE_STRUCT *CreateStruct
540 );
541
542
543 /**
544
545 Adds an End of Data token to the Data structure.
546
547 @param[in/out] CreateStruct Structure used to add the token
548
549 **/
550 TCG_RESULT
551 EFIAPI
552 TcgAddEndOfData(
553 TCG_CREATE_STRUCT *CreateStruct
554 );
555
556
557 /**
558
559 Adds an End of Session token to the Data structure.
560
561 @param [in/out] CreateStruct Structure used to add the token
562
563 **/
564 TCG_RESULT
565 EFIAPI
566 TcgAddEndOfSession(
567 TCG_CREATE_STRUCT *CreateStruct
568 );
569
570
571 /**
572 Adds a Start Transaction token to the Data structure.
573
574 @param [in/out] CreateStruct Structure used to add the token
575
576 **/
577 TCG_RESULT
578 EFIAPI
579 TcgAddStartTransaction(
580 TCG_CREATE_STRUCT *CreateStruct
581 );
582
583
584 /**
585 Adds an End Transaction token to the Data structure.
586
587 @param[in/out] CreateStruct Structure used to add the token
588
589 **/
590 TCG_RESULT
591 EFIAPI
592 TcgAddEndTransaction(
593 TCG_CREATE_STRUCT *CreateStruct
594 );
595
596 /**
597 Initial the tcg parse stucture.
598
599 @param ParseStruct Input parse structure.
600 @param Buffer Input buffer data.
601 @param BufferSize Input buffer size.
602
603 @retval return the action result.
604
605 **/
606 TCG_RESULT
607 EFIAPI
608 TcgInitTcgParseStruct(
609 TCG_PARSE_STRUCT *ParseStruct,
610 const VOID *Buffer,
611 UINT32 BufferSize
612 );
613
614 /**
615 Get next token info.
616
617 @param ParseStruct Input parse structure info.
618 @param TcgToken return the tcg token info.
619
620 @retval return the action result.
621
622 **/
623 TCG_RESULT
624 EFIAPI
625 TcgGetNextToken(
626 TCG_PARSE_STRUCT *ParseStruct,
627 TCG_TOKEN *TcgToken
628 );
629
630 /**
631 Get next token Type.
632
633 @param ParseStruct Input parse structure.
634 @param Type Input the type need to check.
635
636 @retval return the action result.
637
638 **/
639 TCG_RESULT
640 EFIAPI
641 TcgGetNextTokenType(
642 TCG_PARSE_STRUCT *ParseStruct,
643 TCG_TOKEN_TYPE Type
644 );
645
646 /**
647 Get atom info.
648
649 @param TcgToken Input token info.
650 @param HeaderLength return the header length.
651 @param DataLength return the data length.
652 @param ByteOrInt return the atom Type.
653 @param SignOrCont return the sign or count info.
654
655 @retval return the action result.
656
657 **/
658 TCG_RESULT
659 EFIAPI
660 TcgGetAtomInfo(
661 const TCG_TOKEN *TcgToken,
662 UINT32 *HeaderLength,
663 UINT32 *DataLength,
664 UINT8 *ByteOrInt,
665 UINT8 *SignOrCont
666 );
667
668 /**
669 Get token byte sequence.
670
671 @param TcgToken Input token info.
672 @param Length Input the length info.
673
674 @retval Return the value data.
675
676 **/
677 UINT8*
678 EFIAPI
679 TcgGetTokenByteSequence(
680 const TCG_TOKEN *TcgToken,
681 UINT32 *Length
682 );
683
684 /**
685 Get token specified value.
686
687 @param TcgToken Input token info.
688 @param Value return the value.
689
690 @retval return the action result.
691
692 **/
693 TCG_RESULT
694 EFIAPI
695 TcgGetTokenUINT64(
696 const TCG_TOKEN *TcgToken,
697 UINT64 *Value
698 );
699
700
701 /**
702 Get next specify value.
703
704 @param ParseStruct Input parse structure.
705 @param Value Return vlaue.
706
707 @retval return the action result.
708
709 **/
710 TCG_RESULT
711 EFIAPI
712 TcgGetNextUINT8(
713 TCG_PARSE_STRUCT *ParseStruct,
714 UINT8 *Value
715 );
716
717
718 /**
719 Get next specify value.
720
721 @param ParseStruct Input parse structure.
722 @param Value Return vlaue.
723
724 @retval return the action result.
725
726 **/
727 TCG_RESULT
728 EFIAPI
729 TcgGetNextUINT16(
730 TCG_PARSE_STRUCT *ParseStruct,
731 UINT16 *Value
732 );
733
734 /**
735 Get next specify value.
736
737 @param ParseStruct Input parse structure.
738 @param Value Return vlaue.
739
740 @retval return the action result.
741
742 **/
743 TCG_RESULT
744 EFIAPI
745 TcgGetNextUINT32(
746 TCG_PARSE_STRUCT *ParseStruct,
747 UINT32 *Value
748 );
749
750 /**
751 Get next specify value.
752
753 @param ParseStruct Input parse structure.
754 @param Value Return vlaue.
755
756 @retval return the action result.
757
758 **/
759 TCG_RESULT
760 EFIAPI
761 TcgGetNextUINT64(
762 TCG_PARSE_STRUCT *ParseStruct,
763 UINT64 *Value
764 );
765
766 /**
767 Get next specify value.
768
769 @param ParseStruct Input parse structure.
770 @param Value Return vlaue.
771
772 @retval return the action result.
773
774 **/
775 TCG_RESULT
776 EFIAPI
777 TcgGetNextBOOLEAN(
778 TCG_PARSE_STRUCT *ParseStruct,
779 BOOLEAN *Value
780 );
781
782 /**
783 Get next tcg uid info.
784
785 @param ParseStruct Input parse structure.
786 @param Uid Get the uid info.
787
788 @retval return the action result.
789
790 **/
791 TCG_RESULT
792 EFIAPI
793 TcgGetNextTcgUid(
794 TCG_PARSE_STRUCT *ParseStruct,
795 TCG_UID *Uid
796 );
797
798 /**
799 Get next byte sequence.
800
801 @param ParseStruct Input parse structure.
802 @param Data return the data.
803 @param Length return the length.
804
805 @retval return the action result.
806
807 **/
808 TCG_RESULT
809 EFIAPI
810 TcgGetNextByteSequence(
811 TCG_PARSE_STRUCT *ParseStruct,
812 const VOID **Data,
813 UINT32 *Length
814 );
815
816 /**
817 Get next start list.
818
819 @param ParseStruct Input parse structure.
820
821 @retval return the action result.
822
823 **/
824 TCG_RESULT
825 EFIAPI
826 TcgGetNextStartList(
827 TCG_PARSE_STRUCT *ParseStruct
828 );
829
830 /**
831 Get next end list.
832
833 @param ParseStruct Input parse structure.
834
835 @retval return the action result.
836
837 **/
838 TCG_RESULT
839 EFIAPI
840 TcgGetNextEndList(
841 TCG_PARSE_STRUCT *ParseStruct
842 );
843
844 /**
845 Get next start name.
846
847 @param ParseStruct Input parse structure.
848
849 @retval return the action result.
850
851 **/
852 TCG_RESULT
853 EFIAPI
854 TcgGetNextStartName(
855 TCG_PARSE_STRUCT *ParseStruct
856 );
857
858 /**
859 Get next end name.
860
861 @param ParseStruct Input parse structure.
862
863 @retval return the action result.
864
865 **/
866 TCG_RESULT
867 EFIAPI
868 TcgGetNextEndName(
869 TCG_PARSE_STRUCT *ParseStruct
870 );
871
872 /**
873 Get next call.
874
875 @param ParseStruct Input parse structure.
876
877 @retval return the action result.
878
879 **/
880 TCG_RESULT
881 EFIAPI
882 TcgGetNextCall(
883 TCG_PARSE_STRUCT *ParseStruct
884 );
885
886 /**
887 Get next end data.
888
889 @param ParseStruct Input parse structure.
890
891 @retval return the action result.
892
893 **/
894 TCG_RESULT
895 EFIAPI
896 TcgGetNextEndOfData(
897 TCG_PARSE_STRUCT *ParseStruct
898 );
899
900 /**
901 Get next end of session.
902
903 @param ParseStruct Input parse structure.
904
905 @retval return the action result.
906
907 **/
908 TCG_RESULT
909 EFIAPI
910 TcgGetNextEndOfSession(
911 TCG_PARSE_STRUCT *ParseStruct
912 );
913
914 /**
915 Get next start transaction.
916
917 @param ParseStruct Input parse structure.
918
919 @retval return the action result.
920
921 **/
922 TCG_RESULT
923 EFIAPI
924 TcgGetNextStartTransaction(
925 TCG_PARSE_STRUCT *ParseStruct
926 );
927
928 /**
929 Get next end transaction.
930
931 @param ParseStruct Input parse structure.
932
933 @retval return the action result.
934
935 **/
936 TCG_RESULT
937 EFIAPI
938 TcgGetNextEndTransaction(
939 TCG_PARSE_STRUCT *ParseStruct
940 );
941
942 // end of parse functions
943
944
945 typedef
946 BOOLEAN
947 (EFIAPI* TCG_LEVEL0_ENUM_CALLBACK) (
948 const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
949 TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature,
950 UINTN FeatureSize, // includes header
951 VOID *Context
952 );
953
954 /**
955 Adds call token and method Header (invoking id, and method id).
956
957 @param CreateStruct The input create structure.
958 @param InvokingId Invoking id.
959 @param MethodId Method id.
960
961 **/
962 TCG_RESULT
963 EFIAPI
964 TcgStartMethodCall(
965 TCG_CREATE_STRUCT *CreateStruct,
966 TCG_UID InvokingId,
967 TCG_UID MethodId
968 );
969
970 /**
971 Adds START LIST token.
972
973 @param CreateStruct The input create structure.
974
975 **/
976 TCG_RESULT
977 EFIAPI
978 TcgStartParameters(
979 TCG_CREATE_STRUCT *CreateStruct
980 );
981
982 /**
983 Adds END LIST token.
984
985 @param CreateStruct The input create structure.
986
987 **/
988 TCG_RESULT
989 EFIAPI
990 TcgEndParameters(
991 TCG_CREATE_STRUCT *CreateStruct
992 );
993
994 /**
995 Adds END Data token and method list.
996
997 @param CreateStruct The input create structure.
998
999 **/
1000 TCG_RESULT
1001 EFIAPI
1002 TcgEndMethodCall(
1003 TCG_CREATE_STRUCT *CreateStruct
1004 );
1005
1006 /**
1007
1008 Adds Start Session call to the data structure. This creates the entire ComPacket structure and
1009 returns the size of the entire compacket in the size parameter.
1010
1011 @param [in/out] CreateStruct Structure used to add the start session call
1012 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
1013 @param [in] ComId ComID for the ComPacket
1014 @param [in] ComIdExtension Extended ComID for the ComPacket
1015 @param [in] HostSessionId Host Session ID
1016 @param [in] SpId Security Provider to start session with
1017 @param [in] Write Write option for start session. TRUE = start session requests write access
1018 @param [in] HostChallengeLength Length of the host challenge. Length should be 0 if hostChallenge is NULL
1019 @param [in] HostChallenge Host challenge for Host Signing Authority. If NULL, then no Host Challenge shall be sent.
1020 @param [in] HostSigningAuthority Host Signing Authority used for start session. If NULL, then no Host Signing Authority shall be sent.
1021
1022 **/
1023 TCG_RESULT
1024 EFIAPI
1025 TcgCreateStartSession(
1026 TCG_CREATE_STRUCT *CreateStruct,
1027 UINT32 *Size,
1028 UINT16 ComId,
1029 UINT16 ComIdExtension,
1030 UINT32 HostSessionId,
1031 TCG_UID SpId,
1032 BOOLEAN Write,
1033 UINT32 HostChallengeLength,
1034 const VOID *HostChallenge,
1035 TCG_UID HostSigningAuthority
1036 );
1037
1038 /**
1039 Creates ComPacket with a Method call that sets the PIN column for the row specified.
1040 This assumes a start session has already been opened with the desired SP.
1041
1042 @param [in/out] CreateStruct Structure used to add method call.
1043 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
1044 @param [in] ComId ComID for the ComPacket
1045 @param [in] ComIdExtension Extended ComID for the ComPacket
1046 @param [in] TperSession Tper Session ID for the Packet
1047 @param [in] HostSession Host Session ID for the Packet
1048 @param [in] SidRow UID of row of current SP to set PIN column
1049 @param [in] Password value of PIN to set
1050 @param [in] PasswordSize Size of PIN
1051
1052 **/
1053 TCG_RESULT
1054 EFIAPI
1055 TcgCreateSetCPin(
1056 TCG_CREATE_STRUCT *CreateStruct,
1057 UINT32 *Size,
1058 UINT16 ComId,
1059 UINT16 ComIdExtension,
1060 UINT32 TperSession,
1061 UINT32 HostSession,
1062 TCG_UID SidRow,
1063 const VOID *Password,
1064 UINT32 PasswordSize
1065 );
1066
1067 /**
1068 Creates ComPacket with a Method call that sets the "Enabled" column for the row specified using the value specified.
1069 This assumes a start session has already been opened with the desired SP.
1070
1071 @param [in/out] CreateStruct Structure used to add method call
1072 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
1073 @param [in] ComId ComID for the ComPacket
1074 @param [in] ComIdExtension Extended ComID for the ComPacket
1075 @param [in] TperSession Tper Session ID for the Packet
1076 @param [in] HostSession Host Session ID for the Packet
1077 @param [in] AuthorityUid Authority UID to modify the "Enabled" column for
1078 @param [in] Enabled Value to set the "Enabled" column to
1079
1080 **/
1081 TCG_RESULT
1082 EFIAPI
1083 TcgSetAuthorityEnabled(
1084 TCG_CREATE_STRUCT *CreateStruct,
1085 UINT32 *Size,
1086 UINT16 ComId,
1087 UINT16 ComIdExtension,
1088 UINT32 TperSession,
1089 UINT32 HostSession,
1090 TCG_UID AuthorityUid,
1091 BOOLEAN Enabled
1092 );
1093
1094 /**
1095
1096 Creates ComPacket with EndSession.
1097 This assumes a start session has already been opened.
1098
1099 @param [in/out] CreateStruct Structure used to add Endsession
1100 @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.
1101 @param [in] ComId ComID for the ComPacket
1102 @param [in] ComIdExtension Extended ComID for the ComPacket
1103 @param [in] HostSessionId Host Session ID for the Packet
1104 @param [in] TpSessionId Tper Session ID for the Packet
1105
1106 **/
1107 TCG_RESULT
1108 EFIAPI
1109 TcgCreateEndSession(
1110 TCG_CREATE_STRUCT *CreateStruct,
1111 UINT32 *Size,
1112 UINT16 ComId,
1113 UINT16 ComIdExtension,
1114 UINT32 HostSessionId,
1115 UINT32 TpSessionId
1116 );
1117
1118
1119 /**
1120
1121 Retrieves human-readable token type name.
1122
1123 @param[in] Type Token type to retrieve
1124
1125 **/
1126 CHAR8*
1127 EFIAPI
1128 TcgTokenTypeString(
1129 TCG_TOKEN_TYPE Type
1130 );
1131
1132 /**
1133 Returns the method status of the current subpacket. Does not affect the current position
1134 in the ComPacket. In other words, it can be called whenever you have a valid SubPacket.
1135
1136 @param [in/out] ParseStruct Structure used to parse received TCG response
1137 @param [in/out] MethodStatus Method status retrieved of the current SubPacket
1138
1139 **/
1140 TCG_RESULT
1141 EFIAPI
1142 TcgGetMethodStatus(
1143 const TCG_PARSE_STRUCT *ParseStruct,
1144 UINT8 *MethodStatus
1145 );
1146
1147 /**
1148 Returns a human-readable string representing a method status return code.
1149
1150 @param[in] MethodStatus Method status to translate to a string
1151
1152
1153 @retval return the string info.
1154 **/
1155 CHAR8*
1156 EFIAPI
1157 TcgMethodStatusString(
1158 UINT8 MethodStatus
1159 );
1160
1161
1162 /**
1163 Retrieves the comID and Extended comID of the ComPacket in the Tcg response.
1164 It is intended to be used to confirm the received Tcg response is intended for user that received it.
1165
1166 @param [in] ParseStruct Structure used to parse received TCG response.
1167 @param [in/out] ComId comID retrieved from received ComPacket.
1168 @param [in/out] ComIdExtension Extended comID retrieved from received ComPacket
1169
1170 **/
1171 TCG_RESULT
1172 EFIAPI
1173 TcgGetComIds(
1174 const TCG_PARSE_STRUCT *ParseStruct,
1175 UINT16 *ComId,
1176 UINT16 *ComIdExtension
1177 );
1178
1179 /**
1180 Checks if the ComIDs of the response match the expected values.
1181
1182 @param[in] ParseStruct Structure used to parse received TCG response
1183 @param[in] ExpectedComId Expected comID
1184 @param[in] ExpectedComIdExtension Expected extended comID
1185
1186 **/
1187 TCG_RESULT
1188 EFIAPI
1189 TcgCheckComIds(
1190 const TCG_PARSE_STRUCT *ParseStruct,
1191 UINT16 ExpectedComId,
1192 UINT16 ExpectedComIdExtension
1193 );
1194
1195 /**
1196 Parses the Sync Session response contained in the parseStruct to retrieve Tper session ID. If the Sync Session response
1197 parameters do not match the comID, extended ComID and host session ID then a failure is returned.
1198
1199 @param[in/out] ParseStruct Structure used to parse received TCG response, contains Sync Session response.
1200 @param[in] ComId Expected ComID that is compared to actual ComID of response
1201 @param[in] ComIdExtension Expected Extended ComID that is compared to actual Extended ComID of response
1202 @param[in] HostSessionId Expected Host Session ID that is compared to actual Host Session ID of response
1203 @param[in/out] TperSessionId Tper Session ID retrieved from the Sync Session response.
1204
1205 **/
1206 TCG_RESULT
1207 EFIAPI
1208 TcgParseSyncSession(
1209 const TCG_PARSE_STRUCT *ParseStruct,
1210 UINT16 ComId,
1211 UINT16 ComIdExtension,
1212 UINT32 HostSessionId,
1213 UINT32 *TperSessionId
1214 );
1215
1216 /**
1217 Create set ace.
1218
1219 @param CreateStruct Input create structure.
1220 @param Size size info.
1221 @param ComId ComId info.
1222 @param ComIdExtension ComId extension info.
1223 @param TperSession Tper session data.
1224 @param HostSession Host session data.
1225 @param AceRow Ace row info.
1226 @param Authority1 Authority 1 info.
1227 @param LogicalOperator Logiccal operator info.
1228 @param Authority2 Authority 2 info.
1229
1230 @retval Return the action result.
1231
1232 **/
1233 TCG_RESULT
1234 EFIAPI
1235 TcgCreateSetAce(
1236 TCG_CREATE_STRUCT *CreateStruct,
1237 UINT32 *Size,
1238 UINT16 ComId,
1239 UINT16 ComIdExtension,
1240 UINT32 TperSession,
1241 UINT32 HostSession,
1242 TCG_UID AceRow,
1243 TCG_UID Authority1,
1244 BOOLEAN LogicalOperator,
1245 TCG_UID Authority2
1246 );
1247
1248 /**
1249 Enum level 0 discovery.
1250
1251 @param DiscoveryHeader Discovery header.
1252 @param Callback Callback function.
1253 @param Context The context for the function.
1254
1255 @retval return true if the callback return TRUE, else return FALSE.
1256
1257 **/
1258 BOOLEAN
1259 EFIAPI
1260 TcgEnumLevel0Discovery(
1261 const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
1262 TCG_LEVEL0_ENUM_CALLBACK Callback,
1263 VOID *Context
1264 );
1265
1266 /**
1267 Get Feature code from the header.
1268
1269 @param DiscoveryHeader The discovery header.
1270 @param FeatureCode reutrn the Feature code.
1271 @param FeatureSize return the Feature size.
1272
1273 @retval return the Feature code data.
1274 **/
1275 TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER*
1276 EFIAPI
1277 TcgGetFeature(
1278 const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,
1279 UINT16 FeatureCode,
1280 UINTN *FeatureSize
1281 );
1282
1283 /**
1284 Determines if the protocol provided is part of the provided supported protocol list.
1285
1286 @param[in] ProtocolList Supported protocol list to investigate
1287 @param[in] Protocol Protocol value to determine if supported
1288
1289 @return TRUE = protocol is supported, FALSE = protocol is not supported
1290 **/
1291 BOOLEAN
1292 EFIAPI
1293 TcgIsProtocolSupported(
1294 const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList,
1295 UINT16 Protocol
1296 );
1297
1298 /**
1299 Determines if the Locking Feature "Locked" bit is set in the level 0 discovery response.
1300
1301 @param[in] Discovery Level 0 discovery response
1302
1303 @return TRUE = Locked is set, FALSE = Locked is false
1304
1305 **/
1306 BOOLEAN
1307 EFIAPI
1308 TcgIsLocked(
1309 const TCG_LEVEL0_DISCOVERY_HEADER *Discovery
1310 );
1311
1312 #pragma pack()
1313
1314
1315 #endif // _TCG_CORE_H_