1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-06-07 19:36:03 +02:00
Commit Graph

44 Commits

Author SHA1 Message Date
Jack O'Connor cb32f0bd14 replace the new file module with inherent methods on Hasher
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-09-16 17:04:27 -07:00
Elichai Turkel f18e19092b Add tests for Zeroize 2023-07-16 13:29:47 -04:00
Joel Rosdahl 2dd4e57f68 Fix typos 2023-05-23 14:39:27 -07:00
Eduardo Leegwater Simões 8176a2202d add `from_bytes` for conversions from `[u8; 32]`
The function is `const`, so it is fundamentally different from the
`From` trait implementation by allowing compile-time instantiation of a
`Hash`.
2023-05-01 03:23:16 -05:00
Jack O'Connor 5dad698d3f test multiple initial counter values for hash_many
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.
2022-11-22 23:31:29 -08:00
Jack O'Connor 371b5483c9 fix incorrect output / undefined behavior in Windows SSE2 assembly
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-11-05 12:25:44 -04:00
Jack O'Connor 037de38bfe upgrade to arrayvec 0.7.0
This version uses const generics, which bumps our minimum supported
compiler version to 1.51.
2021-05-18 12:28:29 -04:00
Jack O'Connor 9ef2f4d9a8 implement Display for Hash 2021-03-21 21:14:44 -04:00
Jack O'Connor 05292a018b get rid of the standalone "*_rayon" functions
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-21 21:14:13 -04:00
Jack O'Connor b228f46e03 add *_rayon methods 2021-03-14 00:26:18 -05:00
Jack O'Connor ea72822620 re-privatize the Join trait 2021-03-14 00:08:21 -05:00
Jack O'Connor 71d67e0810 make derive_key() return an array 2021-02-28 18:10:59 -05:00
Paul Grandperrin 0872f98c15 Cargo.toml: upgrade all non API breaking dependencies 2021-02-25 11:16:27 -05:00
Jack O'Connor 0c26ed52a8 rename ParseError to HexError and update docs 2021-02-04 15:43:44 -05:00
Jack O'Connor cc21dd0132 implement Error for ParseError, make it opaque, and support from_hex(&[u8]) 2021-02-04 15:36:29 -05:00
Jack O'Connor 9e08f5c38d merge "Adding from_hex and implementing FromStr for Hash"
https://github.com/BLAKE3-team/BLAKE3/pull/24
2021-02-03 11:53:56 -05:00
Jack O'Connor ae3e8e6b3a add more test cases at shorter input lengths 2020-09-29 10:51:49 -04:00
Jack O'Connor 1c5d4eea6a test a couple more reset() cases 2020-02-12 10:22:54 -05:00
Jack O'Connor e0dc4d932e use a non-zero value for counter when testing hash_many with parents
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-11 23:45:41 -05:00
Jack O'Connor fc219f4f8d Hasher::update_with_join
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-06 15:07:15 -05:00
Jack O'Connor e603983647 add Hasher::reset
Closes https://github.com/BLAKE3-team/BLAKE3/issues/41.
2020-02-02 16:38:29 -05:00
Jack O'Connor 92d421dea1 add a larger test case
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-22 21:19:47 -05:00
Jack O'Connor 84c26670bf add blake3_c_rust_bindings for testing and benchmarking 2020-01-16 16:09:42 -05:00
phayes c2f90dfdb0
Adding tests for error conditions 2020-01-15 10:06:40 -08:00
phayes 3353f0e5a1
Updating from_hex to accept a &str instead of an ArrayString 2020-01-15 09:59:36 -08:00
phayes 71e98f1d3f
Adding from_hex and implementing FromStr for Hash 2020-01-14 11:50:28 -08:00
Jack O'Connor 793c8a2444 disambiguate the two test
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-11 00:23:07 -05:00
Jack O'Connor 442775e3ce test_msg_schedule_permutation 2020-01-09 09:21:07 -05:00
Jack O'Connor 2fac7447e0 make derive_key take a key of any length
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-28 17:56:29 -06:00
Jack O'Connor f54c292a53 silence another warning in the --no-default-features tests 2019-12-13 13:19:44 -05:00
Jack O'Connor d963fe18f3 test release mode in CI
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-13 13:15:48 -05:00
Jack O'Connor a52d4daa98 update MAX_DEPTH 2019-12-12 23:40:13 -05:00
Jack O'Connor b5f1e925f7 rename "offset" to "counter" and always increment it by 1
This is simpler than sometimes incrementing by CHUNK_LEN and other times
incrementing by BLOCK_LEN.
2019-12-12 21:41:30 -05:00
Jack O'Connor 3b5664c8a5 struct OutputReader 2019-12-12 11:33:21 -05:00
Jack O'Connor 52ea6487f8 switch to representing CVs as words for the compression function
The portable implementation was getting slowed down by converting back
and forth between words and bytes.

I made the corresponding change on the C side first
(12a37be8b5),
and as part of this commit I'm re-vendoring the C code. I'm also
exposing a small FFI interface to C so that blake3_neon.c can link
against portable.rs rather than blake3_portable.c, see c_neon.rs.
2019-12-11 18:05:26 -05:00
Jack O'Connor c81d5c2522 test against test_vectors.json in CI 2019-12-11 10:50:18 -05:00
Jack O'Connor 1574b488f9 unify the platform-specific tests and test AVX-512 and NEON 2019-12-08 21:56:10 -05:00
Jack O'Connor 6edabea57a provide BLAKS3_FUZZ_ITERATIONS for running a longer fuzz test 2019-12-07 21:45:42 -05:00
Jack O'Connor 47ef3ad01f add struct Hasher 2019-12-06 15:13:27 -05:00
Jack O'Connor 5458066da9 add hash/keyed_hash/derive_key and tests against reference_impl.rs 2019-12-04 18:17:24 -05:00
Jack O'Connor 1ed705374d add a few tests for the arithmetic helpers 2019-12-04 16:55:57 -05:00
Jack O'Connor 07890f36f6 switch from words to bytes in representing chaining values 2019-12-03 15:23:07 -05:00
Jack O'Connor e4e0b0f99d test_reference_impl_size 2019-12-02 17:32:33 -05:00
Jack O'Connor 21df6b1103 add portable.rs 2019-12-02 17:30:55 -05:00