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
|
docker tag ghcr.io/johndoe31415/labwork-docker:master labwork
|
||||||
- name: Run labwork container
|
- name: Run labwork container
|
||||||
run: |
|
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
|
#!/bin/bash
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
cd $SCRIPT_DIR
|
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 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());
|
let mut red_poly_bytes: ByteArray = ByteArray(RED_POLY.to_be_bytes().to_vec());
|
||||||
red_poly_bytes.0.push(0x01);
|
red_poly_bytes.0.push(0x01);
|
||||||
|
|
||||||
let poly1_text: String = serde_json::from_value(args["a"].clone())?;
|
let mut poly1: ByteArray = ByteArray(poly_a);
|
||||||
let mut poly1: ByteArray = ByteArray(BASE64_STANDARD.decode(poly1_text)?);
|
|
||||||
poly1.0.push(0x00);
|
poly1.0.push(0x00);
|
||||||
|
|
||||||
let poly2_text: String = serde_json::from_value(args["b"].clone())?;
|
let mut poly2: ByteArray = ByteArray(poly_b);
|
||||||
let mut poly2: ByteArray = ByteArray(BASE64_STANDARD.decode(poly2_text)?);
|
|
||||||
poly2.0.push(0x00);
|
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]);
|
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]
|
#[test]
|
||||||
fn gfmul_task01() -> Result<()> {
|
fn gfmul_task01() -> Result<()> {
|
||||||
let args: Value = json!({"a": "ARIAAAAAAAAAAAAAAAAAgA==", "b": "AgAAAAAAAAAAAAAAAAAAAA=="});
|
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!(
|
assert_eq!(
|
||||||
result, "hSQAAAAAAAAAAAAAAAAAAA==",
|
result, "hSQAAAAAAAAAAAAAAAAAAA==",
|
||||||
"Failure. Calulated result was: {}",
|
"Failure. Calulated result was: {}",
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@ pub mod block2poly;
|
||||||
pub mod gfmul;
|
pub mod gfmul;
|
||||||
pub mod poly2block;
|
pub mod poly2block;
|
||||||
pub mod sea128;
|
pub mod sea128;
|
||||||
|
pub mod xex;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_json_parsing() {
|
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();
|
let parsed = parse_json(json).unwrap();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue