Skip to content

Commit

Permalink
tdx module attributes type update
Browse files Browse the repository at this point in the history
  • Loading branch information
preston4896 committed Feb 11, 2025
1 parent a621d5b commit 5db93be
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions contracts/bases/TDXModuleBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ abstract contract TDXModuleBase {
function checkTdxModule(
bytes memory mrsignerSeam,
bytes memory expectedMrsignerSeam,
bytes8 seamAttributes,
bytes8 expectedSeamAttributes
uint64 seamAttributes,
uint64 expectedSeamAttributes
) internal pure returns (bool) {
return mrsignerSeam.equals(expectedMrsignerSeam) && seamAttributes == expectedSeamAttributes;
}
Expand Down
7 changes: 4 additions & 3 deletions contracts/bases/tcb/TCBInfoV3Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TDXModuleIdentity,
TDXModuleTCBLevelsObj
} from "@automata-network/on-chain-pccs/helpers/FmspcTcbHelper.sol";
import {BELE} from "../../utils/BELE.sol";
import "./TCBInfoV2Base.sol";

abstract contract TCBInfoV3Base is TCBInfoV2Base {
Expand Down Expand Up @@ -60,12 +61,12 @@ abstract contract TCBInfoV3Base is TCBInfoV2Base {
function checkTdxModuleTcbStatus(bytes16 teeTcbSvn, TDXModuleIdentity[] memory tdxModuleIdentities)
internal
pure
returns (bool, TCBStatus, uint8, bytes memory, bytes8)
returns (bool, TCBStatus, uint8, bytes memory, uint64)
{
uint8 tdxModuleIsvSvn = uint8(teeTcbSvn[0]);
uint8 tdxModuleVersion = uint8(teeTcbSvn[1]);
bytes memory expectedMrSignerSeam;
bytes8 expectedSeamAttributes;
uint64 expectedSeamAttributes;

if (tdxModuleVersion == 0) {
return (true, TCBStatus.OK, tdxModuleVersion, expectedMrSignerSeam, expectedSeamAttributes);
Expand All @@ -87,7 +88,7 @@ abstract contract TCBInfoV3Base is TCBInfoV2Base {
tdxModuleIdentityFound = true;
moduleStatus = tdxModuleTcbLevels[j].status;
expectedMrSignerSeam = currId.mrsigner;
expectedSeamAttributes = currId.attributes;
expectedSeamAttributes = uint64(BELE.leBytesToBeUint(abi.encodePacked(currId.attributes)));
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/types/CommonStruct.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ struct PCKCertTCB {
}

struct Output {
uint16 quoteVersion; // BE
bytes4 tee; // BE
uint16 quoteVersion; // BE (we should change this)
bytes4 tee; // BE (we should change this)
TCBStatus tcbStatus;
bytes6 fmspcBytes;
bytes quoteBody;
Expand Down
6 changes: 3 additions & 3 deletions contracts/types/V4Structs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ struct TD10ReportBody {
bytes16 teeTcbSvn;
bytes mrSeam; // 48 bytes
bytes mrsignerSeam; // 48 bytes
bytes8 seamAttributes;
bytes8 tdAttributes;
bytes8 xFAM;
uint64 seamAttributes;
uint64 tdAttributes;
uint64 xFAM;
bytes mrTd; // 48 bytes
bytes mrConfigId; // 48 bytes
bytes mrOwner; // 48 bytes
Expand Down
8 changes: 4 additions & 4 deletions contracts/verifiers/V4QuoteVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ contract V4QuoteVerifier is QuoteVerifierBase, TCBInfoV3Base, TDXModuleBase {
TCBStatus tdxModuleStatus;
uint8 tdxModuleVersion;
bytes memory expectedMrSignerSeam;
bytes8 expectedSeamAttributes;
uint64 expectedSeamAttributes;
(success, tdxModuleStatus, tdxModuleVersion, expectedMrSignerSeam, expectedSeamAttributes) =
checkTdxModuleTcbStatus(quote.reportBody.teeTcbSvn, ret.tdxModuleIdentities);
if (!success || tdxModuleStatus == TCBStatus.TCB_REVOKED) {
Expand Down Expand Up @@ -308,9 +308,9 @@ contract V4QuoteVerifier is QuoteVerifierBase, TCBInfoV3Base, TDXModuleBase {
report.teeTcbSvn = bytes16(reportBytes.substring(0, 16));
report.mrSeam = reportBytes.substring(16, 48);
report.mrsignerSeam = reportBytes.substring(64, 48);
report.seamAttributes = bytes8(uint64(BELE.leBytesToBeUint(reportBytes.substring(112, 8))));
report.tdAttributes = bytes8(uint64(BELE.leBytesToBeUint(reportBytes.substring(120, 8))));
report.xFAM = bytes8(uint64(BELE.leBytesToBeUint(reportBytes.substring(128, 8))));
report.seamAttributes = uint64(BELE.leBytesToBeUint(reportBytes.substring(112, 8)));
report.tdAttributes = uint64(BELE.leBytesToBeUint(reportBytes.substring(120, 8)));
report.xFAM = uint64(BELE.leBytesToBeUint(reportBytes.substring(128, 8)));
report.mrTd = reportBytes.substring(136, 48);
report.mrConfigId = reportBytes.substring(184, 48);
report.mrOwner = reportBytes.substring(232, 48);
Expand Down

0 comments on commit 5db93be

Please sign in to comment.