Skip to content

Instantly share code, notes, and snippets.

@dajiaji
Last active July 12, 2021 10:50
Show Gist options
  • Save dajiaji/c0c2f28d61c8f2943a73f52f1788b67a to your computer and use it in GitHub Desktop.
Save dajiaji/c0c2f28d61c8f2943a73f52f1788b67a to your computer and use it in GitHub Desktop.
A simple EUDCC verifier implementation with Python CWT: verify_and_decode
def verify_and_decode(self, eudcc: bytes) -> bytes:
if eudcc.startswith(b"HC1:"):
# Decode Base45 data.
eudcc = b45decode(eudcc[4:])
# Decompress with zlib.
eudcc = zlib.decompress(eudcc)
# Verify and decode CWT.
return cwt.decode(eudcc, keys=self._dscs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment