-
Notifications
You must be signed in to change notification settings - Fork 896
[crypto/rsa] Use run_rsa_modexp
in testutils/pentesting
#28354
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
[crypto/rsa] Use run_rsa_modexp
in testutils/pentesting
#28354
Conversation
a18af45
to
da9c85c
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.
Thanks Andi.
Just two minor comments from my side.
.equ MODE_RSA_4096_MODEXP, 0x70b | ||
.equ MODE_RSA_4096_MODEXP_F4, 0x0ee | ||
|
||
# Testing only! These key lengths are not supported. |
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.
What do you mean with this? If it is not supported why are we have this here?
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.
Both otcrypto
and pentesting
use RSA-512 and RSA-1024 for tests. I'm making it explicit here,
that we cannot support them for anything other than tests because both are insecure.
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.
Before there was a hack that bypassed the cryptolib API in order to force the usage of RSA-512
and RSA-1024
. I don't think it should be done that way.
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.
Thanks for the explanation, makes sense!
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.
we dont save code size by removing support for short key sizes, right?
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.
No, because the implementation is independent of the key size.
|
||
uint32_t n_limbs = size_bytes / kOtbnWideWordBytes; | ||
if (n_limbs == 0 || n_limbs > 16) { | ||
if (size_bytes == 0 || size_bytes > 512) { |
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.
Do we have an enum for these 512 bits somewhere?
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.
Ah we actually don't need this, right? Because above the switch case should already check size_bytes.
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.
Correct, I removed it.
|
||
uint32_t n_limbs = size_bytes / kOtbnWideWordBytes; | ||
if (n_limbs == 0 || n_limbs > 16) { | ||
if (size_bytes == 0 || size_bytes > 512) { |
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.
Ah we actually don't need this, right? Because above the switch case should already check size_bytes.
.equ MODE_RSA_4096_MODEXP, 0x70b | ||
.equ MODE_RSA_4096_MODEXP_F4, 0x0ee | ||
|
||
# Testing only! These key lengths are not supported. |
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.
Thanks for the explanation, makes sense!
Use the proper `run_rsa_modexp` OTBN app instead of the orthogonal `rsa.s` for all (pen-)testing functions. Signed-off-by: Andrea Caforio <[email protected]>
da9c85c
to
107aa7f
Compare
Use the proper
run_rsa_modexp
OTBN app instead of the orthogonalrsa.s
for all (pen-)testing functions.