perform dfc checks before spad decryption

This commit is contained in:
ppc
2025-01-15 13:55:47 +00:00
parent 5b19207a91
commit 2bc9c9f673
+12 -3
View File
@@ -112,13 +112,22 @@ async function readAmusementICCardContents(idm: string): Promise<AmusementICCard
return null;
}
const accessCode = performDecrypt(new Uint8Array(response.slice(12, 28)));
const dfcValue = response[37] | (response[36] << 8);
if (dfcValue in AmusementICVendor && dfcValue !== AmusementICVendor.Unknown) {
const accessCode = performDecrypt(new Uint8Array(response.slice(12, 28)));
return {
type: ICType.Amusement,
accessCode: [...accessCode.accessCodeBytes].map(x => x.toString(16).padStart(2, '0')).join(''),
vendor: dfcValue,
idm
};
}
return {
type: ICType.Amusement,
accessCode: [...accessCode.accessCodeBytes].map(x => x.toString(16).padStart(2, '0')).join(''),
vendor: dfcValue in AmusementICVendor ? dfcValue : AmusementICVendor.Unknown,
accessCode: icCard0008Number(idm),
vendor: AmusementICVendor.Unknown,
idm
};
}