Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong implementation for CRC padding in mifare_cryto_postprocess_data #128

Open
ifcwlme opened this issue Jun 4, 2020 · 0 comments
Open

Comments

@ifcwlme
Copy link

ifcwlme commented Jun 4, 2020

When use AES and full data encryption, there is a CRC32 check.
According to document, it is a known data length message for encryption. So the padding is all zeros. Not 0x80 followed by all zeros.
It can also be verified by seeing the actual PICC data after AES decryption. There is no 0x80 in the padding.

In the current mifare_cryto_postprocess_data.c implementation. It does take payload data length as parameter. Instead, it check where the CRC meets 32bit zero to determinate the payload length.

But this implementation will have 1/256 of probability(last byte of CRC also 0x00) that the guessed payload length is less one byte when the last byte of payload is 0x00.

for example, payload: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 DF 21 A1 C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 BA 7D EF 30 00
yields CRC32: E0 43 E2 00

It should perform 4 round of CRC check. But in the third round, CRC remainder is 00 00 00 00, same as fourth round.
This cause the output post processing data only 63 bytes. It should be 64 bytes.

Paul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant