[crypto] Factor out OTBN RSA testing utilities. #20771
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use the same testing library for otbn_rsa_test and power_virus_systemtest. The testing library bypasses everything other than the core OTBN operation, which is helpful for tests that may have other blocks in different configurations than the cryptolib expects (e.g. entropy or HMAC).
The powervirus test is running a different RSA computation now (2K verify with slow constant computation instead of 3K verify with fast and pre-computed constant computation), so the timing of the test might change. The test doesn't run on Verilator, so I can't time it exactly. The RSA computation should get 4x faster after #19755 is merged.
At some point, it might be a good idea to use something other than RSA modexp for these two tasks, because RSA test data is kind of large and RSA decrypt takes ages. The
otbn_rsa_test
currently includes constant values that optionally disable testing decryption or testing large RSA sizes because decryption for large RSA takes too long. It seems to me like both these tests only really need to run some nontrivial OTBN computation, so maybe we could run something fast with small inputs instead for testing convenience. We could run the software SHA256, for example, or X25519 (the fastest asymmetric crypto routine according to current benchmarks), both of which would have much smaller input and faster execution than RSA. Anyway, this doesn't seem urgent enough for me to do it as part of this change; for now I just want to unblock #20495.