Skip to content

Put Crypto Libraries Behind A Trait#75

Merged
njaremko merged 4 commits intonjaremko:masterfrom
WiresmithTech:crypto_refactor
Oct 15, 2025
Merged

Put Crypto Libraries Behind A Trait#75
njaremko merged 4 commits intonjaremko:masterfrom
WiresmithTech:crypto_refactor

Conversation

@JamesWiresmith
Copy link
Copy Markdown
Contributor

Apologies for the rather large drive-by PR but this should make maintenance easier going forward I hope.

Background

The driving factor behind this change is:

  1. I need to try and support this on Windows and would like to be able to swap out the xmlsec primitives for windows native functions if it is too complex to get xmlsec building on Windows.
  2. I'm hoping this isolation will make it easier to look at fixing breaking changes with upgrades in libxml2 and xmlsec. I believe I've seen one on AlmaLinux 10 which needs investigating.

Concept

By putting the crypto functions behind an interface we are able to swap the backends out more easily. The xmlsec dependencies are all contained to the crypto module.

The feature flags set a public type which will point to the active crypto method. This removes having the xmlsec flags over all of the code and I think moves back to making xmlsec optional (but will throw errors if crypto functions are required).

Still To Do

I think this PR is complete but there is still more to do to complete the transformation that I need:

  1. Integrate the URL signing with the pluggable crypto - this still directly requires OpenSSL. This could potentially remain separate though so that there is support for alternative signing such as Add RustCrypto feature  #42 - though I'm not sure if there is a clear benefit.
  2. Review the xmlsec bindings to either go back to the existing crate (not sure of the changes) or make sure this is buildable on Windows.

Let me know if that looks good. I'm going to need this capability at some point so it would be great to have it upstream.

Pulled the key crypto functions behind an interface so we can disable
xmlsec without the same quantity of feature flags.

This still doesn't fully compile with xmlsec disabled but tests still
pass with it enabled.
Cleanup clippy lints and wrapped one more function that was found to be
used for crypto
* Remove references to OpenSSL from core functions which means
  abstracting certs and private keys.
* Moved URL signing to the url_verification module to avoid OpenSSL
  dependency in service provider.
* Just URL Verifier now depends directly on primitives.
@njaremko
Copy link
Copy Markdown
Owner

njaremko commented Sep 23, 2025

Thanks for this @JamesMc86

I'll try to give you a review today or tomorrow.

@njaremko
Copy link
Copy Markdown
Owner

njaremko commented Oct 7, 2025

I dropped the ball on this, I'll review tonight 👍

@JamesWiresmith
Copy link
Copy Markdown
Contributor Author

Thanks! No worries, I know what it can be like

@njaremko njaremko merged commit bf216a9 into njaremko:master Oct 15, 2025
@njaremko
Copy link
Copy Markdown
Owner

Merged, thank you for your patience with me @JamesMc86

@JamesWiresmith
Copy link
Copy Markdown
Contributor Author

Fantastic thanks, I appreciate this was a big PR. Hopefully new ones will be more straightforward!

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

Successfully merging this pull request may close these issues.

2 participants