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

Update supported algorithms #163

Closed
geedo0 opened this issue Jul 26, 2024 · 5 comments
Closed

Update supported algorithms #163

geedo0 opened this issue Jul 26, 2024 · 5 comments
Assignees

Comments

@geedo0
Copy link

geedo0 commented Jul 26, 2024

The supported algorithms here no longer align with the supported algorithms in liboqs here. We need to update the algorithms supported in the OpenSSH OQS fork back in line.

I went through the two lists by hand to identify all the mismatches since the last time these algorithms were updated. I can use some help from the maintainers as to how these newer algorithms should be brought into OpenSSH. Some specific questions off the top of my head:

  • If they should be brought in at all.
  • How they should be named/renamed.
  • Hybrid/Hash pairing for the algorithms.

Listing of algorithms that exist in liboqs, but not in OpenSSH and some initial notes/thoughts:

  • BIKE Round-4
    • Adds a new parameter set BIKE-L5.
    • Existing KEX names are qualified with r3 and need to be updated.
  • ML-KEM and ML-DSA IPD
    • Forthcoming NIST standards for Kyber/Dilithium.
    • Follow conventions set by the pre-NIST implementation?
    • Some names/pairings are proposed here
    • The security levels in the draft RFC do not align on the security levels which is the convention followed by the OQS library
    • The draft RFC uses x25519, need to figure out how to wire that up.
    • The IPD version exists in OQS and an alias without the IPD qualifier is provided.
  • sntrup761
    • This would allow interop with upstream OpenSSH
    • Also would conflict with upstream OpenSSH implementation
    • Upstream name [email protected]
  • Falcon PADDED format
    • Existing KEX uses the COMPRESSED format.
  • MAYO
    • New signature algorithm
  • XMSS and LMS
    • Stateful algorithms not suitable for SSH signatures.
@baentsch
Copy link
Member

At the time when oqs-openssh and oqs-openssl were equally well supported by OQS, their code-generator scripts were closely in sync, thus creating a very similar user "config experience".

And that's what I'd suggest trying to achieve again. If you could subscribe to this goal, @geedo0 , please check out the oqsprovider code generator config file: It documents "user-level" algorithm names, incl. hybrid and composite ones, incl. the "co-related" classic algs' strengths. If you don't like to work with .yml, this file is generated from it for better readability.

As per your specific per-algorithm questions, my suggestions would thus be as follows:

  • Bike, Mayo, Falcon, ML-KEM/DSA: Use oqsprovider config as-is (i.e., add new "openssh" alg monikers; in the case of ML-*, oqsprovider promises to shield its users from any NIST last-minute changes in that the name will persist, but the algorithm logic will adapt to any changes in spec. In other words, mlkem/mldsa can be requested by users and currently will be implemented by the -ipd code and in the future by a possibly different, finally standardized, code. )
  • sntrup761: That's a challenge -- but its use in openssh is actually the only reason why liboqs still supports it. My personal preference would be to see what it takes to achieve interop with the version openssh anyway supports (e.g., by way of creating an "oqssntrup761x25519" hybrid and running that against what "baseline" openssh has built-in). If this were possible, we should pause and talk: Personally, I'd then completely drop "sntrup761" from OQS for good. If this were not possible, well, we also need to talk and understand what's the problem then. Personally, I'd most likely suggest checking whether that variant would interop with the "oqs-opensshv8" version -- and if so, keep it. If not, drop it (why keep something that cannot talk with anything else?).
  • XMSS/LMS: Unusable

@geedo0
Copy link
Author

geedo0 commented Jul 29, 2024

Yes, that's exactly the goal I had in mind. Get OpenSSH up to date and back in-line with the other OQS projects.

From your oqsprovider pointer, getting the new algorithm support in-line ooks straightforward. The only new issue I noticed is that there are hybrid algorithms for x448/x25519, this would be new development for the OpenSSH fork. Here's a proposal for the plan of attack:

  1. Add missing algorithm support for Mayo, Bike, Falcon, ML-KEM, ML-DSA with conventional naming/hybrids.
  2. Rename Bike to use the round 4 qualifier.
  3. Match ML-KEM's naming and hybrids to the draft RFC's specifications (omit x25519 implementation for now).
  4. Look into the work around sntrup761 and align on a path forward for OQS.
  5. Look into x448/x25519 support for oqs-openssh.

I've got the items 1-3 on-deck, but need to get PR #161 and #162 merged before I can submit.

