(history: list[str])
| 30 | |
| 31 | |
| 32 | def replay_rtmr(history: list[str]) -> str: |
| 33 | if len(history) == 0: |
| 34 | return INIT_MR |
| 35 | mr = bytes.fromhex(INIT_MR) |
| 36 | for content in history: |
| 37 | # mr = sha384(concat(mr, content)) |
| 38 | # if content is shorter than 48 bytes, pad it with zeros |
| 39 | content_bytes = bytes.fromhex(content) |
| 40 | if len(content_bytes) < 48: |
| 41 | content_bytes = content_bytes.ljust(48, b"\0") |
| 42 | mr = hashlib.sha384(mr + content_bytes).digest() |
| 43 | return mr.hex() |
| 44 | |
| 45 | |
| 46 | def get_endpoint(endpoint: str | None = None) -> str: |