feat: add division and powmod (WIP) and start adapting task runner

This commit is contained in:
alivecow 2024-11-14 22:30:55 +01:00
parent a05f2f02b6
commit deb4261121
4 changed files with 183 additions and 16 deletions

View file

@ -11,6 +11,7 @@ use tasks01::{
gcm::{gcm_decrypt, gcm_encrypt},
gfmul::gfmul_task,
pad_oracle::padding_oracle,
pfmath::gfpoly_add,
poly2block::poly2block,
sea128::sea128,
xex::{self, fde_xex},
@ -83,6 +84,12 @@ pub fn task_deploy(testcase: &Testcase) -> Result<Value> {
Ok(json)
}
"gfpoly_add" => {
let result = gfpoly_add(args)?;
let json = json!({"plaintext" : result.to_c_array()});
Ok(json)
}
_ => Err(anyhow!(
"Fatal. No compatible action found. Json data was {:?}. Arguments were; {:?}",
testcase,

View file

@ -2,6 +2,7 @@ pub mod block2poly;
pub mod gcm;
pub mod gfmul;
pub mod pad_oracle;
pub mod pfmath;
pub mod poly2block;
pub mod sea128;
pub mod xex;

View file

@ -0,0 +1,15 @@
use anyhow::Result;
use base64::{prelude::BASE64_STANDARD, Engine};
use serde_json::Value;
use crate::utils::field::Polynomial;
pub fn gfpoly_add(args: &Value) -> Result<Polynomial> {
let poly_a = Polynomial::from_c_array(&args["A"].clone());
let poly_b = Polynomial::from_c_array(&args["B"].clone());
let result = poly_a + poly_b;
Ok(result)
}