geedo0 added a commit to geedo0/openssh that referenced this issue Aug 1, 2024
This aligns the algorithms supported by the OQS OpenSSH fork with the algorithms available in liboqs.

- Added support for ML-KEM-IPD using the ML-KEM alias and the names/curves documented by the [PQ SSH draft RFC](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/).
- Added support for ML-DSA-IPD using the ML-DSA alias following the conventions from the Dilithium implementation. The Dilithium signatures have been disabled.
- Updated from BIKE Round 3 to Round 4. This adds a new parameter set for BIKE-L5.
- Added support for the Falcon PADDED format. It is disabled by default to preserve entries in the bit-mask.
- Added support for MAYO. The level 1 variant is left disabled.

The KEX algorithms specified by the draft RFC do not match the security
level pairing convention followed by Kyber so we chose to prefer the
pairings specified in the document. There were no proposed parameter
sets for ML-KEM-512 so we defaulted to the conventional parameters.
x25519 hybrids are currently not handled by the oqs-openssh fork so
we've omitted `mlkem768x25519-sha256` support for now.

This does not add support for sntrup761 as that requires handling the conflict with the upstream OpenSSH implementation.

Related to Issue open-quantum-safe#163
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 1, 2024
This adds support for hybrid-PQ key exchanges with x25519. This allows for the implementation of `mlkem768x25519-sha256` as defined by [draft-kampanakis-curdle-ssh-pq-ke-02](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/) and `[email protected]` as defined by upstream OpenSSH. We also take the opportunity to add hybrid implementations for all existing PQ key exchanges which supported NIST P-256. Due to the conflicting implementation for `[email protected]` we omit an OQS exclusive version for now and will plan for it in a future PR. Unlike in `oqs-provider`, we cannot provide support for x448 hybrid algorithms since the x448 algorithm is not available within OpenSSH.

The way this all works is by introducing a new source file `kexoqsx25519.c` which is a synthesis of `kexoqsecdh.c` and `kexsntrup761x25519.c`. These files provide example implementations of hybrid-PQ for OQS-backed algorithms and x25519 usage. In that source file, we define functions to implement OpenSSH's KEX interface for each hybrid algorithm using an `oqs-template` file. Within the `generate.yml`, we add a new boolean key to flag `x25519` hybrids similar to how the `rsa` key works for hybrid signatures.

Related to issue open-quantum-safe#163.
@geedo0 geedo0 self-assigned this Aug 6, 2024
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 13, 2024
This aligns the algorithms supported by the OQS OpenSSH fork with the algorithms available in liboqs.

- Added support for ML-KEM-IPD using the ML-KEM alias and the names/curves documented by the [PQ SSH draft RFC](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/).
- Added support for ML-DSA-IPD using the ML-DSA alias following the conventions from the Dilithium implementation. The Dilithium signatures have been disabled.
- Updated from BIKE Round 3 to Round 4. This adds a new parameter set for BIKE-L5.
- Added support for the Falcon PADDED format. It is disabled by default to preserve entries in the bit-mask.
- Added support for MAYO. The level 1 variant is left disabled.

The KEX algorithms specified by the draft RFC do not match the security
level pairing convention followed by Kyber so we chose to prefer the
pairings specified in the document. There were no proposed parameter
sets for ML-KEM-512 so we defaulted to the conventional parameters.
x25519 hybrids are currently not handled by the oqs-openssh fork so
we've omitted `mlkem768x25519-sha256` support for now.

This does not add support for sntrup761 as that requires handling the conflict with the upstream OpenSSH implementation.

Related to Issue open-quantum-safe#163

Signed-off-by: gcr <[email protected]>
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 13, 2024
This aligns the algorithms supported by the OQS OpenSSH fork with the algorithms available in liboqs.

- Added support for ML-KEM-IPD using the ML-KEM alias and the names/curves documented by the [PQ SSH draft RFC](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/).
- Added support for ML-DSA-IPD using the ML-DSA alias following the conventions from the Dilithium implementation. The Dilithium signatures have been disabled.
- Updated from BIKE Round 3 to Round 4. This adds a new parameter set for BIKE-L5.
- Added support for the Falcon PADDED format. It is disabled by default to preserve entries in the bit-mask.
- Added support for MAYO. The level 1 variant is left disabled.

