refactor: Apply cargo reccomended cleanups
This commit is contained in:
parent
26ca12b419
commit
1ce30e1cea
11 changed files with 12 additions and 21 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
env::{self, args},
|
||||
env::{self},
|
||||
fs,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use tasks01::{
|
|||
gfmul::gfmul_task,
|
||||
poly2block::poly2block,
|
||||
sea128::sea128,
|
||||
xex::{self, fde_xex},
|
||||
xex::{fde_xex},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::utils::poly::{b64_2_num, block_2_polynomial, get_coefficients};
|
||||
use crate::utils::poly::block_2_polynomial;
|
||||
use anyhow::Result;
|
||||
use base64::prelude::*;
|
||||
use serde_json::Value;
|
||||
|
|
@ -19,7 +19,7 @@ pub fn block2poly(val: &Value) -> Result<Vec<u8>> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
// Note this useful idiom: importing names from outer (for mod tests) scope.
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
use crate::utils::{
|
||||
field::ByteArray,
|
||||
poly::{b64_2_num, coefficient_to_binary, gfmul},
|
||||
};
|
||||
use crate::utils::poly::gfmul;
|
||||
|
||||
use anyhow::Result;
|
||||
use base64::prelude::*;
|
||||
|
|
@ -24,7 +21,7 @@ pub fn gfmul_task(args: &Value) -> Result<Vec<u8>> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
// Note this useful idiom: importing names from outer (for mod tests) scope.
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use crate::utils::poly::{self, polynomial_2_block};
|
||||
use crate::utils::poly::{polynomial_2_block};
|
||||
use anyhow::{Ok, Result};
|
||||
use base64::prelude::*;
|
||||
use serde_json::Value;
|
||||
|
||||
pub fn poly2block(args: &Value) -> Result<Vec<u8>> {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ pub fn sea128(args: &Value) -> Result<String> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs;
|
||||
|
||||
|
||||
use anyhow::Result;
|
||||
use serde_json::json;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use std::io::BufRead;
|
||||
|
||||
use anyhow::Result;
|
||||
use openssl::symm::{Cipher, Crypter, Mode};
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ impl ByteArray {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_byte_array_shift1() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use anyhow::{anyhow, Ok, Result};
|
||||
use base64::Engine;
|
||||
use anyhow::{Ok, Result};
|
||||
|
||||
use super::poly::gfmul;
|
||||
|
||||
pub fn xor_bytes(vec1: &Vec<u8>, mut vec2: Vec<u8>) -> Result<Vec<u8>> {
|
||||
for (byte1, byte2) in vec1.iter().zip(vec2.iter_mut()) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub fn parse_json(json: String) -> Result<Testcases> {
|
|||
mod tests {
|
||||
use std::fs;
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
|
||||
// Note this useful idiom: importing names from outer (for mod tests) scope.
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
use crate::utils::field::ByteArray;
|
||||
use anyhow::{anyhow, Result};
|
||||
use base64::prelude::*;
|
||||
use serde_json::Value;
|
||||
use std::{str::FromStr, u128, u8, usize};
|
||||
|
||||
use super::field;
|
||||
pub const RED_POLY: u128 = 0x87000000_00000000_00000000_00000000;
|
||||
|
||||
pub fn gfmul(poly_a: Vec<u8>, poly_b: Vec<u8>, semantic: &str) -> Result<Vec<u8>> {
|
||||
|
|
@ -167,7 +165,7 @@ pub fn coefficients_to_byte_arr_xex(coeffs: Vec<u8>) -> Vec<u8> {
|
|||
let mut byte_array: Vec<u8> = vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
for coeff in coeffs {
|
||||
let block_num = coeff / 8;
|
||||
byte_array[usize::from(block_num)] |= (1 << (coeff % 7));
|
||||
byte_array[usize::from(block_num)] |= 1 << (coeff % 7);
|
||||
}
|
||||
|
||||
byte_array
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue