feat: finialise test runner and add testing json
This commit is contained in:
parent
deb4261121
commit
68d9f13a3d
4 changed files with 213 additions and 11 deletions
|
|
@ -11,7 +11,7 @@ use tasks01::{
|
|||
gcm::{gcm_decrypt, gcm_encrypt},
|
||||
gfmul::gfmul_task,
|
||||
pad_oracle::padding_oracle,
|
||||
pfmath::gfpoly_add,
|
||||
pfmath::{gfdiv, gfpoly_add, gfpoly_divmod, gfpoly_mul, gfpoly_pow, gfpoly_powmod},
|
||||
poly2block::poly2block,
|
||||
sea128::sea128,
|
||||
xex::{self, fde_xex},
|
||||
|
|
@ -86,10 +86,42 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
|
|||
}
|
||||
"gfpoly_add" => {
|
||||
let result = gfpoly_add(args)?;
|
||||
let json = json!({"plaintext" : result.to_c_array()});
|
||||
let json = json!({"S" : result.to_c_array()});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
"gfpoly_mul" => {
|
||||
let result = gfpoly_mul(args)?;
|
||||
let json = json!({"P" : result.to_c_array()});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
"gfpoly_pow" => {
|
||||
let result = gfpoly_pow(args)?;
|
||||
let json = json!({"Z" : result.to_c_array()});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
"gfdiv" => {
|
||||
let result = gfdiv(args)?;
|
||||
let out = BASE64_STANDARD.encode(result);
|
||||
let json = json!({"q" : out});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
"gfpoly_divmod" => {
|
||||
let result = gfpoly_divmod(args)?;
|
||||
let json = json!({"Q" : result.0.to_c_array(), "R" : result.1.to_c_array()});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
"gfpoly_powmod" => {
|
||||
let result = gfpoly_powmod(args)?;
|
||||
let json = json!({"Z" : result.to_c_array()});
|
||||
|
||||
Ok(json)
|
||||
}
|
||||
|
||||
_ => Err(anyhow!(
|
||||
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
|
||||
testcase,
|
||||
|
|
@ -279,4 +311,22 @@ mod tests {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_task_gcm_gfpoly_add() -> Result<()> {
|
||||
let json = fs::read_to_string("test_json/gcm_decrypt_sea.json").unwrap();
|
||||
let parsed = parse_json(json).unwrap();
|
||||
|
||||
let expected = json!({ "responses" : { "b856d760-023d-4b00-bad2-15d2b6da22fe" : {
|
||||
"plaintext": "RGFzIGlzdCBlaW4gVGVzdA==",
|
||||
"authentic": true,
|
||||
}}});
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_value(task_distrubute(&parsed)?).unwrap(),
|
||||
serde_json::to_value(expected).unwrap()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue