Read and write DS extended header: new header fields in DS games launched after the DSi. Including...
HMACs: validate and re-generate. Except ARM9/7 HMAC as it requires to implement the secure area encryption. Validated and re-created via the new class TwilightHMacGenerator.
RSA header signature: validate. We cannot re-generate as the private key is unknown. Validated via new class TwilightSigner
New DsiKeyStore class to specify the keys for HMAC and RSA signature. The documentation of the fields explains how to fill it. It is a class easily serializable into YAML or JSON.
Convert UnitCode, DsiCryptoFlags into an enum with the possible values.
Regenerate ROM header CRC-16
Rename RomInfo into ProgramInfo to match variable names.
The class HashInfo is used now for CRC, HMAC and Signatures.
Example
The Binary2NitroRom converter accepts the optional parameter DsiKeyStore. If provided, the HMAC and Signature will be validated while reading the ROM.
DsiKeyStore keys = ...; // Create in code or deserialize from YAML/JSON.
using Node node = NodeFactory.FromFile(romPath, FileOpenMode.Read);
node.TransformWith<Binary2NitroRom, DsiKeyStore>(keys);
NitroRom rom = node.GetFormatAs<NitroRom>();
ProgramInfo programInfo = rom.Information;
bool isDsi = programInfo.UnitCode != DeviceUnitKind.DS;
if (isDsi || programInfo.ProgramFeatures.HasFlag(DsiRomFeatures.BannerSigned)) {
programInfo.BannerMac.Status.Should().Be(HashStatus.Valid);
}
if (programInfo.ProgramFeatures.HasFlag(DsiRomFeatures.ProgramSigned)) {
programInfo.OverlaysMac.Status.Should().Be(HashStatus.Valid);
programInfo.Signature.Status.Should().Be(HashStatus.Valid);
}
if (isDsi) {
programInfo.OverlaysMac.IsNull.Should().BeTrue();
programInfo.ProgramMac.IsNull.Should().BeTrue();
programInfo.Signature.Status.Should().Be(HashStatus.Valid);
}
The NitroRom2Binary converter accepts the optional parameter NitroRom2BinaryParams. If provided with keys, it will re-generate the above HMACs.
Description
TwilightHMacGenerator
.TwilightSigner
DsiKeyStore
class to specify the keys for HMAC and RSA signature. The documentation of the fields explains how to fill it. It is a class easily serializable into YAML or JSON.UnitCode
,DsiCryptoFlags
into an enum with the possible values.RomInfo
intoProgramInfo
to match variable names.HashInfo
is used now for CRC, HMAC and Signatures.Example
The
Binary2NitroRom
converter accepts the optional parameterDsiKeyStore
. If provided, the HMAC and Signature will be validated while reading the ROM.The
NitroRom2Binary
converter accepts the optional parameterNitroRom2BinaryParams
. If provided with keys, it will re-generate the above HMACs.Related to #9, #12