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

Split the BouncyCastle.Cryptography library into feature groups. #451

Open
webprofusion-chrisc opened this issue Apr 17, 2023 · 3 comments

Comments

@webprofusion-chrisc
Copy link

webprofusion-chrisc commented Apr 17, 2023

Currently (2.2.0) the BouncyCastle.Cryptography.dll is just over 7MB and this has recently increased (it's double the old Portable.BouncyCastle dll size). In my application this accounts for almost a third of the installer size.

I would like to propose that the build be split into a Core for shared and or/essential parts, with additional DLLs (and therefore nugets) for other parts or exotic features, for instance I'm using the following namespaces:

using Org.BouncyCastle.Asn1.Sec;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Crypto.EC;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Operators;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Prng;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Ocsp;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;

Splitting into separate DLLs would allows apps which cannot using trimming to still only include the functionality they need,
With feature groups in packages the download stats could be monitored to assess the relative popularity of feature groups, Future security problems in one are would not affect the SBOM for apps which simply don't include that feature.

A (full) BouncyCastle.Cryptography package could be retained for those who want to include the whole thing.

It's possible that interdependency between parts of the library prevent this from being a workable solution but I'd like to raise the issue for discussion at least.

@webprofusion-chrisc
Copy link
Author

webprofusion-chrisc commented Apr 17, 2023

Example parts that happily delete without affecting the build and reduce the dll to 2.4MB:

  • pqc
  • openpgp
  • bcpg
  • tls
  • tsp

@patagonaa
Copy link

If file size is a design goal for your app, depending on a few things, maybe trimming self-contained applications could be useful to you too (though it has some limitations). From my understanding, it should already remove all unused code, from both the app itself and libraries.

@webprofusion-chrisc
Copy link
Author

@patagonaa thanks for your reply, I'm targeting net462 currently so I don't think that trimming would work for me, currently I'm using my own fork to trim the build instead,

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

No branches or pull requests

2 participants