Parallelize calculate models
This commit is contained in:
parent
0dedbd16a3
commit
fc9133056c
1 changed files with 7 additions and 6 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -6,7 +6,9 @@ use aes::{
|
|||
cipher::{BlockEncrypt, KeyInit, generic_array::GenericArray},
|
||||
};
|
||||
use clap::Parser;
|
||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||
use rayon::iter::{
|
||||
IndexedParallelIterator, IntoParallelIterator, IntoParallelRefMutIterator, ParallelIterator,
|
||||
};
|
||||
use std::{
|
||||
io::{BufRead, Read},
|
||||
path::{Path, PathBuf},
|
||||
|
|
@ -75,14 +77,13 @@ fn calculate_models(ciphertexts: &[[u8; 16]]) -> Vec<[Vec<u8>; 16]> {
|
|||
})
|
||||
.collect();
|
||||
|
||||
r.par_iter_mut().enumerate().for_each(|(j, r)| {
|
||||
for k in 0..16 {
|
||||
for j in 0..256 {
|
||||
for (i, c) in ciphertexts.iter().enumerate() {
|
||||
r[j][k][i] = RSBOX[(c[k] ^ (j as u8)) as usize];
|
||||
r[k][i] = RSBOX[(c[k] ^ (j as u8)) as usize];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
r
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue