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

Bouncy Castle dependency - replaceable with in-box cryptography? #461

Closed
christophwille opened this issue Jun 3, 2023 · 6 comments · Fixed by #590
Closed

Bouncy Castle dependency - replaceable with in-box cryptography? #461

christophwille opened this issue Jun 3, 2023 · 6 comments · Fixed by #590

Comments

@christophwille
Copy link
Contributor

The four assemblies for netsparkle come in at 3.46MB, with Bouncy Castle accounting for 3.16 (2.2.2 WPF .Core distribution). That is quite a hefty "penalty" - what is Bouncy Castle used for (ie would it be possible to at least replace it on .NET (Core) with in-box cryptography?)

@christophwille christophwille changed the title Bouncy Castle dependency - replacable with in-box cryptography? Bouncy Castle dependency - replaceable with in-box cryptography? Jun 3, 2023
@christophwille
Copy link
Contributor Author

christophwille commented Jun 3, 2023

Unless I am mistaken, there is only one place in the main package, namely https://github.com/NetSparkleUpdater/NetSparkle/blob/develop/src/NetSparkle/SignatureVerifiers/Ed25519Checker.cs (AppCast generation isn't something I am concerned about as this is a dev dependency).

@Deadpikle
Copy link
Collaborator

Deadpikle commented Jun 4, 2023

You're not mistaken. That's the one place where it is used.

If you can point me to a library that is similarly trustworthy and unit tested, or a built-in way to do this in .NET that works from 4.5.2 (or 4.6.2) all the way through .NET 7+, I'd be interested in taking a look.

Alternatively, would trimming the DLL in your own application (and making sure NetSparkle was trimmable) be the solution, here? It seems as though that would allow us to continue to use BouncyCastle (with its benefits and google-ability) while not bogging down published apps.

Edit: Links for future ref: bcgit/bc-csharp#451, bcgit/bc-csharp#422, bcgit/bc-csharp#504

@Deadpikle
Copy link
Collaborator

Some additional applicable old discussion here: #98

@christophwille
Copy link
Contributor Author

Isn't NSec doing just that?

@Deadpikle Deadpikle mentioned this issue Jun 25, 2024
11 tasks
@Deadpikle
Copy link
Collaborator

Deadpikle commented Jul 6, 2024

BouncyCastle now supports trimming, and when your application is trimmed, the file size of BouncyCastle is reduced quite a bit (in my tests, to less than 50 KB). So, if your application supports trimming, this shouldn't be a problem.

If your application does not support trimming out of the box:

  • Try https://github.com/yangzhongke/Zack.DotNetTrimmer if that is reasonable for your app
  • Use the NetSparkle.Tests.Trimming app to pop open a CLI in that folder, run dotnet publish, and then use the trimmed DLL in your app. Make sure to test, first, but since DLLs can be replaced, this shouldn't pose an issue, I would imagine, and I was able to do this successfully using one of the NetSparkle test applications. Very much willing to be corrected if I'm wrong, here.

The other option I'd be willing to consider is using Chaos.NaCl (my fork here with .NET Standard compat), but that'd take some work to move in since we'd need to add in file streaming compatibility at the very least.

In any case, with the changes on BouncyCastle's side and trimming available on the NetSparkle side along with the option of just shipping a self-trimmed DLL to your users, I think this can be resolved for end users.

@Deadpikle
Copy link
Collaborator

I have again made an adjustment after seeing that the above wasn't going to result in the best experience for end users by switching fully to Chaos.NaCl, of which we have a fork here. This should fully alleviate the concerns that you shared as it is a small DLL, even without trimming, at less than 250 KB. BouncyCastle is no longer used. As a bonus, the core lib is now trimmable and AoT-compatible, so some good things came out of it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants