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

ML-KEM doesn't perform encapsulation key check #1951

Open
ueno opened this issue Oct 15, 2024 · 3 comments
Open

ML-KEM doesn't perform encapsulation key check #1951

ueno opened this issue Oct 15, 2024 · 3 comments
Labels
enhancement New feature or request help wanted Asking for support from non-core team

Comments

@ueno
Copy link
Contributor

ueno commented Oct 15, 2024

Describe the bug
When encapsulating, FIPS 203 7.1 suggests checking input key so any integers in the encoded public key are in the range [0, q - 1]. However, the current liboqs code seems to omit this check.

To Reproduce
Steps to reproduce the behavior:

  1. Compile the attached test-kem.c with: gcc -o test-kem test-kem.c $(pkg-config liboqs --cflags --libs)
  2. Run test-kem
  3. You will see: test-kem: test-kem.c:48: main: Assertion 'rc != OQS_SUCCESS' failed.

Expected behavior
The program should exit normally.

Environment (please complete the following information):

  • OS: Fedora Linux 40
  • OpenSSL version 3.2.2
  • Compiler version used gcc 14.2.1
  • Build variables used -DBUILD_SHARED_LIBS=ON -DOQS_USE_AES_OPENSSL=ON -DOQS_USE_AES_INSTRUCTIONS=OFF -DOQS_DIST_BUILD=ON -DOQS_ALGS_ENABLED=STD_IANA -DOQS_USE_SHA3_OPENSSL=ON -DOQS_DLOPEN_OPENSSL=ON -DCMAKE_BUILD_TYPE=Debug -LAH
  • liboqs version 0.11.0

Additional context
This was found when running a tlsfuzzer test script currently in development, against gnutls-serv (in MR).

@SWilson4
Copy link
Member

Thanks for the report, @ueno. We pull our ML-KEM implementation from the pq-crystals/kyber repo. It seems to me that it would be better to add the optional checks upstream and then integrate the updated code into liboqs. Would you agree with that assessment?

As an aside, I don't believe we support the STD_IANA value for the OQS_ALGS_ENABLED variable—I assume this is something from a fork?

@SWilson4
Copy link
Member

Also tagging @bhess as he is the one most familiar with the CRYSTALS algorithms.

@bhess
Copy link
Member

bhess commented Oct 15, 2024

Thanks for the report, input validation still needs to be added upstream, see pq-crystals/kyber#87 (comment)

@SWilson4 SWilson4 added enhancement New feature or request help wanted Asking for support from non-core team labels Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Asking for support from non-core team
Projects
Status: Todo
Development

No branches or pull requests

3 participants