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