-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(bignum): Add initial hardware acceleration for modular exponentiation #24
Conversation
I think this already looks quite good It's quite annoying, that we cannot reduce that For safety Probably we can get rid of a few U256::LIMBS => {
let mut mod_exp = RsaModularExponentiation::<operand_sizes::Op256>::new(
&mut rsa,
core::mem::transmute(Y.private_p), // exponent (Y) Y_MEM
core::mem::transmute(M.private_p), // modulus (M) M_MEM
compute_mprime(M), // mprime
);
mod_exp.start_exponentiation(
core::mem::transmute(X.private_p), // X_MEM
core::mem::transmute(rinv.private_p), // Z_MEM
);
mod_exp.read_results(core::mem::transmute((*Z).private_p));
} It's scary and unsafe but not really more unsafe than copying the bytes I guess |
4b9832a
to
e07a82c
Compare
I rebased this off master. I added an argument for The I tried switching over to memory transmuting, and it doesn't seem to work. I couldn't get the self-tests to pass. |
e07a82c
to
0914830
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.
Awesome, thanks! Great job
This is based on #20, where I isolated the
modular exponentiation
part to break down the PR into smaller chunks.This uses the hardware RSA accelerator to use hardware acceleration for bignum operations.
Support:
*DNC: Did not compile. region
dram_seg
overflowed by X bytes*HO: Heap Overflow. The request ran out of heap space.
— : No support. Currently, I did not add support for the esp32 as it acts differently.
@bjoernQ I'm pinging you since you're most likely going to be the one doing a review on this. Feel free to tear down this code to make it safer / faster. The
match num_words {}
section could be done using a macro since it's repetition. I still don't know what's the optimal way to implement this. We cannot use generics since the implementation in the HAL uses structs to define the size of the operands.