Subject
blake3 is the official Rust implementation of the BLAKE3 cryptographic hash function, as specified in the BLAKE3 paper by O'Connor, Neves, Aumasson, and Wilcox-O'Hearn and in the C2SP community specification. It implements a Merkle-tree hash with BLAKE2-derived compression, supporting a 256-bit default output, arbitrary-length extended output (XOF), a keyed-hash (MAC) variant, and a key-derivation variant. Multiple SIMD backends are included: a portable Rust implementation, Rust intrinsics for SSE2/SSE4.1/AVX2/WASM SIMD, hand-written assembly for SSE2/SSE4.1/AVX2/AVX-512 on x86-64, and a C intrinsics backend for NEON. CPU feature detection is performed at runtime on x86/x86_64 via the cpufeatures crate. The public API exposes hash, keyed_hash, derive_key, Hasher (incremental), and OutputReader (seekable XOF), plus a hazmat module for direct tree manipulation used by applications like Bao.
Methodology
The published crate was compared against the upstream Git repository at the commit recorded in .cargo_vcs_info.json using diff -rq. All 18 .rs files in src/ were read in full (~8268 LOC total), along with build.rs, the c/ directory listing, and Cargo.toml.orig. The source was surveyed with grep for network, filesystem, exec, environment-variable, concurrency, and RNG usage patterns before reading in detail. CI configuration was examined in vcs/.github/workflows/ci.yml. Tool versions used: openvet 0.6.0, diff (macOS), grep (BSD), file (macOS).
Results
The diff -rq comparison shows that source files in contents/src/ match the VCS byte-for-byte. The only differences are: Cargo.toml (cargo normalisation), Cargo.toml.orig and Cargo.lock present only in the published crate, and directories (b3sum/, reference_impl/, test_vectors/, tools/) present only in the VCS root and not in scope for this audit.
No binary artifacts are present in the published crate (has-binaries). The media/ directory contains SVG files only. The c/ directory holds C and assembly source files compiled by build.rs at build time; these are text files.
The build script compiles C and assembly SIMD backends via cc::Build and emits cargo:rustc-cfg=blake3_* directives to select which Rust module is compiled. It makes no network requests (build-exec-no-network). It reads environment variables in the standard CARGO_* / CC / CFLAGS set (build-exec-deterministic). One write outside OUT_DIR occurs: on Windows MinGW targets, lines 396-400 call std::fs::remove_file on four .asm artifacts generated in the crate root by clang-cl. The deletions are best-effort (let _ = remove_file(...)) and are a documented cleanup for a known clang-cl quirk. This is the basis for build-exec-no-write-out being false. The unsafe { env::set_var("CFLAGS", flags) } at build.rs:313 modifies the environment to append -fno-lto when CFLAGS is set by the caller; a SAFETY comment documents that the build script is single-threaded.
Approximately 220 occurrences of unsafe were found across the Rust source (excluding test.rs). They are concentrated in four areas: (1) platform.rs, which calls into each SIMD module after verifying feature support at runtime, with inline comments documenting the precondition; (2) the FFI wrappers (ffi_sse2.rs, ffi_sse41.rs, ffi_avx2.rs, ffi_avx512.rs, ffi_neon.rs), which each add an explicit assert! on the output buffer length before passing raw pointers to C; (3) the Rust intrinsics modules (rust_sse2.rs, rust_sse41.rs, rust_avx2.rs, wasm32_simd.rs), which use SIMD intrinsics and transmute for the CVWords→CVBytes conversion, annotated with the x86 little-endian invariant; and (4) io.rs, which wraps memmap2::Mmap::map. All four areas carry safety comments that document the relied-upon invariants. The absence of SAFETY comments does not indicate any block was overlooked: the FFI modules use a function-level "Unsafe because this may only be called on platforms supporting X" convention, and the platform dispatch arms carry per-call comments. All unsafe is necessary for its purpose: SIMD intrinsics, FFI, and mmap. Justifies uses-unsafe, unsafe-safe, unsafe-documented, unsafe-minimal, and unsafe-tested (Miri smoketest in CI; randomized tests cross-check all backends against the portable implementation).
The Hash type implements PartialEq via constant_time_eq::constant_time_eq_32, documented "This implementation is constant-time." Hash deliberately omits Deref and AsRef to prevent implicit coercions that would bypass constant-time comparison. This is correct practice for a MAC output type. Justifies uses-crypto, crypto-safe, impl-crypto, and crypto-impl-safe.
The compression function in portable.rs implements the BLAKE3 G function and round schedule directly from the specification constants. All three modes (regular hash, keyed hash, derive-key) are domain-separated with distinct flag bits. The test suite in src/test.rs cross-checks every backend against the reference implementation (reference_impl dev-dep, a clean re-implementation) for 46 different input lengths from 0 to 100 KiB. The test_fuzz_hasher and test_fuzz_xof tests use a fixed-seed ChaCha8Rng to perform 10,000 randomized update-pattern tests against the reference. A Miri smoketest runs in CI. Justifies crypto-impl-correct and crypto-impl-tested.
The crate uses the filesystem only via the mmap feature (update_mmap, update_mmap_rayon), which opens a path provided by the caller. No path manipulation is performed on the path argument; the OS handles it. Justifies uses-filesystem and filesystem-safe.
No networking, exec, JIT, interpreter, concurrency primitives, or environment-variable access is present in the library code. The rayon feature delegates parallelism entirely to rayon-core::join, which is not implemented by this crate. The crate does not implement a parser, protocol, data structure, algorithm (in the non-crypto sense), JIT, or interpreter. Justifies uses-network, uses-exec, uses-jit, uses-interpreter, uses-concurrency, uses-environment, impl-concurrency, impl-parser, impl-protocol, impl-datastructure, impl-algorithm, impl-interpreter, impl-jit.
There are no install-time hooks (has-install-exec). The package ships no integration tests, property tests, or fuzz test targets (has-integration-tests, has-property-tests, has-fuzz-tests); the randomized tests in test.rs are unit tests run with cargo test, not dedicated fuzz targets.
No malicious code patterns were identified: no obfuscated code, base64 blobs, suspicious network endpoints, telemetry, or time-based behaviour. Justifies is-benign.
No findings were recorded.
Conclusion
The crate's unsafe surface is large due to the SIMD and FFI backends, but it is methodically structured: every unsafe call site has a documented precondition, the preconditions are enforced either by runtime feature detection or by explicit assertions, and the randomized test suite cross-checks all backends against a common reference. The Hash type's constant-time equality is correctly implemented and deliberately protected from accidental bypass. The one area that cannot be fully validated without a hardware AVX-512 target is the assembly implementation in c/, which is authored by the algorithm's designers and is shared with the C library. The build-exec-no-write-out claim is false due to the clang-cl cleanup on Windows; this is a minor correctness trade-off with no security impact.