Dev merge gfmul and XEX tasks #3
5 changed files with 16 additions and 9 deletions
2
.github/workflows/kauma.yaml
vendored
2
.github/workflows/kauma.yaml
vendored
|
|
@ -66,5 +66,5 @@ jobs:
|
|||
docker tag ghcr.io/johndoe31415/labwork-docker:master labwork
|
||||
- name: Run labwork container
|
||||
run: |
|
||||
docker run -v $PWD:/dut/ labwork /bin/bash -c 'ls && pwd && ls ./test_json/kauma_tests.json && /dut/build && /dut/kauma ./test_json/kauma_tests.json'
|
||||
docker run -v $PWD:/dut/ labwork /bin/bash -c '/dut/build && /dut/kauma ./test_json/kauma_tests.json'
|
||||
|
||||
|
|
|
|||
2
kauma
2
kauma
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd $SCRIPT_DIR
|
||||
cargo run --release --locked --offline -- --verbose $@
|
||||
cargo run --release --locked --offline -- $@
|
||||
|
|
|
|||
|
|
@ -10,16 +10,14 @@ use crate::utils::{
|
|||
|
||||
pub const RED_POLY: u128 = 0x87000000_00000000_00000000_00000000;
|
||||
|
||||
pub fn gfmul(args: &Value) -> Result<String> {
|
||||
pub fn gfmul(poly_a: Vec<u8>, poly_b: Vec<u8>) -> Result<String> {
|
||||
let mut red_poly_bytes: ByteArray = ByteArray(RED_POLY.to_be_bytes().to_vec());
|
||||
red_poly_bytes.0.push(0x01);
|
||||
|
||||
let poly1_text: String = serde_json::from_value(args["a"].clone())?;
|
||||
let mut poly1: ByteArray = ByteArray(BASE64_STANDARD.decode(poly1_text)?);
|
||||
let mut poly1: ByteArray = ByteArray(poly_a);
|
||||
poly1.0.push(0x00);
|
||||
|
||||
let poly2_text: String = serde_json::from_value(args["b"].clone())?;
|
||||
let mut poly2: ByteArray = ByteArray(BASE64_STANDARD.decode(poly2_text)?);
|
||||
let mut poly2: ByteArray = ByteArray(poly_b);
|
||||
poly2.0.push(0x00);
|
||||
|
||||
let mut result: ByteArray = ByteArray(vec![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
|
@ -61,7 +59,15 @@ mod tests {
|
|||
#[test]
|
||||
fn gfmul_task01() -> Result<()> {
|
||||
let args: Value = json!({"a": "ARIAAAAAAAAAAAAAAAAAgA==", "b": "AgAAAAAAAAAAAAAAAAAAAA=="});
|
||||
let result = gfmul(&args)?;
|
||||
|
||||
let poly1_text: String = serde_json::from_value(args["a"].clone())?;
|
||||
let poly_a = BASE64_STANDARD.decode(poly1_text)?;
|
||||
|
||||
let poly2_text: String = serde_json::from_value(args["b"].clone())?;
|
||||
let poly_b = BASE64_STANDARD.decode(poly2_text)?;
|
||||
|
||||
let result = gfmul(poly_a, poly_b)?;
|
||||
|
||||
assert_eq!(
|
||||
result, "hSQAAAAAAAAAAAAAAAAAAA==",
|
||||
"Failure. Calulated result was: {}",
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ pub mod block2poly;
|
|||
pub mod gfmul;
|
||||
pub mod poly2block;
|
||||
pub mod sea128;
|
||||
pub mod xex;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_json_parsing() {
|
||||
let json = fs::read_to_string("src/test_json/parse_example.json").unwrap();
|
||||
let json = fs::read_to_string("test_json/parse_example.json").unwrap();
|
||||
let parsed = parse_json(json).unwrap();
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue