Difference between revisions of "ES block encryption"

From DSiBrew
Jump to navigation Jump to search
(New page: = ES block encryption = ES block encryption, for lack of a better name, is a commonly used data encryption method on DSi by Nintendo. It uses AES CCM to encrypt a maximum of 0x20000 byte...)
(No difference)

Revision as of 20:41, 23 December 2009

ES block encryption

ES block encryption, for lack of a better name, is a commonly used data encryption method on DSi by Nintendo.

It uses AES CCM to encrypt a maximum of 0x20000 bytes of data per time, and extends it with a 32 byte trail block at the end.

A part of the last 16 bytes of trail block itself is encrypted with AES CTR, and contains the nonce for decryption and size of the ES block:

0000000: qq qq qq qq qq qq qq qq qq qq qq qq qq qq qq qq
0000010: xx nn nn nn nn nn nn nn nn nn nn nn nn yy yy yy

The counter used for decrypting the trail block is the last 16 bytes of the trailblock, with the first, 14th, 15th and 16th byte set to 0:

00 nn nn nn nn nn nn nn nn nn nn nn nn 00 00 00

After decrypting the trailblock, xx is always 0x3A, and yy is the size of the ES block (excluding the trail block). The nonce after decryption is not used. It is assumed that qq is a MAC (Message Authentication Code), used to verify the contents of the ES block after decryption, but this has not been verified yet.

The same 12-byte nonce from the trailblock is again used to decrypt the whole ES block itself.

Data larger than 0x20000 bytes is split into multiple ES blocks, each with their own trailblock.