Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python/tests: fix some pylint errors #26

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/python/cctrusted_vm/cvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _load_config(self):
LOG.debug("Invalid vsock port specified in the config.")
del tdx_config_dict["port"]

return tdx_config_dict
return tdx_config_dict

def process_cc_report(self, report_data=None) -> bool:
"""Process the confidential computing REPORT."""
Expand Down
23 changes: 9 additions & 14 deletions src/python/tests/tdx_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pytest
from cctrusted_base.api import CCTrustedApi
from cctrusted_base.eventlog import EventLogs
from cctrusted_base.tcg import TcgAlgorithmRegistry, TcgEventType
from cctrusted_base.tcg import TcgAlgorithmRegistry
from cctrusted_base.tdx.common import TDX_REPORTDATA_LEN
from cctrusted_base.tdx.quote import TdxQuote, TdxQuoteBody
from cctrusted_base.tdx.rtmr import TdxRTMR
Expand Down Expand Up @@ -56,8 +56,8 @@ def tdx_check_measurement_imrs():
"""
alg = CCTrustedVmSdk.inst().get_default_algorithms()
rtmrs = _replay_eventlog()
for imr_idx, _ in rtmrs.items():
_check_imr(imr_idx, alg.alg_id, rtmrs[imr_idx][alg.alg_id])
for imr_idx, digests in rtmrs.items():
_check_imr(imr_idx, alg.alg_id, digests[alg.alg_id])

def _gen_valid_nonce():
"""Generate nonce for test.
Expand Down Expand Up @@ -123,19 +123,14 @@ def _check_quote_rtmrs(quote):
assert quote is not None and isinstance(quote, TdxQuote)
body = quote.body
assert body is not None and isinstance(body, TdxQuoteBody)
quote_rtmrs = [body.rtmr0, body.rtmr1, body.rtmr2, body.rtmr3]
rtmrs = _replay_eventlog()
alg = CCTrustedVmSdk.inst().get_default_algorithms()
# Replay result only contains the RTMR values covered by the event logs
# Need to fill back the RTMRs that are not covered by the event logs
for idx in range(TdxRTMR.RTMR_COUNT):
if idx not in rtmrs.keys():
rtmrs[idx] = {}
rtmrs[idx][alg.alg_id] = bytearray(TdxRTMR.RTMR_LENGTH_BY_BYTES)
# Compare all the RTMR values
assert body.rtmr0 == rtmrs[0][alg.alg_id], "RTMR0 doesn't equal the replay from event log!"
assert body.rtmr1 == rtmrs[1][alg.alg_id], "RTMR1 doesn't equal the replay from event log!"
assert body.rtmr2 == rtmrs[2][alg.alg_id], "RTMR2 doesn't equal the replay from event log!"
assert body.rtmr3 == rtmrs[3][alg.alg_id], "RTMR3 doesn't equal the replay from event log!"
# Compare all the RTMR values which are used by the event log.
# Please note that some RTMR may not be used.
for imr_idx, digests in rtmrs.items():
assert quote_rtmrs[imr_idx] == digests[alg.alg_id], \
f"RTMR{imr_idx} doesn't equal the replay from event log!"

def _check_quote_reportdata(quote, nonce=None, userdata=None):
"""Check the userdata in quote result."""
Expand Down
Loading