.NET 6 version wrongly decrypts 3ds roms #7

Closed
opened 2026-01-29 22:29:01 +00:00 by claunia · 19 comments
Owner

Originally created by @Brankale on GitHub (Jul 2, 2022).

Originally assigned to: @mnadareski on GitHub.

When you try to decrypt a 3DS rom with the .NET 6 version, the final file is corrupted and if you try to re-encrypt it you don't get the original file

.NET 4.8 and 5.0 versions are not affected by this problem.

Originally created by @Brankale on GitHub (Jul 2, 2022). Originally assigned to: @mnadareski on GitHub. When you try to decrypt a 3DS rom with the .NET 6 version, the final file is corrupted and if you try to re-encrypt it you don't get the original file .NET 4.8 and 5.0 versions are not affected by this problem.
claunia added the bug label 2026-01-29 22:29:01 +00:00
Author
Owner

@mnadareski commented on GitHub (Sep 27, 2022):

I'm not seeing the typical issues that were caused by the stream reading/writing change in .NET 6. I'll have to dig in.

@mnadareski commented on GitHub (Sep 27, 2022): I'm not seeing the typical issues that were caused by the stream reading/writing change in .NET 6. I'll have to dig in.
Author
Owner

@mnadareski commented on GitHub (Sep 27, 2022):

Hmm, so I have the library compiled to netstandard2.0 so there must be something up with the commandline program?

@mnadareski commented on GitHub (Sep 27, 2022): Hmm, so I have the library compiled to `netstandard2.0` so there must be something up with the commandline program?
Author
Owner

@mnadareski commented on GitHub (Sep 27, 2022):

I made a few smaller changes that are semi-related to .NET 6 that may help with this. Not a guarantee, but please try it out. I'll try to test locally when possible.

@mnadareski commented on GitHub (Sep 27, 2022): I made a few smaller changes that are semi-related to .NET 6 that _may_ help with this. Not a guarantee, but please try it out. I'll try to test locally when possible.
Author
Owner

@mnadareski commented on GitHub (Sep 27, 2022):

Local testing on a very small 3DS game worked on both decrypt and re-encrypt using the newest .NET 6 build on Windows 10. Hopefully that works for you as well.

@mnadareski commented on GitHub (Sep 27, 2022): Local testing on a very small 3DS game worked on both decrypt and re-encrypt using the newest .NET 6 build on Windows 10. Hopefully that works for you as well.
Author
Owner

@Brankale commented on GitHub (Sep 27, 2022):

If you can upload here the executable in a zip file you would save me a ton of time. If you can't, I'll try to make it myself as soon as I can find the time.

@Brankale commented on GitHub (Sep 27, 2022): If you can upload here the executable in a zip file you would save me a ton of time. If you can't, I'll try to make it myself as soon as I can find the time.
Author
Owner

@mnadareski commented on GitHub (Sep 27, 2022):

Here you go:
net6.0.zip

@mnadareski commented on GitHub (Sep 27, 2022): Here you go: [net6.0.zip](https://github.com/SabreTools/NDecrypt/files/9659983/net6.0.zip)
Author
Owner

@Brankale commented on GitHub (Sep 28, 2022):

Unfornately these changes don't solve the issue. However I did further testing and:

  1. encryption seems to work fine (both the old and the new version)
  2. decryption works only on some games. For example Super Mario 3D Land decryption works but in games like Pokemon Sun/Ultramoon or Zelda Majora's Mask, decryption is not working.
  3. I did the test only on one game but it seems that the decryption problem is at the beginning of the file in the first couple of MB (probably the header). Take this info with a grain of salt.
@Brankale commented on GitHub (Sep 28, 2022): Unfornately these changes don't solve the issue. However I did further testing and: 1) encryption seems to work fine (both the old and the new version) 2) decryption works only on some games. For example Super Mario 3D Land decryption works but in games like Pokemon Sun/Ultramoon or Zelda Majora's Mask, decryption is not working. 3) I did the test only on one game but it seems that the decryption problem is at the beginning of the file in the first couple of MB (probably the header). Take this info with a grain of salt.
Author
Owner

@mnadareski commented on GitHub (Oct 4, 2022):

Were the file sizes different as well? I may have to look into write operations if that's the case. It feels like this isn't a decrypt/encrypt library issue at this point, rather something yet harder to track down.

@mnadareski commented on GitHub (Oct 4, 2022): Were the file sizes different as well? I may have to look into write operations if that's the case. It feels like this isn't a decrypt/encrypt library issue at this point, rather something yet harder to track down.
Author
Owner

@Brankale commented on GitHub (Oct 4, 2022):

