NdsForge.NET 1.0.1
Read, validate, edit, compare, and build Nintendo DS and DSi images from .NET
Loading...
Searching...
No Matches
NdsValidationOptions.cs
1namespace NdsForge;
2
7public sealed class NdsValidationOptions
8{
10 private byte[]? _dsiHmacKey;
12 private NdsKey1KeyTable? _secureAreaKeyTable;
14 private NdsDsiRsaPublicKey? _dsiRsaPublicKey;
15
17 public static NdsValidationOptions Default => new();
18
25 public NdsValidationOptions SetDsiHmacKey(ReadOnlySpan<byte> key)
26 {
27 if (key.IsEmpty)
28 {
29 throw new ArgumentException("A DSi validation HMAC key cannot be empty.", nameof(key));
30 }
31
32 _dsiHmacKey = key.ToArray();
33 return this;
34 }
35
43 {
44 _secureAreaKeyTable = keyTable ?? throw new ArgumentNullException(nameof(keyTable));
45 return this;
46 }
47
55 {
56 _dsiRsaPublicKey = publicKey ?? throw new ArgumentNullException(nameof(publicKey));
57 return this;
58 }
59
64 public bool ValidateDsiDevelopmentSignature { get; init; } = true;
65
70 public int MaxDsiDigestTableBytes { get; init; } = 64 * 1024 * 1024;
71
73 public int MaxDsiDigestFailures { get; init; } = 64;
74
76 internal ReadOnlyMemory<byte> DsiHmacKey => _dsiHmacKey;
77
79 internal NdsKey1KeyTable? SecureAreaKeyTable => _secureAreaKeyTable;
80
82 internal NdsDsiRsaPublicKey? DsiRsaPublicKey => _dsiRsaPublicKey;
83
85 internal void Validate()
86 {
88 {
89 throw new ArgumentException("DSi digest validation limits must allow at least one 20-byte entry and one finding.");
90 }
91 }
92}
Represents one explicitly trusted RSA-1024 public key for DSi header authentication....
Holds the 18 round words and four 256-word substitution boxes consumed by the DS KEY1 algorithm....
Supplies optional trust material and policy for validation checks that cannot be inferred from image ...
static NdsValidationOptions Default
Returns a fresh keyless policy suitable for structural validation without shared mutable state.
NdsValidationOptions SetDsiHmacKey(ReadOnlySpan< byte > key)
Recomputes DSi component HMAC-SHA1 fields with caller-supplied trust material. Merely storing a match...
int MaxDsiDigestFailures
Caps individual sector/block mismatch diagnostics while retaining a final truncation warning.
bool ValidateDsiDevelopmentSignature
Verifies a recognizable no$gba development marker against the finalized 0xE00-byte header input....
NdsValidationOptions SetSecureAreaKeyTable(NdsKey1KeyTable keyTable)
Enables secure-area identifier recovery and encrypted-form CRC validation. No default table is bundle...
NdsValidationOptions SetDsiRsaPublicKey(NdsDsiRsaPublicKey publicKey)
Enables DSi header authenticity verification against one explicitly trusted RSA-1024 key....
int MaxDsiDigestTableBytes
Bounds each materialized DSi digest table while sector contents themselves remain streamed....