Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Verify and generate Twilight digest hashes #24

Merged
merged 6 commits into from
Apr 21, 2022
Merged

Conversation

pleonex
Copy link
Member

@pleonex pleonex commented Apr 21, 2022

Description

  • Verify and regenerate the digest HMAC section for Twilight (DSi) programs.
  • Fix phase 1 HMAC generation (missing updated header values)

Example

The digest is verified by Binary2NitroRom when the keys are provided. It's also regenerated by NitroRom2Binary when the keys are provided. To use it manually, use the class TwilightHmacGenerator.

Performance

Regenerating or verifying the full content of the ROM impacts the performance. It's optional and only happens if the keys are provided. The results are acceptable under the second.

BenchmarkDotNet=v0.13.1, OS=fedora 34
Intel Core i7-4720HQ CPU 2.60GHz (Haswell), 1 CPU, 8 logical and 4 physical cores
.NET SDK=6.0.103
  [Host]     : .NET 6.0.3 (6.0.322.16001), X64 RyuJIT
  DefaultJob : .NET 6.0.3 (6.0.322.16001), X64 RyuJIT

Method RomPath UseKeys Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
ReadRom METALMAX3_BM9JQC_00.nds False 646.5 μs 8.65 μs 7.67 μs 65.4297 32.2266 - 364 KB
WriteRom METALMAX3_BM9JQC_00.nds False 13,830.4 μs 66.63 μs 62.33 μs 453.1250 - - 1,412 KB
ReadRom METALMAX3_BM9JQC_00.nds True 3,822.7 μs 68.78 μs 129.19 μs 265.6250 257.8125 164.0625 1,680 KB
WriteRom METALMAX3_BM9JQC_00.nds True 17,498.3 μs 157.89 μs 139.96 μs 468.7500 - - 2,591 KB
ReadRom NINOKUNI_B2KJHF_00.nds False 51,638.4 μs 928.01 μs 911.43 μs 2100.0000 1000.0000 300.0000 11,477 KB
WriteRom NINOKUNI_B2KJHF_00.nds False 205,883.5 μs 2,838.06 μs 2,369.91 μs 24000.0000 - - 75,966 KB
ReadRom NINOKUNI_B2KJHF_00.nds True 54,195.4 μs 774.02 μs 724.02 μs 2200.0000 1000.0000 300.0000 12,691 KB
WriteRom NINOKUNI_B2KJHF_00.nds True 205,055.0 μs 2,815.72 μs 2,633.82 μs 24333.3333 - - 77,032 KB
ReadRom PSL_VPYJ2P_00.nds False 2,916.6 μs 32.17 μs 28.52 μs 191.4063 93.7500 - 1,209 KB
WriteRom PSL_VPYJ2P_00.nds False 79,985.2 μs 1,597.41 μs 2,239.34 μs 1000.0000 - - 6,050 KB
ReadRom PSL_VPYJ2P_00.nds True 600,838.2 μs 10,032.94 μs 8,893.94 μs 4000.0000 1000.0000 - 16,396 KB
WriteRom PSL_VPYJ2P_00.nds True 369,532.8 μs 5,659.06 μs 4,725.57 μs 6000.0000 - - 21,104 KB

This closes #12

@pleonex pleonex added the enhancement New feature or request label Apr 21, 2022
@pleonex pleonex added this to the vNext milestone Apr 21, 2022
@pleonex pleonex self-assigned this Apr 21, 2022
@pleonex pleonex merged commit 314091f into main Apr 21, 2022
@pleonex pleonex deleted the feature/digest branch April 21, 2022 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement verification and generation of DSi ROM digests
1 participant