NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsForge.NdsSecureArea Class Reference

Provides pure inspection and KEY1 transformations for the conventional 0x4000-0x7FFF cartridge interval. Operations return new buffers and never rewrite a source image, header checksum, or caller key table. More...

Static Public Member Functions

static NdsSecureAreaInspection Inspect (NdsImage image, NdsKey1KeyTable? keyTable=null)
 Inspects a loaded image and verifies encrypted state or CRC only when enough explicit key material exists.
static NdsSecureAreaInspection Inspect (ReadOnlySpan< byte > area, string gameCode, ushort storedCrc, NdsKey1KeyTable? keyTable=null)
 Classifies one isolated interval using caller-supplied identity and stored checksum context.
static byte[] Encrypt (ReadOnlySpan< byte > area, string gameCode, NdsKey1KeyTable keyTable)
 Encrypts a decrypted interval for the supplied product identity and returns an independent copy.
static byte[] Decrypt (ReadOnlySpan< byte > area, string gameCode, NdsKey1KeyTable keyTable)
 Decrypts a key-verifiable interval and replaces its secure identifier with conventional destroyed markers.
static ValueTask EncryptAsync (Stream source, Stream destination, string gameCode, NdsKey1KeyTable keyTable, CancellationToken cancellationToken=default)
 Reads one interval at the source's current position, encrypts it, and writes exactly 16 KiB without closing either caller-owned stream. Buffering the fixed-size area prevents a partially transformed destination when the source is truncated or the identifier is invalid.
static ValueTask DecryptAsync (Stream source, Stream destination, string gameCode, NdsKey1KeyTable keyTable, CancellationToken cancellationToken=default)
 Reads one encrypted interval and emits a verified decrypted copy without closing caller-owned streams. No destination bytes are written unless both KEY1 initialization levels recover the secure identifier.

Static Public Attributes

const int Offset = 0x4000
 Absolute image offset at which the cartridge security interval begins.
const int ByteLength = 0x4000
 CRC-covered interval length; KEY1 itself transforms only the first 0x800 bytes.

Detailed Description

Provides pure inspection and KEY1 transformations for the conventional 0x4000-0x7FFF cartridge interval. Operations return new buffers and never rewrite a source image, header checksum, or caller key table.

Definition at line 10 of file NdsSecureArea.cs.

Member Function Documentation

◆ Decrypt()

byte[] NdsForge.NdsSecureArea.Decrypt ( ReadOnlySpan< byte > area,
string gameCode,
NdsKey1KeyTable keyTable )
inlinestatic

Decrypts a key-verifiable interval and replaces its secure identifier with conventional destroyed markers.

Parameters
areaExactly 16 KiB whose first 2 KiB use KEY1.
gameCodeExactly four ASCII product-code bytes.
keyTableExplicit seed schedule from an authorized source.
Returns
Decrypted bytes; the last 14 KiB remain byte-identical to input.

Definition at line 110 of file NdsSecureArea.cs.

◆ DecryptAsync()

ValueTask NdsForge.NdsSecureArea.DecryptAsync ( Stream source,
Stream destination,
string gameCode,
NdsKey1KeyTable keyTable,
CancellationToken cancellationToken = default )
inlinestatic

Reads one encrypted interval and emits a verified decrypted copy without closing caller-owned streams. No destination bytes are written unless both KEY1 initialization levels recover the secure identifier.

Parameters
sourceReadable stream positioned at encrypted secure-area byte zero.
destinationWritable stream receiving decrypted bytes at its current position.
gameCodeExactly four ASCII product-code bytes.
keyTableExplicit seed schedule from an authorized source.
cancellationTokenCancels input and output I/O.
Returns
A task-like value that completes after the verified 16 KiB result has been written.

Definition at line 145 of file NdsSecureArea.cs.

◆ Encrypt()

byte[] NdsForge.NdsSecureArea.Encrypt ( ReadOnlySpan< byte > area,
string gameCode,
NdsKey1KeyTable keyTable )
inlinestatic

Encrypts a decrypted interval for the supplied product identity and returns an independent copy.

Parameters
areaExactly 16 KiB beginning with two destroyed-ID marker words.
gameCodeExactly four ASCII product-code bytes.
keyTableExplicit seed schedule from an authorized source.
Returns
Encrypted bytes suitable for writing at image offset 0x4000.

Definition at line 99 of file NdsSecureArea.cs.

◆ EncryptAsync()

ValueTask NdsForge.NdsSecureArea.EncryptAsync ( Stream source,
Stream destination,
string gameCode,
NdsKey1KeyTable keyTable,
CancellationToken cancellationToken = default )
inlinestatic

Reads one interval at the source's current position, encrypts it, and writes exactly 16 KiB without closing either caller-owned stream. Buffering the fixed-size area prevents a partially transformed destination when the source is truncated or the identifier is invalid.

Parameters
sourceReadable stream positioned at decrypted secure-area byte zero.
destinationWritable stream receiving encrypted bytes at its current position.
gameCodeExactly four ASCII product-code bytes.
keyTableExplicit seed schedule from an authorized source.
cancellationTokenCancels input and output I/O.
Returns
A task-like value that completes after the verified 16 KiB result has been written.

Definition at line 127 of file NdsSecureArea.cs.

◆ Inspect() [1/2]

NdsSecureAreaInspection NdsForge.NdsSecureArea.Inspect ( NdsImage image,
NdsKey1KeyTable? keyTable = null )
inlinestatic

Inspects a loaded image and verifies encrypted state or CRC only when enough explicit key material exists.

Parameters
imageRead-only image supplying header metadata and exactly bounded bytes.
keyTableOptional KEY1 schedule used to recognize encrypted content and reconstruct decrypted CRC input.
Returns
A state and checksum report; malformed data is represented without mutating or repairing it.

Definition at line 21 of file NdsSecureArea.cs.

◆ Inspect() [2/2]

NdsSecureAreaInspection NdsForge.NdsSecureArea.Inspect ( ReadOnlySpan< byte > area,
string gameCode,
ushort storedCrc,
NdsKey1KeyTable? keyTable = null )
inlinestatic

Classifies one isolated interval using caller-supplied identity and stored checksum context.

Parameters
areaExactly 16 KiB beginning at image offset 0x4000.
gameCodeExactly four ASCII bytes used by KEY1 initialization.
storedCrcHeader checksum to compare with the encrypted representation.
keyTableOptional schedule enabling cryptographic recognition.
Returns
A state and nullable checksum conclusion.

Definition at line 47 of file NdsSecureArea.cs.

Member Data Documentation

◆ ByteLength

const int NdsForge.NdsSecureArea.ByteLength = 0x4000
static

CRC-covered interval length; KEY1 itself transforms only the first 0x800 bytes.

Definition at line 15 of file NdsSecureArea.cs.

◆ Offset

const int NdsForge.NdsSecureArea.Offset = 0x4000
static

Absolute image offset at which the cartridge security interval begins.

Definition at line 13 of file NdsSecureArea.cs.


The documentation for this class was generated from the following file: