doc: add docmentation and test

This commit is contained in:
0xalivecow 2024-11-04 15:46:09 +01:00
parent 1dfed264e9
commit b81bbab16c
No known key found for this signature in database
2 changed files with 40 additions and 30 deletions

View file

@ -108,4 +108,24 @@ mod tests {
);
Ok(())
}
#[test]
fn gfmul_task01_gcm() -> Result<()> {
let args: Value = json!({"a": "AAAAAAAAAAAAAAAQBAAAAA==", "b": "IAAAAAAAAACAAAAAAAAAAA=="});
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 = BASE64_STANDARD.encode(gfmul(poly_a, poly_b, "gcm")?);
assert_eq!(
result, "hSQAAAAAAAAAAAAAAAAAAA==",
"Failure. Calulated result was: {}",
result
);
Ok(())
}
}