@SciresM
/* Package2 size, version number is stored XORed in header CTR. */
/* Nintendo, what the fuck? */
I loled. I don't know what he's talking about, but it must have been the blunder for him to be that exasperated about it. Can we get a little context?
Ah, yeah. So, package2 header is basically [Signature] || [CTR] || [Encrypted Header]. When they decrypt the encrypted header, they decrypt everything after the signature in place, and then fix the CTR to be what it was pre-decryption.
Then, they derive some important values from the CTR (how big is the package2, what version is it).
AES-CTR's security relies on the CTR being a random number, and Nintendo's derivation results in a CTR that's certainly random...however, they sacrifice some of that randomness in order to derive values from it.
In particular, the CTR should be 128 random bits, but because of their derivations they only actually get 88 bits of randomness.
It's super WTF, because there's plenty of space where they could have stored that metadata elsewhere, without sacrificing any randomness...