Skip to content

Commit 0209653

Browse files
committed
new collateral issuance date must be strictly higher than the issuance date of existing collaterals
1 parent abbd942 commit 0209653

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/bases/FmspcTcbDao.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ abstract contract FmspcTcbDao is DaoBase, SigVerifyBase {
185185
/// I don't think there can be a scenario where an existing tcbinfo with a higher evaluation data number
186186
/// to be issued BEFORE a new tcbinfo with a lower evaluation data number
187187
bool outOfDate = tcbInfo.evaluationDataNumber < existingEvaluationDataNumber ||
188-
tcbInfo.issueDate < existingIssueDate;
188+
tcbInfo.issueDate <= existingIssueDate;
189189
if (outOfDate) {
190190
revert TCB_Out_Of_Date();
191191
}

src/bases/PckDao.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ abstract contract PckDao is DaoBase, SigVerifyBase {
294294
bytes memory existingData = _fetchDataFromResolver(key, false);
295295
if (existingData.length > 0) {
296296
(uint256 existingCertNotValidBefore, ) = pckLib.getCertValidity(existingData);
297-
bool outOfDate = existingCertNotValidBefore > pck.validityNotBefore;
297+
bool outOfDate = existingCertNotValidBefore >= pck.validityNotBefore;
298298
if (outOfDate) {
299299
revert Pck_Out_Of_Date();
300300
}

src/bases/PcsDao.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ abstract contract PcsDao is DaoBase, SigVerifyBase {
143143
function _upsertPcsCrl(CA ca, bytes calldata crl) private returns (bytes32 attestationId) {
144144
(bytes32 hash, bytes32 key) = _validatePcsCrl(ca, crl);
145145

146-
_checkCollateralDuplicate(key, hash);
147-
148146
attestationId = _attestPcs(crl, hash, key);
149147

150148
emit UpsertedPCSCollateral(ca, true);
@@ -173,7 +171,7 @@ abstract contract PcsDao is DaoBase, SigVerifyBase {
173171
bytes memory existingData = _fetchDataFromResolver(key, false);
174172
if (existingData.length > 0) {
175173
(uint256 existingCertNotValidBefore, ) = x509Lib.getCertValidity(existingData);
176-
bool outOfDate = existingCertNotValidBefore > currentCert.validityNotBefore;
174+
bool outOfDate = existingCertNotValidBefore >= currentCert.validityNotBefore;
177175
if (outOfDate) {
178176
revert Certificate_Out_Of_Date();
179177
}
@@ -234,6 +232,11 @@ abstract contract PcsDao is DaoBase, SigVerifyBase {
234232

235233
function _validatePcsCrl(CA ca, bytes calldata crl) private view returns (bytes32 hash, bytes32 key) {
236234
X509CRLObj memory currentCrl = crlLib.parseCRLDER(crl);
235+
236+
key = PCS_KEY(ca, true);
237+
hash = keccak256(currentCrl.tbs);
238+
239+
_checkCollateralDuplicate(key, hash);
237240

238241
// Step 1: Check whether CRL has expired
239242
bool validTimestamp =
@@ -245,11 +248,10 @@ abstract contract PcsDao is DaoBase, SigVerifyBase {
245248

246249
// Step 2: Rollback prevention: new CRL should not have an issued date
247250
// that is older than the existing CRL
248-
key = PCS_KEY(ca, true);
249251
bytes memory existingData = _fetchDataFromResolver(key, false);
250252
if (existingData.length > 0) {
251253
(uint256 existingCrlNotValidBefore, ) = crlLib.getCrlValidity(existingData);
252-
bool outOfDate = existingCrlNotValidBefore > currentCrl.validityNotBefore;
254+
bool outOfDate = existingCrlNotValidBefore >= currentCrl.validityNotBefore;
253255
if (outOfDate) {
254256
revert Certificate_Out_Of_Date();
255257
}
@@ -272,8 +274,6 @@ abstract contract PcsDao is DaoBase, SigVerifyBase {
272274
if (!sigVerified) {
273275
revert Invalid_Signature();
274276
}
275-
276-
hash = keccak256(currentCrl.tbs);
277277
}
278278

279279
function _getIssuer(CA ca) private view returns (bytes memory issuerCert) {

0 commit comments

Comments
 (0)