-
Notifications
You must be signed in to change notification settings - Fork 131
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
dbl: Refactor to avoid unsafe #688
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.
LGTM
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.
Thank you! It would be nice to get performance measurements without the force-soft
feature enabled for aes
, but I guess performance should be the same.
While we at it can you please also add #[inline]
attributes on methods?
dbl/src/lib.rs
Outdated
let mut val = [0u64; 2]; | ||
for (s, v) in self.chunks_exact(size_of::<u64>()).zip(val.iter_mut()) { | ||
*v = u64::from_be_bytes(s.try_into().unwrap()); | ||
} |
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.
I think we can replace it simply with:
let mut val = [
u64::from_be_bytes(self[..8].try_into().unwrap()),
u64::from_be_bytes(self[8..].try_into().unwrap()),
];
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.
Updated for the methods dbl
and inv_dbl
having a block size of 128 bits.
For the block size of 256 bits I kept the for loop. IMO its a bit better readable, but can change it as well.
9511613
to
57db0e7
Compare
Below is the benchmark without Before:
After (
Done. |
Thank you! |
MACs/cmac
benchmarks were used to evaluate the refactoring, asdbl
does not contain its own. The refactoring ofdbl
seems to have no effect on theMACs/cmac
performance.Benchmarks results with
dbl
refactored:Benchmark results with
dbl
untouched: