Skip to content

Conversation

siddharth-narayan
Copy link
Contributor

@siddharth-narayan siddharth-narayan commented Dec 11, 2024

Added openssl_quantum using oqs-provider. Adapted from my own repository. This is still standard openssl but with the added abililty to make quantum safe connections.

Post quantum cryptography is becoming more important as quantum computers become more powerful, so now that liboqs and oqs-provider are in nixpkgs, I thought I would add them to openssl as well. Maybe eventually this can even become the default openssl.

This package is the same as openssl_3_3 but with a modified configuration that points to oqs-provider so that openssl knows where to look. It also loads providers by default, so they are always active.

PQ functionality can be tested with

  • openssl list -providers
  • openssl list -kem-algorithms
  • openssl list -signature-algorithms

Resources

https://github.com/openssl/openssl/blob/master/README-PROVIDERS.md - About providers
https://github.com/open-quantum-safe/oqs-provider
https://www.nist.gov/cybersecurity/what-post-quantum-cryptography - Why post quantum cryptography is important now

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Dec 11, 2024
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Dec 12, 2024
@ofborg ofborg bot requested review from thillux and ulrikstrid December 12, 2024 03:58
@ofborg ofborg bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Dec 12, 2024
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/5043

@siddharth-narayan
Copy link
Contributor Author

@thillux @ulrikstrid Could you please take a look?

@ulrikstrid
Copy link
Member

@thillux @ulrikstrid Could you please take a look?

I'm a bit low on bandwidth currently, I can try to find some time next week for a review.

Ideally we should have a better way to load providers and engines so that we don't have to create custom packages when we want to add more providers.

@siddharth-narayan
Copy link
Contributor Author

siddharth-narayan commented Jan 5, 2025

No worries, whenever you're free!

Ideally we should have a better way to load providers and engines so that we don't have to create custom packages when we want to add more providers.

I'm not sure how this would be possible? The best thing I can think of is an "empty" default openssl package, for example named openssl_with_providers without any providers that it's possible to override later.

@thillux
Copy link
Contributor

thillux commented Jan 6, 2025

I'll probably have time again to look at this starting next week. Is there any upcoming user of this in nixpkgs? Are there any other OpenSSL providers besides TPM 2.0, esdm and oqs we can build/test this with?

I'm also not really happy with introducing a default package for every provider combination. Nevertheless, using providers should be made easier 👍.

@thillux
Copy link
Contributor

thillux commented Jan 6, 2025

We probably should update master/unstable to OpenSSL 3.4.0 on the go, as this adds more CLI options for testing key encapsulation schemes.

@siddharth-narayan
Copy link
Contributor Author

Is there any upcoming user of this in nixpkgs?

I'm not aware of any people in particular, but given that oqs-provider and liboqs were added recently, it does seem like there's at least some people who would find this useful.

Are there any other OpenSSL providers besides TPM 2.0, esdm and oqs we can build/test this with?

with-providers should work with any providers, although I don't know of any others

I'm also not really happy with introducing a default package for every provider combination.

Me neither :( unfortunately I don't know if there's a better way; Nix forces us to declare everything about the package, right?

We probably should update master/unstable to OpenSSL 3.4.0 on the go

Do you mean that should happen in this PR?

@ulrikstrid
Copy link
Member

I'm also not really happy with introducing a default package for every provider combination.

Ideally we should have a providers or something that we can pass a list of providers to add. openssl.override { providers = [ ... ]

@thillux
Copy link
Contributor

thillux commented Jan 10, 2025

We probably should update master/unstable to OpenSSL 3.4.0 on the go

Do you mean that should happen in this PR?

No, I opened #372733 for this.

@siddharth-narayan siddharth-narayan force-pushed the master branch 2 times, most recently from e5751e2 to 9d2c973 Compare January 11, 2025 08:41
@github-actions github-actions bot added 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jan 11, 2025
@nix-owners nix-owners bot requested a review from gebner January 11, 2025 08:57
@siddharth-narayan
Copy link
Contributor Author

Sorry, the PR accidentally closed after I force pushed the wrong commit!

I'm also not really happy with introducing a default package for every provider combination.

Ideally we should have a providers or something that we can pass a list of providers to add. openssl.override { providers = [ ... ]

Ah, I didn't realize that the problem was the extra provider package instead of the override being available on the normal openssl package. I've changed the code to match this suggestion, so now anyone can add their own providers with openssl.override

@siddharth-narayan siddharth-narayan force-pushed the master branch 2 times, most recently from 97057b4 to 10858f4 Compare January 11, 2025 18:02
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Jan 11, 2025
@spacekitteh
Copy link
Contributor

Perhaps a way to configure openssl similar to the way different BLAS/LAPACK implementations are selected would be a good way to go about it?

@siddharth-narayan
Copy link
Contributor Author

Perhaps a way to configure openssl similar to the way different BLAS/LAPACK implementations are selected would be a good way to go about it?

Reading over it, this implementation seems similar: somebody can use openssl.override { proivders = []; } with their own packages, similar to how someone can use lapack.override { lapackProvider = ... }

The only issue I have is with the handling of the config, which is not the nicest way to handle the config, but because it's a nonstandard format I don't see a better way.

@github-actions github-actions bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Apr 23, 2025
@spacekitteh
Copy link
Contributor

The only issue I have is with the handling of the config, which is not the nicest way to handle the config, but because it's a nonstandard format I don't see a better way.

Is it not just an INI with a global section?

@siddharth-narayan
Copy link
Contributor Author

Is it not just an INI with a global section?

It is, so I guess you could say it's standard (even though the INI format doesn't have a formal specification), but it doesn't seem like there's a way to convert to INI in Nix. It seems like there's only support for TOML.

@spacekitteh
Copy link
Contributor

There is! :) Check out lib.generators.toINIWithGlobalSection :)

@siddharth-narayan siddharth-narayan marked this pull request as draft June 22, 2025 00:14
@siddharth-narayan
Copy link
Contributor Author

@spacekitteh Thanks for the recommendation! Do you know if there's a way to go the other way from INI -> Nix? Without it, modifying the config seems like it'll be just crudely appending to whatever's already there, or sed replacement. Another option might be to rewrite the entire config in Nix, which I feel is a significantly worse approach.

@siddharth-narayan siddharth-narayan force-pushed the master branch 2 times, most recently from 4f1de91 to b3e3efe Compare August 14, 2025 19:48
@siddharth-narayan siddharth-narayan marked this pull request as ready for review August 14, 2025 20:02
@siddharth-narayan
Copy link
Contributor Author

Hi everyone, I've updated the PR to include the INI format generator, and I think it's ready for review. If there's anything you would like me to change, I'd be happy to do so.

@siddharth-narayan
Copy link
Contributor Author

@thillux @ulrikstrid If you're busy no worries, but is there anything you'd like me to change/fix up?

Copy link
Member

@ulrikstrid ulrikstrid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach. It doesn't seem to trigger a mass-rebuild (openssl seems to be cached from what I can tell) so should be fine to merge to master

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants