Skip to content

Commit

Permalink
Added API to get enclave platform ID
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaven committed Jul 4, 2024
1 parent 7715e1a commit 3538fe5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions contracts/DecentServerCertMgr.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,22 @@ contract DecentServerCertMgr {
bytes32(0);
}

/**
* Get the platform ID of a Decent Server
* @param svrKeyAddr Address derived from the Decent Server public key
* @return bytes32 Platform ID of the Decent Server
*/
function getPlatformId(address svrKeyAddr)
external
view
returns (bytes32)
{
DecentServerCert.DecentServerCertObj storage cert =
m_serverCerts[svrKeyAddr];

require(cert.isVerified, "Server not verified");

return cert.platformId;
}

}
10 changes: 10 additions & 0 deletions contracts/Interface_DecentServerCertMgr.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ interface Interface_DecentServerCertMgr {
view
returns (bytes32);

/**
* Get the platform ID of a Decent Server
* @param svrKeyAddr Address derived from the Decent Server public key
* @return bytes32 Platform ID of the Decent Server
*/
function getPlatformId(address svrKeyAddr)
external
view
returns (bytes32);

}
16 changes: 16 additions & 0 deletions tests/DecentServer/03_DecentServerCertMgr_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ contract DecentServerCertMgr_testSuit {
TestCerts.DECENT_SVR_CERT_ENCL_HASH,
"encHash not match"
);

bytes32 platId = decentServerCertMgr.getPlatformId(TestCerts.DECENT_SVR_CERT_KEY_ADDR);

Assert.equal(
platId,
TestCerts.DECENT_SVR_CERT_PLAT_ID,
"platform ID not match"
);
}

function verifyCertTest() public {
Expand All @@ -93,6 +101,14 @@ contract DecentServerCertMgr_testSuit {
TestCerts.DECENT_SVR_CERT_ENCL_HASH,
"encHash not match"
);

bytes32 platId = decentServerCertMgr.getPlatformId(TestCerts.DECENT_SVR_CERT_KEY_ADDR);

Assert.equal(
platId,
TestCerts.DECENT_SVR_CERT_PLAT_ID,
"platform ID not match"
);
}

function verifyInvalidCertTest() public {
Expand Down

0 comments on commit 3538fe5

Please sign in to comment.