-
Notifications
You must be signed in to change notification settings - Fork 792
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
[cryptotest] Add test coverage of HMAC streaming API #23493
base: master
Are you sure you want to change the base?
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.
Rust LGTM, thanks
5051d52
to
78eb1af
Compare
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.
LGTM, thanks @RyanTorok.
nit: Digest/tag sizes are exposed through cryptolib-API's hash.h
now, which is included in mac.h
. I recently refactored some other tests to reuse these exposed enums. E.g. kOtcryptoHmacTagBytesSha256
-> kSha256DigestWords
.
Because of the amount of vectors in SHA-2, I cannot get past 2h timeout on FPGA. Am I missing another timeout parameters besides the one defined below?
timeout = "long", |
The test should respect the timeout that's there. If you're timing out, you can try changing |
78eb1af
to
c25ad2b
Compare
Refactored to use the constants in |
I am setting |
I find the timeout very surprising; HMAC should be fast. I'm worried this means we're missing a performance issue in the C code. How many test vectors are there exactly? Is the test progressing through them at a steady rate or taking much longer on some than others? |
The test timeouts (at 2h mark) at the following test:
There are two immediate things to improve in the driver that I am aware of:
However I am not sure these alone should justify the speed. I will investigate to see why it's taking so long. |
There's a lot of hash test vectors, and quite a few of them are intentionally very long messages that take on the order of seconds to hash on a CW310. I recall the entire job taking over an hour for me, the last time I ran the whole thing. Regarding your concern about the performance of HMAC, recall that the hash test job also includes SHA-3 and SHAKE, which are currently software backed, I think. One practical option would be to split the job up by high-level algorithm, i.e. one job for SHA-2, one for SHA-3, and one for SHAKE. |
c25ad2b
to
3e21972
Compare
We should make this change so that we can include the SHA2 and HMAC vectors as part of the hmac sign-off. I would prefer if there is a separate target per configuration: e.g. Let's get this PR in, and then we can work on the required refactoring. |
But according to the printout, it's timing out after 632 tests. I'd expect a hardware HMAC to get through a lot more than that in 2h on an FPGA. I'm still a little worried that we're missing a performance issue here. But it shouldn't block the PR; either the issue is in the test code (in which case it's not a huge deal) or it's not being introduced here, just detected. |
Yes, it timeouts before SHAKE/SHA3 vectors. I think the number of tests do not mean much in this case. The message length seems to be throttling the speed. For comparison, |
I ran a simple experiment that runs 100 SHA-512 operations with 4KByte message blocks, by modifying
I get the following time measurements on CW340.
I suspect that the cryptotest and communicating with FPGA is the bottleneck for tests that have large message inputs. |
Thanks for the experiments, @ballifatih ! I agree that given your results (reasonably fast tests even with large, streamed input) it seems likely that communication with the FPGA could be the culprit in terms of performance. It'd still be good to resolve, but that's much better than the bottleneck being in the actual library 🙂 |
23335 added a streaming API for HMAC utilizing the HMAC HWIP. Here, we add support in the cryptotest framework to cover the streaming API, modeled after how this is done for the existing streaming APIs for SHA-2. Signed-off-by: Ryan Torok <[email protected]>
3e21972
to
87e3c1a
Compare
Rebased to master to resolve merge conflict with #23518 |
Adds test coverage in the cryptotest framework for the HMAC streaming API added in #23335. The testing is modeled after how the streaming coverage was done for SHA-2 in #21281.
The second commit uncomments the hash algorithm tests in the BUILD file, which were accidentally commented out in a previous commit.
See also: #23471