The KEX algorithms specified by the draft RFC do not match the security
level pairing convention followed by Kyber so we chose to prefer the
pairings specified in the document. There were no proposed parameter
sets for ML-KEM-512 so we defaulted to the conventional parameters.
x25519 hybrids are currently not handled by the oqs-openssh fork so
we've omitted `mlkem768x25519-sha256` support for now.

This does not add support for sntrup761 as that requires handling the conflict with the upstream OpenSSH implementation.

Related to Issue open-quantum-safe#163

Signed-off-by: gcr <[email protected]>
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 13, 2024
This aligns the algorithms supported by the OQS OpenSSH fork with the algorithms available in liboqs.

- Added support for ML-KEM-IPD using the ML-KEM alias and the names/curves documented by the [PQ SSH draft RFC](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/).
- Added support for ML-DSA-IPD using the ML-DSA alias following the conventions from the Dilithium implementation. The Dilithium signatures have been disabled.
- Updated from BIKE Round 3 to Round 4. This adds a new parameter set for BIKE-L5.
- Added support for the Falcon PADDED format. It is disabled by default to preserve entries in the bit-mask.
- Added support for MAYO. The level 1 variant is left disabled.

The KEX algorithms specified by the draft RFC do not match the security
level pairing convention followed by Kyber so we chose to prefer the
pairings specified in the document. There were no proposed parameter
sets for ML-KEM-512 so we defaulted to the conventional parameters.
x25519 hybrids are currently not handled by the oqs-openssh fork so
we've omitted `mlkem768x25519-sha256` support for now.

This does not add support for sntrup761 as that requires handling the conflict with the upstream OpenSSH implementation.

Related to Issue open-quantum-safe#163

Signed-off-by: gcr <[email protected]>
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 21, 2024
This aligns the algorithms supported by the OQS OpenSSH fork with the algorithms available in liboqs.

- Added support for ML-KEM-IPD using the ML-KEM alias and the names/curves documented by the [PQ SSH draft RFC](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/).
- Added support for ML-DSA-IPD using the ML-DSA alias following the conventions from the Dilithium implementation. The Dilithium signatures have been disabled.
- Updated from BIKE Round 3 to Round 4. This adds a new parameter set for BIKE-L5.
- Added support for the Falcon PADDED format. It is disabled by default to preserve entries in the bit-mask.
- Added support for MAYO. The level 1 variant is left disabled.

The KEX algorithms specified by the draft RFC do not match the security
level pairing convention followed by Kyber so we chose to prefer the
pairings specified in the document. There were no proposed parameter
sets for ML-KEM-512 so we defaulted to the conventional parameters.
x25519 hybrids are currently not handled by the oqs-openssh fork so
we've omitted `mlkem768x25519-sha256` support for now.

This does not add support for sntrup761 as that requires handling the conflict with the upstream OpenSSH implementation.

Related to Issue open-quantum-safe#163

Signed-off-by: Gerardo Ravago <[email protected]>
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 21, 2024
This adds support for hybrid-PQ key exchanges with x25519. This allows for the implementation of `mlkem768x25519-sha256` as defined by [draft-kampanakis-curdle-ssh-pq-ke-02](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/) and `[email protected]` as defined by upstream OpenSSH. We also take the opportunity to add hybrid implementations for all existing PQ key exchanges which supported NIST P-256. Due to the conflicting implementation for `[email protected]` we omit an OQS exclusive version for now and will plan for it in a future PR. Unlike in `oqs-provider`, we cannot provide support for x448 hybrid algorithms since the x448 algorithm is not available within OpenSSH.

The way this all works is by introducing a new source file `kexoqsx25519.c` which is a synthesis of `kexoqsecdh.c` and `kexsntrup761x25519.c`. These files provide example implementations of hybrid-PQ for OQS-backed algorithms and x25519 usage. In that source file, we define functions to implement OpenSSH's KEX interface for each hybrid algorithm using an `oqs-template` file. Within the `generate.yml`, we add a new boolean key to flag `x25519` hybrids similar to how the `rsa` key works for hybrid signatures.

