-
Notifications
You must be signed in to change notification settings - Fork 975
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
remove rustc-serialize (#359) #386
Conversation
Feature gated behind 'aes-all'. Building requires RUSTFLAGS="-C target-feature=+aes,+ssse3" and RUSTDOCFLAGS="-C target-feature=+aes,+ssse3". Only support x86 case.
RUSTC aes and sse are enabled). To build with aes-all, aes and sse flag should not be set.
secio/Cargo.toml
Outdated
@@ -14,7 +14,7 @@ protobuf = "2.0.2" | |||
rand = "0.3.17" | |||
ring = { version = "0.12.1", features = ["rsa_signing"] } | |||
aes-ctr = "0.1.0" | |||
aes-soft = { version = "0.2", optional = true } | |||
aesni = { git="https://github.com/cheme/block-ciphers.git", features = ["nocheck"], optional = true } |
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.
@cheme is there anything in the git-repo that isn't in the release on crates.io? Or why can't we use that?
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.
Yes there was a little change, but RustCrypto guys merge it: RustCrypto/block-ciphers#22 , so we can now use the crates.io dependancy (I change it).
@cheme thanks heaps. Could you rebase this on master, so the win32 tests will be included? |
Anyone should be able to merge master thanks to github's button. |
Feature gated behind 'aes-all'. Building requires RUSTFLAGS="-C target-feature=+aes,+ssse3" and RUSTDOCFLAGS="-C target-feature=+aes,+ssse3". Only support x86 case.
RUSTC aes and sse are enabled). To build with aes-all, aes and sse flag should not be set.
… RustCrypto_switch
win32 pass 👍 |
@@ -0,0 +1,109 @@ | |||
|
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.
Missing copyright header.
|
||
/// Returns your stream cipher depending on `KeySize`. | ||
#[cfg(not(all(feature = "aes-all", any(target_arch = "x86_64", target_arch = "x86"))))] | ||
pub(crate) fn ctr(key_size: KeySize, key: &[u8], iv: &[u8]) -> Box<StreamCipherCore + 'static> { |
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.
Doesn't need to be pub(crate)
.
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.
Indeed.
feature = "aes-all", | ||
any(target_arch = "x86_64", target_arch = "x86"), | ||
))] | ||
#[test] |
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.
Should be in a mod tests
module.
// Apparently this is the fastest way of doing. | ||
// See https://gist.github.com/kirushik/e0d93759b0cd102f814408595c20a9d0 | ||
let mut out_buffer = BytesMut::from(vec![0; capacity]); | ||
let mut data_buf = item; |
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.
Why this line, instead of renaming the function parameter or using item
in the code below?
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.
Useless (just wanted to keep proto looks but does not need to be here).
/// Returns your stream cipher depending on `KeySize`. | ||
#[cfg(all(feature = "aes-all", any(target_arch = "x86_64", target_arch = "x86")))] | ||
pub(crate) fn ctr(key_size: KeySize, key: &[u8], iv: &[u8]) -> Box<StreamCipherCore + 'static> { | ||
if *aes_alt::AES_NI { |
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 haven't really digged into the crate, but from what I understand the aes_ctr
crate already does that, no?
It would really really really be great if we didn't have platform-specific code.
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.
aes_ctr run compile time switch between NI and soft implementation (to activate NI only crate flags from original PR msg should be use). A runtime check is not in aes_ctr crate, that is what eas-all feature does, but honestly I doubt that there is a lot of x86 cpu that could not run NI (I did my tests with qemu).
The best thing to do would be to try to PR runtime NI check to RustCrypto (not directly this code as dynamic type usage does not fit RustCrypto crates design), not sure if it would be easily accepted.
Another option would be to simply remove the 'aes-all' feature as I do not know if it is wanted (usecase would be single x86 build supporting old x86 cpu, it seems reasonable to me to defaults to NI activated build (binary distribution) and ask users to build from source if they are using x86 cpu that does not support aes NI and sse3). For info in #371 Sergei low end config could run aes-ni.
Haven't had time to review. |
This reverts commit 7399688.
In this commit I replace rust-serialize with RustSerialize project aes-ctr crate.
Fixes #383
Note that to avoid any api changes, I do not transmit a possible encoding error (the error seems a bit unlikely to occurs : end of keystream), it will likely panic on failure.
This should also fix #371 but it needs to be tested.
To use aes native instruction, the following rust-flags must be use
RUSTFLAGS="-C target-feature=+aes,+ssse3" RUSTDOCFLAGS="-C target-feature=+aes,+ssse3"
.I also add a feature 'aes-all' for including both version of the aes lib (aes-ni or aes-soft) and choose at runtime (with 'is_86_feature_enabled' macro) which one to use.
I do not believe if there is still a lot of x86 without support for aes or ssse3 and this feature may not be usefull (not activated by default and I would understand if we want to get rid of it).