aboutsummaryrefslogtreecommitdiff
path: root/src/test.rs
AgeCommit message (Collapse)Author
2025-11-24Add `Hash::as_slice()` for convenient serialization to bytesJosh Triplett
`Hash::as_bytes()` returns the hash as an array of bytes. However, sometimes it's useful to have the hash as a slice of bytes instead, such as for serialization via an API that takes `&[u8]`. While `.as_bytes().as_slice()` works for this, it'd be more convenient to have a direct `.as_slice()` on hashes.
2025-10-22chore: make some documents clearer (#528)wyrapeseed
2025-03-30add the `hazmat` module and deprecate the undocumented `guts` moduleJack O'Connor
https://github.com/BLAKE3-team/BLAKE3/pull/458
2025-02-17Add `Hash::from_slice` to handle conversion from `&[u8]` bytesJosh Triplett
This is a convenience method, to avoid having to first call `<[u8; 32]>::try_from(slice)?`.
2025-02-03upgrade rand to v0.9Jack O'Connor
2024-08-19test_compare_reference_impl_long_xofJack O'Connor
2024-08-18delete portable::xof_many and blake3_xof_many_portableJack O'Connor
2024-08-18test that xof_many doesn't write more blocks than requestedJack O'Connor
2024-08-15test_fuzz_xofJack O'Connor
2024-08-15integrate xof_many with the Rust implementation and with Rust and C testsJack O'Connor
2024-07-14Revert "serialize Hash with serde_bytes"Jack O'Connor
This mostly reverts commits 8416b1658c2690dc6351bdc7e0975b0d5f1a5282 and dd0afd640ad97b5ebcf887107162009a23ffdca0. Changing the serialization of Hash can only be backwards-compatible in self-describing formats like CBOR. In non-self-describing formats like bincode, the deserializer has to know in advance which serialization format was used. Fixes https://github.com/BLAKE3-team/BLAKE3/issues/414. Reopens https://github.com/BLAKE3-team/BLAKE3/issues/412.
2024-07-10update CBOR tests per @BurningEnlightenment's suggestionsJack O'Connor
https://github.com/BLAKE3-team/BLAKE3/issues/412#issuecomment-2220970998
2024-07-09serialize Hash with serde_bytesJack O'Connor
Closes #412.
2024-03-10test_miri_smoketestJack O'Connor
2024-03-09avoid using NamedTempFile under MiriJack O'Connor
2023-09-19add a test for the new serde featureJack O'Connor
2023-09-16make update_reader/mmap/mmap_rayon return selfJack O'Connor
This makes them consistent with how the existing update() and update_rayon() methods work, with the difference being that it's it's io::Result<&mut Self> instead of just &mut Self.
2023-09-16replace the new file module with inherent methods on HasherJack O'Connor
New methods: - update_reader - update_mmap - update_mmap_rayon These are more discoverable, more convenient, and safer. There are two problems I want to avoid by taking a `Path` instead of a `File`. First, exposing `Mmap` objects to the caller is fundamentally unsafe, and making `maybe_mmap_file` private avoids that issue. Second, taking a `File` raises questions about whether memory mapped reads should behave like regular file reads. (Should they respect the current seek position? Should they update the seek position?) Taking a `Path` from the caller and opening the `File` internally avoids these questions.
2023-07-16Add tests for ZeroizeElichai Turkel
2023-05-23Fix typosJoel Rosdahl
2023-05-01add `from_bytes` for conversions from `[u8; 32]`Eduardo Leegwater Simões
The function is `const`, so it is fundamentally different from the `From` trait implementation by allowing compile-time instantiation of a `Hash`.
2022-11-22test multiple initial counter values for hash_manyJack O'Connor
I'm adding the i32::MAX test case here because I personally screwed it up while I was working on https://github.com/BLAKE3-team/BLAKE3/issues/271. The correct implementation of the carry bit is the ANDNOT of old high bit (1) and the new high bit (0). Using XOR instead of ANDNOT gives the correct answer in the overflow case, but it also reports an incorrect "extra" overflow when the high bit goes from 0 to 1.
2021-11-05fix incorrect output / undefined behavior in Windows SSE2 assemblyJack O'Connor
The SSE2 patch introduced xmm10 as a temporary register for one of the rotations, but xmm6-xmm15 are callee-save registers on Windows, and SSE4.1 was only saving the registers it used. The minimal fix is to use one of the saved registers instead of xmm10. See https://github.com/BLAKE3-team/BLAKE3/issues/206.
2021-05-18upgrade to arrayvec 0.7.0Jack O'Connor
This version uses const generics, which bumps our minimum supported compiler version to 1.51.
2021-03-21implement Display for HashJack O'Connor
2021-03-21get rid of the standalone "*_rayon" functionsJack O'Connor
These clutter the toplevel API, and their prominence might lead callers to prefer them as a first resort, which probably isn't a good idea. Restricting multithreading to `Hasher::update_rayon` feels better, similar to what we've done with `Hasher::finalize_xof`. (But I think `update_rayon` is still an improvement over the trait-based interface that it replaced.)
2021-03-14add *_rayon methodsJack O'Connor
2021-03-14re-privatize the Join traitJack O'Connor
2021-02-28make derive_key() return an arrayJack O'Connor
2021-02-25Cargo.toml: upgrade all non API breaking dependenciesPaul Grandperrin
2021-02-04rename ParseError to HexError and update docsJack O'Connor
2021-02-04implement Error for ParseError, make it opaque, and support from_hex(&[u8])Jack O'Connor
2021-02-03merge "Adding from_hex and implementing FromStr for Hash"Jack O'Connor
https://github.com/BLAKE3-team/BLAKE3/pull/24
2020-09-29add more test cases at shorter input lengthsJack O'Connor
2020-02-12test a couple more reset() casesJack O'Connor
2020-02-11use a non-zero value for counter when testing hash_many with parentsJack O'Connor
We use a counter value that's very close to wrapping the lower word, when we're testing the hash_many chunks case. It turns out that this is a useful thing to do with parents too, even though parents 1) are teeechnically supposed to always use a counter of 0, and 2) aren't going to increment the counter at all. We caught a bug in the assembly implementations this way (where we accidentally did increment the counter, but only the higher word), because the equivalent test in rust_c_bindings uses this eccentric parents counter value.
2020-02-06Hasher::update_with_joinJack O'Connor
This is a new interface that allows the caller to provide a multi-threading implementation. It's defined in terms of a new `Join` trait, for which we provide two implementations, `SerialJoin` and `RayonJoin`. This lets the caller control when multi-threading is used, rather than the previous all-or-nothing design of the "rayon" feature. Although existing callers should keep working, this is a compatibility break, because callers who were relying on automatic multi-threading before will now be single-threaded. Thus the next release of this crate will need to be version 0.2. See https://github.com/BLAKE3-team/BLAKE3/issues/25 and https://github.com/BLAKE3-team/BLAKE3/issues/54.
2020-02-02add Hasher::resetJack O'Connor
Closes https://github.com/BLAKE3-team/BLAKE3/issues/41.
2020-01-22add a larger test caseJack O'Connor
One thing I like to test is that, if I hack simd_degree to be higher than MAX_SIMD_DEGREE, assertions fire. This requires a test case long enough to exceed that number of chunks.
2020-01-16add blake3_c_rust_bindings for testing and benchmarkingJack O'Connor
2020-01-15Adding tests for error conditionsphayes
2020-01-15Updating from_hex to accept a &str instead of an ArrayStringphayes
2020-01-14Adding from_hex and implementing FromStr for Hashphayes
2020-01-11disambiguate the two testJack O'Connor
We can't change the context used in test_vectors.json without breaking people, but we can change the one in unit tests.
2020-01-09test_msg_schedule_permutationJack O'Connor
2019-12-28make derive_key take a key of any lengthJack O'Connor
The previous version of this API called for a key of exactly 256 bits. That's good for optimal performance, but it would mean losing the use-with-other-algorithms property for applications whose input keys are a different size. There's no way for an abstraction over the previous version to provide reliable domain separation for the "extract" step.
2019-12-13silence another warning in the --no-default-features testsJack O'Connor
2019-12-13test release mode in CIJack O'Connor
As part of this, get rid of the BLAKE3_FUZZ_ITERATIONS variable. I wasn't using it anywhere, and it was leading to some compiler warnings in --no-default-features mode.
2019-12-12update MAX_DEPTHJack O'Connor
2019-12-12rename "offset" to "counter" and always increment it by 1Jack O'Connor
This is simpler than sometimes incrementing by CHUNK_LEN and other times incrementing by BLOCK_LEN.