switchbrew / libnx

Library for Switch Homebrew
https://switchbrew.github.io/libnx/
ISC License
1.26k stars 167 forks source link

crypto: fix aes-cbc individual block decryption #624

Closed liamadvance closed 11 months ago

liamadvance commented 11 months ago

We ran into this issue in nxdumptool when decrypting the card header encryption target data from an inserted gamecard, which made us think that Nintendo added a new field to the data.

This happens due to a missing XOR operation during individual block decryption. Since the card header encryption target data is 0x70 bytes in the size, the first six blocks are decrypted correctly, while the last block is not.