1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-23 17:06:05 +02:00
Commit Graph

138 Commits

Author SHA1 Message Date
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
Ricardo Fernández Serrata 0fb6410c90 Fix doc typo 2022-07-28 14:14:39 -07:00
Jack O'Connor 46cf7b7315 simplify a line in the docs example code
The same change was previously made in README.md.
2022-06-07 21:52:51 -07:00
Jack O'Connor 48c4621edc add "(if any)" regarding keying in the security notes 2022-03-04 10:19:14 -05:00
Jack O'Connor d295410aad simplify a bit more 2022-03-03 11:52:58 -05:00
Jack O'Connor b3c06e46ed simplify the security notes, avoid referring to entropy 2022-03-02 19:05:15 -05:00
Jack O'Connor ea3bc782d8 document the extended output security issue found by Aldo Gunsing
https://eprint.iacr.org/2022/283
2022-03-02 17:39:25 -05:00
Jack O'Connor 540f708a94 check the HMAC output bytes 2022-01-24 20:52:22 -05:00
jbis9051 509e97ed90 Adds test 2022-01-24 19:29:33 -05:00
jbis9051 e069e46116 Add blocksize trait 2022-01-23 15:46:04 -05:00
Jack O'Connor c7b5881928 a few more comment tweaks 2021-12-30 13:34:13 -05:00
Matthias Schiffer 61d6621ba5 Update digest crate to 0.10 for traits-preview feature
Adjust to the following changes that happened in digest:

- The crypto-mac crate has been merged into digest (with "mac" feature
  enabled)
- Various traits have been split up
- The Digest and Mac traits now share their update/finalize/reset
  implementations
- The BlockInput trait was dropped without replacement apparently (as
  long as the low-level core API is not used)
2021-12-30 13:31:20 -05: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 04571021fb add Hasher::count 2021-11-04 20:37:05 -04:00
Jack O'Connor f35d031578 remove an incorrect comment 2021-10-29 12:07:28 -04:00
Jack O'Connor 1f2010d79e update NEON docs in lib.rs 2021-10-23 13:09:52 -04:00
rsdy 0a0bb7126e Implement better target detection for NEON 2021-10-07 12:41:53 +01:00
Jack O'Connor c4582c9779 clarify that OutputReader::position is equivalent to Seek::stream_position 2021-09-10 12:59:13 -04:00
Jack O'Connor 3baa54476a link to the paper in the derive_key docs 2021-09-10 12:48:58 -04:00
Jack O'Connor 5aef6849bb update README examples 2021-07-25 12:42:09 -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 7cd208afcf explicitly document the properties of short outputs
Suggested by @joshtriplett at:
https://github.com/BLAKE3-team/BLAKE3/issues/168#issuecomment-829609667
2021-05-18 11:02:05 -04:00
Jack O'Connor 4b7babbe99 more cleaup of undocumented API 2021-03-28 20:04:51 -04:00
Jack O'Connor dab97de401 update doc comments on guts module 2021-03-28 15:21:02 -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 07b746b1b4 gate digest and crypto-mac implementations behind "traits-preview"
This approach was suggested by @tarcieri at
https://github.com/BLAKE3-team/BLAKE3/pull/157.
2021-03-21 15:53:26 -04:00
Jack O'Connor 7155e5bb71 Rayon-related doc fixes 2021-03-20 15:25:14 -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
Jack O'Connor 134bb24686 impl PartialEq<[u8]> for Hash 2021-02-28 17:50:06 -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 004b39a350 cargo fmt 2020-09-10 15:55:02 -04:00
Jack O'Connor 3c1db55529 add the dynamic check for SSE2 support
It will be very rare that this actually executes, but we should include
it for completeness.
2020-08-31 18:25:38 -04:00
Jack O'Connor a79fec7e39 fix a build break on x86 targets without guaranteed SSE2 support
This is quite hard to trigger, because SSE2 has been guaranteed for a
long time. But you could trigger it this way:

    rustup target add i686-unknown-linux-musl
    RUSTFLAGS="-C target-cpu=i386" cargo build --target i686-unknown-linux-musl

