89b5329f06
X-Wing is composed from ml-kem, x25519-dalek, sha3 and shake and matches the draft's vectors. The PSK comes from a mutual exchange (each peer encapsulates to the other, QA A-15) bound to the full transcript in Arcanum's own HKDF layer (QA D-QA-1). Low-order X25519 values are refused. Deterministic entry points sit behind the off-by-default hazmat feature, enabled only for the tests.
39 lines
1.4 KiB
Rust
39 lines
1.4 KiB
Rust
//! Mandatory test 6 (the part a test can check; `cargo deny` and `cargo audit` are run separately,
|
|
//! see docs/01_arcanum.md). The compiler enforces `#![forbid(unsafe_code)]`; this guardrail makes
|
|
//! sure the attribute itself is never removed and no source file opts back in.
|
|
|
|
use std::fs;
|
|
use std::path::Path;
|
|
|
|
fn rust_files(dir: &Path, out: &mut Vec<std::path::PathBuf>) {
|
|
for entry in fs::read_dir(dir).unwrap() {
|
|
let path = entry.unwrap().path();
|
|
if path.is_dir() {
|
|
rust_files(&path, out);
|
|
} else if path.extension().is_some_and(|e| e == "rs") {
|
|
out.push(path);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn the_crate_forbids_unsafe_code() {
|
|
let lib = fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("src/lib.rs")).unwrap();
|
|
assert!(lib.lines().any(|l| l.trim() == "#![forbid(unsafe_code)]"), "src/lib.rs must forbid unsafe code");
|
|
}
|
|
|
|
#[test]
|
|
fn no_source_file_contains_unsafe() {
|
|
let mut files = Vec::new();
|
|
rust_files(&Path::new(env!("CARGO_MANIFEST_DIR")).join("src"), &mut files);
|
|
assert!(!files.is_empty());
|
|
for f in files {
|
|
let text = fs::read_to_string(&f).unwrap();
|
|
for (n, line) in text.lines().enumerate() {
|
|
let code = line.split("//").next().unwrap_or("");
|
|
let opts_in = code.contains("unsafe") && code.trim() != "#![forbid(unsafe_code)]";
|
|
assert!(!opts_in, "{}:{}: {line}", f.display(), n + 1);
|
|
}
|
|
}
|
|
}
|