Related to issue open-quantum-safe#163.
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 21, 2024
This adds support for hybrid-PQ key exchanges with x25519. This allows for the implementation of `mlkem768x25519-sha256` as defined by [draft-kampanakis-curdle-ssh-pq-ke-02](https://datatracker.ietf.org/doc/draft-kampanakis-curdle-ssh-pq-ke/) and `[email protected]` as defined by upstream OpenSSH. We also take the opportunity to add hybrid implementations for all existing PQ key exchanges which supported NIST P-256. Due to the conflicting implementation for `[email protected]` we omit an OQS exclusive version for now and will plan for it in a future PR. Unlike in `oqs-provider`, we cannot provide support for x448 hybrid algorithms since the x448 algorithm is not available within OpenSSH.

The way this all works is by introducing a new source file `kexoqsx25519.c` which is a synthesis of `kexoqsecdh.c` and `kexsntrup761x25519.c`. These files provide example implementations of hybrid-PQ for OQS-backed algorithms and x25519 usage. In that source file, we define functions to implement OpenSSH's KEX interface for each hybrid algorithm using an `oqs-template` file. Within the `generate.yml`, we add a new boolean key to flag `x25519` hybrids similar to how the `rsa` key works for hybrid signatures.

Related to issue open-quantum-safe#163.

Signed-off-by: Gerardo Ravago <[email protected]>
@tttekk
Copy link

tttekk commented Aug 24, 2024

Thank you for your hard work. I am studying this project.
I have some concerns about the following function, so I would like to post it.
If you have already noticed this, please discard it.

kex_kem_generic_with_x25519_enc

  /* generate and encrypt KEM key with client key */
  if (OQS_KEM_encaps(kem, public_key, private_key, client_pub)
      != OQS_SUCCESS) {
+   r = SSH_ERR_LIBCRYPTO_ERROR; // I don't know if this definition is good.
    goto out;
  }
  client_pub += kem->length_public_key;
  public_key += kem->length_ciphertext;
- private_key += kem->length_shared_secret; // I think this is unnecessary.

@geedo0
Copy link
Author

geedo0 commented Aug 26, 2024

Feel free to drop that as a comment directly on PR #169 which is still open. I agree that incrementing private_key is unnecessary. The error code is more subjective. Looking at ssherr.h, there doesn't seem to be a better error code than SSH_ERR_LIBCRYPTO_ERROR which suggests an error in the underlying libcrypto (i.e. OpenSSL). In this case, I understand that the library that's returning an error is liboqs but I'd prefer the more precise albeit slightly inaccurate error code over SSH_ERR_INTERNAL_ERROR or introducing a whole new series of error codes for this.

geedo0 added a commit to geedo0/openssh that referenced this issue Aug 26, 2024
`[email protected]` is a PQ key exchange algorithm available in upstream OpenSSH. This implements that algorithm using the sntrup761 implementation within liboqs. Using this, we are able to demonstrate interop with upstream OpenSSH for this specific algorithm and more generally the construction of the hybrid combiner. While sntrup761 has fallen out of fashion, we have received [reassurances](open-quantum-safe/liboqs#1328 (comment)) from upstream OpenSSH that it will be supported until at least 2027.

Support for the algorithm is added by adding the necessary entry to `generate.yml` and generating the relevant code snippets. In addition, we had to address the conflicting implementation from upstream by disabling the preprocessor macro and/or removing the conflicting code segment.

Related to Issue open-quantum-safe#163
geedo0 added a commit to geedo0/openssh that referenced this issue Aug 26, 2024
`[email protected]` is a PQ key exchange algorithm available in upstream OpenSSH. This implements that algorithm using the sntrup761 implementation within liboqs. Using this, we are able to demonstrate interop with upstream OpenSSH for this specific algorithm and more generally the construction of the hybrid combiner. While sntrup761 has fallen out of fashion, we have received [reassurances](open-quantum-safe/liboqs#1328 (comment)) from upstream OpenSSH that it will be supported until at least 2027.

Support for the algorithm is added by adding the necessary entry to `generate.yml` and generating the relevant code snippets. In addition, we had to address the conflicting implementation from upstream by disabling the preprocessor macro and/or removing the conflicting code segment.

Testing

Updated `try_connection.py` to accept a specific KEX and/or SIG to test. This allows us to test arbitrary algorithms against arbitrary SSH implementations including the upstream OpenSSH. It was necessary to add a classical signature to the test so that there would be a supported signature in upstream OpenSSH that OQS could test against. In a follow-up PR I plan to add a CI job to do this, but am running short on time this week.

Related to Issue open-quantum-safe#163

Signed-off-by: Gerardo Ravago <[email protected]>
@geedo0
Copy link
Author

geedo0 commented Aug 27, 2024

Algorithm support is now fully in sync with liboqs.

@geedo0 geedo0 closed this as completed Aug 27, 2024
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

3 participants