additional validation

This commit is contained in:
Lee Salminen 2022-08-21 13:17:44 -06:00
parent a6f0acc030
commit a3f910acf4

View file

@ -159,6 +159,9 @@ async def api_scan(p, c, request: Request, card_uid: str = None):
try: try:
card = await get_card_by_uid(card_uid) card = await get_card_by_uid(card_uid)
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(card.k1)) card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(card.k1))
if card.uid.upper() != card_uid.hex().upper():
return {"status": "ERROR", "reason": "Card UID mis-match."}
except: except:
return {"status": "ERROR", "reason": "Error decrypting card."} return {"status": "ERROR", "reason": "Error decrypting card."}