-
Notifications
You must be signed in to change notification settings - Fork 130
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
Add 64-bit fixslice AES implementation #180
Conversation
@peterdettman it'd be good to preserve both the 32-bit and 64-bit backends, but select which one to use based on the host CPU. You can do something like: #[cfg(target_pointer_width = "32")]
mod fixslice32;
#[cfg(target_pointer_width = "64")]
mod fixslice64; If you're having trouble, the |
Benchmarks look very nice:
|
@tarcieri Yeah, I certainly want both to coexist, but I'd really prefer to leave the cfg stuff to you. It's not just cfg either; the 64-bit version does 4 blocks at a time (instead of 2) and somehow the encrypt_block(s) methods in impl.rs will need to know how many blocks the inner implementation is handling. |
@peterdettman okay, if you'd like I can try to handle the gating. How about renaming the existing implementation to
Can you make them all 8 for now and add a TODO to change I think there's also some discussion to be had there. Perhaps we should try to align all of the implementations exposed via the Edit: opened an issue about changing |
77fb1f9
to
52ea649
Compare
OK, I've renamed fixslice.rs to fixslice32.rs and lib.rs now switches b/w them on |
aes/aes-soft/src/impls.rs
Outdated
@@ -24,6 +24,7 @@ macro_rules! define_aes_impl { | |||
$key_size:ty, | |||
$rounds:expr, | |||
$rounds2:ty, | |||
$fixslice_blocks:expr, |
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.
Since this is the same for all impls it doesn't need to be a macro parameter
aes/aes-soft/src/impls.rs
Outdated
@@ -70,7 +71,7 @@ macro_rules! define_aes_impl { | |||
|
|||
#[inline] | |||
fn encrypt_block(&self, block: &mut Block) { | |||
let mut blocks = [Block::default(); 2]; | |||
let mut blocks = [Block::default(); $fixslice_blocks]; |
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.
You can use the FIXSLICE_BLOCKS
constant directly here:
let mut blocks = [Block::default(); $fixslice_blocks]; | |
let mut blocks = [Block::default(); FIXSLICE_BLOCKS]; |
aes/aes-soft/src/impls.rs
Outdated
@@ -85,7 +86,7 @@ macro_rules! define_aes_impl { | |||
|
|||
#[inline] | |||
fn encrypt_blocks(&self, blocks: &mut ParBlocks) { | |||
for chunk in blocks.chunks_mut(2) { | |||
for chunk in blocks.chunks_mut($fixslice_blocks) { |
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.
...also here:
for chunk in blocks.chunks_mut($fixslice_blocks) { | |
for chunk in blocks.chunks_mut(FIXSLICE_BLOCKS) { |
@peterdettman looks great aside from one nit! After landing this, I can expand the CI config to run the tests on 32-bit architectures as well as add some |
- protoype: replaces 32-bit in lib.rs, impls.rs
52ea649
to
cb1b278
Compare
Fixed nits and rebased. |
@tarcieri I’d be interested in seeing some arm (32/64) benchmarks for these fixslice implementations. |
@peterdettman I'll be looking into benchmarking it on Cortex-A and Cortex-M (32-bit). Somewhere around here I have some |
Not familiar enough with rust to attempt configuration settings.