Yes

super mario 3d land was the only one below 1GB (512MB to be specific)

Zelda was 1 GB if I remember correctly and Pokemon games are 4GB in size

I thought about the file size too, but currently i dont have the tools to verify it

@Brankale commented on GitHub (Oct 4, 2022): Yes super mario 3d land was the only one below 1GB (512MB to be specific) Zelda was 1 GB if I remember correctly and Pokemon games are 4GB in size I thought about the file size too, but currently i dont have the tools to verify it
Author
Owner

@Brankale commented on GitHub (Oct 10, 2022):

Since the .NET 6 is currently buggy, is it possible to remove this version from the github releases tab? I ask for this because this program is used to submit hashes on DAT-o-MATIC for rom dumps verification and game preservation purposes. Since the program can output wrong values a user who is unaware of this problem can accidentally submit wrong data to the website. Alternatively you can put a warning somewhere.

@Brankale commented on GitHub (Oct 10, 2022): Since the .NET 6 is currently buggy, is it possible to remove this version from the github releases tab? I ask for this because this program is used to submit hashes on DAT-o-MATIC for rom dumps verification and game preservation purposes. Since the program can output wrong values a user who is unaware of this problem can accidentally submit wrong data to the website. Alternatively you can put a warning somewhere.
Author
Owner

@mnadareski commented on GitHub (Oct 10, 2022):

An entirely reasonable ask. Let me see what I can do.

@mnadareski commented on GitHub (Oct 10, 2022): An entirely reasonable ask. Let me see what I can do.
Author
Owner

@mnadareski commented on GitHub (Oct 10, 2022):

It's been removed from the release page and a note was put up. Good call.

@mnadareski commented on GitHub (Oct 10, 2022): It's been removed from the release page and a note was put up. Good call.
Author
Owner

@mnadareski commented on GitHub (Oct 27, 2022):

I've been looking into this pretty heavily to see if there's anything in my code that is causing this issue. Unfortunately, I've narrowed it down to (seemingly) the library I use for AES encryption support, where their internal code may not deal properly with byte reading changes in .NET 6.0. I'll be trying to narrow it down even further, but that's the best I have right now.

@mnadareski commented on GitHub (Oct 27, 2022): I've been looking into this pretty heavily to see if there's anything in my code that is causing this issue. Unfortunately, I've narrowed it down to (seemingly) the library I use for AES encryption support, where their internal code may not deal properly with byte reading changes in .NET 6.0. I'll be trying to narrow it down even further, but that's the best I have right now.
Author
Owner

@mnadareski commented on GitHub (Oct 28, 2022):

I may have narrowed it down further to something adjacent to the encryption. There were things happening async that made it seem like the encryption and decryption weren't working.

@mnadareski commented on GitHub (Oct 28, 2022): I may have narrowed it down further to something adjacent to the encryption. There were things happening async that made it seem like the encryption and decryption weren't working.
Author
Owner

@mnadareski commented on GitHub (Oct 28, 2022):

I think I was able to fix the issue in 7d263886da

Please see the attached build.
net6.0.zip

@mnadareski commented on GitHub (Oct 28, 2022): I think I was able to fix the issue in https://github.com/SabreTools/NDecrypt/commit/7d263886daedb4a4336cd1524d7d664e11314586 Please see the attached build. [net6.0.zip](https://github.com/SabreTools/NDecrypt/files/9883715/net6.0.zip)
Author
Owner

@Brankale commented on GitHub (Oct 28, 2022):

I’ll look into that in the next couple of days as soon as I can. Sorry but i’m pretty busy at the moment

@Brankale commented on GitHub (Oct 28, 2022): I’ll look into that in the next couple of days as soon as I can. Sorry but i’m pretty busy at the moment
Author
Owner

@Brankale commented on GitHub (Oct 29, 2022):

I've tried with a couple of games and the issue seems to be fixed

@Brankale commented on GitHub (Oct 29, 2022): I've tried with a couple of games and the issue seems to be fixed
Author
Owner

@mnadareski commented on GitHub (Oct 30, 2022):

That's great news! This will probably mean a new stable release. Thank you for your patience.

@mnadareski commented on GitHub (Oct 30, 2022): That's great news! This will probably mean a new stable release. Thank you for your patience.
Author
Owner

@mnadareski commented on GitHub (Oct 31, 2022):

Officially released as part of https://github.com/SabreTools/NDecrypt/releases/tag/0.2.4

@mnadareski commented on GitHub (Oct 31, 2022): Officially released as part of https://github.com/SabreTools/NDecrypt/releases/tag/0.2.4
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SabreTools/NDecrypt#7