Skip to content
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

aes-soft: use fixslicing for AES encryption #176

Merged
merged 1 commit into from Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 1 addition & 13 deletions aes/aes-soft/benches/aes128.rs
Expand Up @@ -2,7 +2,7 @@
extern crate test;

use aes_soft::cipher::{BlockCipher, NewBlockCipher};
use aes_soft::{Aes128, Aes128Fixsliced};
use aes_soft::Aes128;

#[bench]
pub fn aes128_encrypt(bh: &mut test::Bencher) {
Expand Down Expand Up @@ -40,18 +40,6 @@ pub fn aes128_encrypt8(bh: &mut test::Bencher) {
bh.bytes = (input[0].len() * input.len()) as u64;
}

#[bench]
pub fn aes128_encrypt2_fixsliced(bh: &mut test::Bencher) {
let cipher = Aes128Fixsliced::new(&Default::default());
let mut input = Default::default();

bh.iter(|| {
cipher.encrypt_blocks(&mut input);
test::black_box(&input);
});
bh.bytes = (input[0].len() * input.len()) as u64;
}

#[bench]
pub fn aes128_decrypt8(bh: &mut test::Bencher) {
let cipher = Aes128::new(&Default::default());
Expand Down
14 changes: 1 addition & 13 deletions aes/aes-soft/benches/aes192.rs
Expand Up @@ -2,7 +2,7 @@
extern crate test;

use aes_soft::cipher::{BlockCipher, NewBlockCipher};
use aes_soft::{Aes192, Aes192Fixsliced};
use aes_soft::Aes192;

#[bench]
pub fn aes192_encrypt(bh: &mut test::Bencher) {
Expand Down Expand Up @@ -40,18 +40,6 @@ pub fn aes192_encrypt8(bh: &mut test::Bencher) {
bh.bytes = (input[0].len() * input.len()) as u64;
}

#[bench]
pub fn aes192_encrypt2_fixsliced(bh: &mut test::Bencher) {
let cipher = Aes192Fixsliced::new(&Default::default());
let mut input = Default::default();

bh.iter(|| {
cipher.encrypt_blocks(&mut input);
test::black_box(&input);
});
bh.bytes = (input[0].len() * input.len()) as u64;
}

#[bench]
pub fn aes192_decrypt8(bh: &mut test::Bencher) {
let cipher = Aes192::new(&Default::default());
Expand Down
14 changes: 1 addition & 13 deletions aes/aes-soft/benches/aes256.rs
Expand Up @@ -2,7 +2,7 @@
extern crate test;

use aes_soft::cipher::{BlockCipher, NewBlockCipher};
use aes_soft::{Aes256, Aes256Fixsliced};
use aes_soft::Aes256;

#[bench]
pub fn aes256_encrypt(bh: &mut test::Bencher) {
Expand Down Expand Up @@ -40,18 +40,6 @@ pub fn aes256_encrypt8(bh: &mut test::Bencher) {
bh.bytes = (input[0].len() * input.len()) as u64;
}

#[bench]
pub fn aes256_encrypt2_fixsliced(bh: &mut test::Bencher) {
let cipher = Aes256Fixsliced::new(&Default::default());
let mut input = Default::default();

bh.iter(|| {
cipher.encrypt_blocks(&mut input);
test::black_box(&input);
});
bh.bytes = (input[0].len() * input.len()) as u64;
}

#[bench]
pub fn aes256_decrypt8(bh: &mut test::Bencher) {
let cipher = Aes256::new(&Default::default());
Expand Down
20 changes: 0 additions & 20 deletions aes/aes-soft/src/bitslice.rs
Expand Up @@ -21,26 +21,6 @@ pub trait AesOps {
fn add_round_key(self, rk: &Self) -> Self;
}

pub fn encrypt_core<S: AesOps + Copy>(state: &S, sk: &[S]) -> S {
// Round 0 - add round key
let mut tmp = state.add_round_key(&sk[0]);

// Remaining rounds (except last round)
for i in 1..sk.len() - 1 {
tmp = tmp.sub_bytes();
tmp = tmp.shift_rows();
tmp = tmp.mix_columns();
tmp = tmp.add_round_key(&sk[i]);
}

// Last round
tmp = tmp.sub_bytes();
tmp = tmp.shift_rows();
tmp = tmp.add_round_key(&sk[sk.len() - 1]);

tmp
}

pub fn decrypt_core<S: AesOps + Copy>(state: &S, sk: &[S]) -> S {
// Round 0 - add round key
let mut tmp = state.add_round_key(&sk[sk.len() - 1]);
Expand Down