Table of Contents

Class TwilightHMacGenerator

Namespace
SceneGate.Ekona.Security
Assembly
SceneGate.Ekona.dll

Generate different hashes, HMAC and signatures of DS and DSi ROMs.

public class TwilightHMacGenerator
Inheritance
TwilightHMacGenerator
Inherited Members

Constructors

TwilightHMacGenerator(DsiKeyStore)

Initializes a new instance of the TwilightHMacGenerator class.

public TwilightHMacGenerator(DsiKeyStore keyStore)

Parameters

keyStore DsiKeyStore

Store with the keys.

Methods

GenerateArm9NoSecureAreaHmac(Stream, RomSectionInfo)

Generate the HMAC of the ARM9 without secure area.

public byte[] GenerateArm9NoSecureAreaHmac(Stream romStream, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to generate the hash.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

byte[]

HMAC of the ARM9 with no secure area.

GenerateDigestBlockHashes(Stream, RomSectionInfo)

Generate the digest block hashes (to the sector hashes) .

public IEnumerable<byte[]> GenerateDigestBlockHashes(Stream romStream, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to validate.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

IEnumerable<byte[]>

Collection of digest block hashes.

Exceptions

EndOfStreamException

The block area is incomplete.

GenerateDigestBlockHmac(Stream, RomSectionInfo)

Generate the HMAC of the DSi program digest block.

public byte[] GenerateDigestBlockHmac(Stream romStream, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to generate the hash.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

byte[]

HMAC of the digest block.

GenerateDigestSectionHashes(Stream, Stream, Node, RomSectionInfo)

Generate the hashes of the digest section (with the ROM data).

public IEnumerable<byte[]> GenerateDigestSectionHashes(Stream romStream, Stream encryptedArm9, Node systemNode, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to validate.

encryptedArm9 Stream

ARM9 stream with encrypted secure area.

systemNode Node

Container node with modcrypt decrypted system programs.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

IEnumerable<byte[]>

Collection of hashes for the digest section.

Exceptions

EndOfStreamException

The section area or ROM is incomplete.

GenerateHmac(Stream)

Generate the HMAC of the stream.

public byte[] GenerateHmac(Stream stream)

Parameters

stream Stream

Stream to generate MAC.

Returns

byte[]

HMAC of the stream.

GeneratePhase1Hmac(Stream, Stream, RomSectionInfo)

Generate the DS whitelist phase 1 HMAC (header, encrypted ARM9 and ARM7).

public byte[] GeneratePhase1Hmac(Stream romStream, Stream encryptedArm9, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to generate the hash.

encryptedArm9 Stream

Encrypted ARM9 to use for the hash.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

byte[]

HMAC for the whitelist phase 1.

Exceptions

InvalidOperationException

The key for the whitelist phase 1 is missing.

GeneratePhase2Hmac(Stream, RomSectionInfo)

Generate the whitelist phase 2 HMAC (overlay9).

public byte[] GeneratePhase2Hmac(Stream romStream, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to generate the hash.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

byte[]

HMAC for the whitelist phase 2.

Exceptions

InvalidOperationException

The key for the whitelist phase 2 is missing.

GeneratePhase3Hmac(Stream, ProgramInfo, RomSectionInfo)

Generate the whitelist phase 3 HMAC (banner with titles and icons).

public byte[] GeneratePhase3Hmac(Stream romStream, ProgramInfo programInfo, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to generate the hash.

programInfo ProgramInfo

Program information to determine if the target is DSi or DS.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

byte[]

HMAC for the whitelist phase 3.

Exceptions

InvalidOperationException

The key for the whitelist phase 3 is missing.

VerifyDigestBlock(Stream, RomSectionInfo)

Verify if the digest block hashes (to the sector hashes) are valid.

public HashStatus VerifyDigestBlock(Stream romStream, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to validate.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

HashStatus

The status if the digest block area is valid or not.

Exceptions

EndOfStreamException

The block area is incomplete.

VerifyDigestSectionContent(Stream, Stream, Node, RomSectionInfo)

Verify if the digest section content hashes (to the ROM data) are valid.

public HashStatus VerifyDigestSectionContent(Stream romStream, Stream encryptedArm9, Node systemNode, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to validate.

encryptedArm9 Stream

ARM9 stream with encrypted secure area.

systemNode Node

Container node with modcrypt decrypted system programs.

sectionInfo RomSectionInfo

Information of different ROM sections.

Returns

HashStatus

The status if the digest section is valid or not.

Exceptions

EndOfStreamException

The section area or ROM is incomplete.

WriteDigestBlock(Stream, RomSectionInfo)

Write the digest block (hashes of digest section).

public void WriteDigestBlock(Stream romStream, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM to generate hashes and write result.

sectionInfo RomSectionInfo

Information of different ROM sections.

WriteDigestSectionContent(Stream, Stream, Node, RomSectionInfo)

Write the digest section content hashes (to the ROM data).

public void WriteDigestSectionContent(Stream romStream, Stream encryptedArm9, Node systemNode, RomSectionInfo sectionInfo)

Parameters

romStream Stream

ROM stream with the content to validate and to write.

encryptedArm9 Stream

ARM9 stream with encrypted secure area.

systemNode Node

Container node with modcrypt decrypted system programs.

sectionInfo RomSectionInfo

Information of different ROM sections.

Exceptions

EndOfStreamException

The section area or ROM is incomplete.