Note a relevant gotcha though: The `cross` tool will not forward
environment variables like RUSTFLAGS to the container by default, so if
you're testing with `cross` you'll need to use the `rustc` command to
explicitly pass the flag, as I've done here in ci.yml. (Or you could
create a `Cross.toml` file, but I don't want to commit one of those if I
can avoid it.)
2020-08-31 18:25:38 -04:00
Samuel Neves 3340e32c7f
Merge pull request #110 from mkrupcale/sse2
Add SSE2 implementations
2020-08-31 18:56:55 +01:00
Nikolai Vazquez 324090b2c3 Implement `fmt::Debug` using builders
This enables pretty printing via `{:#?}`. The normal style for `{:?}` is
kept exactly the same.
2020-08-31 12:04:40 -04:00
Matthew Krupcale c33a8462d1 Write _mm_blend_epi16 emulation without multiplication
Use _mm_and_si128 and _mm_cmpeq_epi16 rather than expensive multiplication _mm_mullo_epi16 with _mm_srai_epi16 that compiler may not be able to optimize.
2020-08-25 12:26:15 -04:00
Matthew Krupcale c32660099a Fix unreachable expression compiler warning
SSE2 target_feature appears to always be present for x86_64.
2020-08-24 21:09:56 -04:00
Matthew Krupcale 40a4a2b6b0 SSE2 intrinsic: emulate _mm_blend_epi16 SSE4.1 intrinsic with SSE2 intrinsics
Use a constant mask to blend according to (mask & b) | ((~mask) & a).

 * src/rust_sse2.rs: emulate _mm_blend_epi16 using SSE2 intrinsics
 * c/blake3_sse2.c: Likewise.
2020-08-24 00:55:06 -04:00
Matthew Krupcale d91f20dd29 Start SSE2 implementation based on SSE4.1 version
Wire up basic functions and features for SSE2 support using the SSE4.1 version
as a basis without implementing the SSE2 instructions yet.

 * Cargo.toml: add no_sse2 feature
 * benches/bench.rs: wire SSE2 benchmarks
 * build.rs: add SSE2 rust intrinsics and assembly builds
 * c/Makefile.testing: add SSE2 C and assembly targets
 * c/README.md: add SSE2 to C build instructions
 * c/blake3_c_rust_bindings/build.rs: add SSE2 C rust binding builds
 * c/blake3_c_rust_bindings/src/lib.rs: add SSE2 C rust bindings
 * c/blake3_dispatch.c: add SSE2 C dispatch
 * c/blake3_impl.h: add SSE2 C function prototypes
 * c/blake3_sse2.c: add SSE2 C intrinsic file starting with SSE4.1 version
 * c/blake3_sse2_x86-64_{unix.S,windows_gnu.S,windows_msvc.asm}: add SSE2
   assembly files starting with SSE4.1 version
 * src/ffi_sse2.rs: add rust implementation using SSE2 C rust bindings
 * src/lib.rs: add SSE2 rust intrinsics and SSE2 C rust binding rust SSE2 module
   configurations
 * src/platform.rs: add SSE2 rust platform detection and dispatch
 * src/rust_sse2.rs: add SSE2 rust intrinsic file starting with SSE4.1 version
 * tools/instruction_set_support/src/main.rs: add SSE2 feature detection
2020-08-24 00:54:46 -04:00
Jack O'Connor 09cc03614d the same hex example for rustdocs 2020-08-14 11:33:53 -04:00
Jack O'Connor c908847c3f shrink a stack array that's twice as big as it needs to be
It looks like I originally made this mistake when I was copying code
from the baokeshed prototype (a274a9b0fa),
and then it got replicated into the C implementation later.
2020-06-26 16:16:55 -04:00
Jack O'Connor 4c41a893a0 a little bit of cleanup and more testing 2020-06-14 14:35:47 -04:00
Justus K 1ecb14ce34 Replace std::io::copy with clone_from_slice 2020-06-14 14:35:14 -04:00