Implement decrypt/encrypt ARM9 (secure area) also known as "encrypted DS cartridge"
Verify and re-generate the secure area CRC from the header.
Verify and re-generate the phase 1 HMAC of the header.
Verify and generate disable secure area token.
Implement verify and generate "disable secure area" token from the DS header.
Rename header hashes and related enums.
Add a performance test for the encryption. It takes about 150 us (0.00015 sec) to encrypt or decrypt a 2 KB secure area.
Example
To use the KEY1 encryption alone use the class NitroBlowfish:
var blowfish = new NitroBlowfish();
blowfish.Initialize(gameCode, level, modulo, key);
uint data0, data1;
byte[] dataArray;
Stream dataStream;
blowfish.Decrypt(ref data0, ref data1); // or Encrypt()
byte[] output = blowfish.Decrypt(dataArray); // or Encrypt()
blowfish.Decrypt(dataStream); // or Encrypt()
To encrypt or decrypt the ARM9 use the class NitroKey1Encryption:
var encryption = new NitroKey1Encryption(gameCode, keys);
bool isEncrypted = encryption.HasEncryptedArm9(arm9Stream); // false in game dumps
using DataStream encryptedArm9 = encryption.EncryptArm9(arm9Stream);
using DataStream decryptedArm9 = encryption.DecryptArm9(encryptedArm9);
To verify or generate the "disable secure area" token use the class NitroKey1Encryption:
var encryption = new NitroKey1Encryption(gameCode, keys);
byte[] token = encryption.GenerateEncryptedDisabledSecureAreaToken();
encryption.HasDisabledSecureArea(token);
Description
Example
To use the KEY1 encryption alone use the class
NitroBlowfish
:To encrypt or decrypt the ARM9 use the class
NitroKey1Encryption
:To verify or generate the "disable secure area" token use the class
NitroKey1Encryption
: