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