-
Notifications
You must be signed in to change notification settings - Fork 469
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 SPHINCS+ #1420
Update SPHINCS+ #1420
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we decide to drop the "robust" variants as per NIST's recommendation (#1245 (comment) )?
Yes, you're right. I've removed the robust variants as well as the Haraka variants (NIST's email also says they only plan to move forward with SHA2 and SHAKE variants). |
Compile runs down from 1900 to 1300 .... The environment says Thank you :) But the compile errors still confuse me: I locally have missing symbols
and the CI runs have even weirder problems. Maybe a fresh look tomorrow resolves these.... |
I did a quick pull without looking much into the changes. I recall there was a change involving removal of a Keccak-related file from the PQClean directories, but I didn't look into it. I don't think I'll get a chance to do so over the next few days, unfortunately. |
Yup -- before this PR there was a
NP; so focusing just on functionality (sphincs+ update) for the IETF hackathon I opted to simply remove the AVX2 optimizations from this PR (see #1422). This solves most build problems, but for example https://github.com/open-quantum-safe/liboqs/actions/runs/4465669616/jobs/7842995392, confirms the same results on my local machine and the (optimized) M1, namely incorrect KATs for 4 algorithms:
--> It seems the KATs introduced with this PR are not all correct. Thus, I'm afraid we cannot use this Sphincs+ update in the IETF hackathon. Agreed, @dstebila @xvzcf ? Good ideas how to facilitate that regardless very welcome. |
@baentsch @dstebila I think at least part of the problem lies with our OpenSSL SHA2 code. In the mb-remove-avx2-from-sphincs branch, compare the |
Interesting, indeed: Just by setting OQS_OPENSSL_OFF the test passes. It looks like our self tests then are also insufficient/not equivalent to the use of the API in |
I now started to look a bit into this issue and concluded that the use of the |
I've been looking into it as well, and yes it's this API that seems to be changing the KAT values. |
I believe that was a fat finger on my part. Oops! Sorry! |
Good to know :) Will you do a PR fixing this? Next question: Am I reading correctly that our code is double-freeing MD contexts: liboqs/src/common/sha2/sha2_ossl.c Lines 125 to 136 in d704da0
(when
|
The more I read this code, the less happy I am: Many OpenSSL API calls are made without checking their return values. This is not good, considering for example
(from https://www.openssl.org/docs/man3.0/man3/EVP_DigestInit_ex.html). Shall I do a PR for this or does anyone else volunteer? |
Our API expects that you call one or the other of
It is confusing that we sometimes use |
I suppose we could put some null sets/checks ( |
Since most of our hashing API has no return value (void), would you then be putting in something similar to |
And another logical question: Why is SHA2_BLOCK_SIZE defined as 64 in the OpenSSL wrapper ( liboqs/src/common/sha2/sha2_ossl.c Line 45 in d704da0
liboqs/src/common/sha2/sha2_ossl.c Lines 121 to 123 in d704da0
liboqs/src/common/sha2/sha2_c.c Lines 624 to 625 in d704da0
|
Oh! That's it! The SHA-256 block size is 64 bytes whereas the SHA-512 block size 128 bytes; in the C code it's using 64 and 128 correctly for the two different functions, but in the ossl wrapper it's using 64 everywhere. |
The last question indeed resolves the problem with the KATs: This diff resolves the issue:
|
Hold on, isn't the SHA384 block size also 128 bytes? |
Before we get too excited, about declaring this resolved, I think we should also strengthen the OQS test programs to detect this flaw. |
Most definitely. And strengthen the way we use the OpenSSL APIs. Let's talk about this... now :) |
* correct ARM SHA3 extension addition * correct compile option for ARM SHA * following https://developer.arm.com/documentation/101754/0618/armclang-Reference/armclang-Command-line-Options/-march * correct SHA3 enablement
This reverts commit f57ed6d.
* AVX2 test * AVX2 test * add patch; correct aarch64; correct documentation * enable Keccak for Sphincs even if OpenSSL shall provide SHA3 * properly handle xkcp enablement if only specific algorithms are selected * correct conditional setting * re-enable XKCP for other platforms * Windows support * alternate pqcrystals-AES removal
2b36cdd
to
1f267d5
Compare
If I can get a once over and 1-2 approvals on this it should be good to merge |
Done. But it doesn't feel quite right that I give an approval on this as all changes done to get this to "green" were done by me in #1460. But if that got a good review, I think we're good to move forward. |
Thanks for this merge, @xvzcf . Are you going to look into the downstreams now? For oqs-openssl111 it should be as simple as copying over generate.yml from oqs-provider (if open-quantum-safe/oqs-provider#158 still passes OK after the #1420 merge). |
I'm working on it, I'm updating the names in liboqs first and then I'll update the downstreams |
SPHINCS+ was updated in liboqs (open-quantum-safe/liboqs/pull/1420), and this makes old keys incompatible with the new implementation. New keys were generated using the oqs-provider for OpenSSL 3 openssl genpkey \ -provider default -provider oqsprovider \ -algorithm sphincsshake128fsimple \ -outform der \ -out bench_sphincs_fast_level1_key.der And certs_test.h was updated with these new keys using xxd xxd -i -c 10 -u bench_sphincs_fast_level1_key.der This was repeated for the 6 variants of SPHINCS+ that wolfSSL supports.
This also adds new keys for SPHINCS+. The reason is that SPHINCS+ was updated to 3.1 in liboqs (open-quantum-safe/liboqs/pull/1420), and old keys are incompatible with the new implementation. Keys were generated using the oqs-provider for OpenSSL 3 openssl genpkey \ -provider default -provider oqsprovider \ -algorithm sphincsshake128fsimple \ -outform der \ -out bench_sphincs_fast_level1_key.der And certs_test.h was updated using xxd xxd -i -c 10 -u bench_sphincs_fast_level1_key.der This was repeated for the 6 variants of SPHINCS+ that wolfSSL supports.
Fixes #1249.