summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2021-03-17 23:33:31 +0200
committerYuval Adam <_@yuv.al>2021-03-17 23:33:31 +0200
commitc105914f8341d5c6135d077b879a26db13679ded (patch)
treea958a4786ed83c76c804a6796ecb93e063cfd85d
parent66e098b0d9c200271412fd92e9a2e677ec7fbb4c (diff)
Add bytes validation and warn on no signature
-rw-r--r--verify.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/verify.py b/verify.py
index 41f9494..e1c9cdc 100644
--- a/verify.py
+++ b/verify.py
@@ -15,6 +15,8 @@ from pyzbar import pyzbar
class GreenPassVerifier(object):
def __init__(self, data_bytes):
+ self.validate_bytes(data_bytes)
+
sig, self.payload = data_bytes.split(b"#", maxsplit=1)
self.signature = base64.decodebytes(sig)
self.data = json.loads(self.payload)
@@ -48,6 +50,15 @@ class GreenPassVerifier(object):
data = img.getImageData(output="png")
return cls.from_qr(BytesIO(data))
+ def validate_bytes(self, bs):
+ if bs.decode().startswith("GreenPass"):
+ click.secho(
+ "⚠️ Green pass QR code contains no signature to verify",
+ fg="yellow",
+ bold=True,
+ )
+ click.get_current_context().exit()
+
def validate_data(self):
ct = self.data["ct"]
if ct not in (1, 2):