mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-09 15:56:23 +02:00
Compare commits
3 Commits
207c7463c8
...
0525703fe7
Author | SHA1 | Date | |
---|---|---|---|
Jeremy Maitin-Shepard | 0525703fe7 | ||
Jack O'Connor | 4ec3be8bfa | ||
Jeremy Maitin-Shepard | 680bdb58f7 |
15
c/blake3.c
15
c/blake3.c
|
@ -5,6 +5,13 @@
|
|||
#include "blake3.h"
|
||||
#include "blake3_impl.h"
|
||||
|
||||
#ifdef __has_feature
|
||||
#if __has_feature(memory_sanitizer)
|
||||
#include <sanitizer/msan_interface.h>
|
||||
#define BLAKE3_MEMORY_SANITIZER_BUILD
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const char *blake3_version(void) { return BLAKE3_VERSION_STRING; }
|
||||
|
||||
INLINE void chunk_state_init(blake3_chunk_state *self, const uint32_t key[8],
|
||||
|
@ -583,6 +590,10 @@ void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,
|
|||
if (self->cv_stack_len == 0) {
|
||||
output_t output = chunk_state_output(&self->chunk);
|
||||
output_root_bytes(&output, seek, out, out_len);
|
||||
#ifdef BLAKE3_MEMORY_SANITIZER_BUILD
|
||||
// MemorySanitizer gives a false positive due to use of assembly.
|
||||
__msan_unpoison(out, out_len);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
// If there are any bytes in the chunk state, finalize that chunk and do a
|
||||
|
@ -611,6 +622,10 @@ void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,
|
|||
output = parent_output(parent_block, self->key, self->chunk.flags);
|
||||
}
|
||||
output_root_bytes(&output, seek, out, out_len);
|
||||
#ifdef BLAKE3_MEMORY_SANITIZER_BUILD
|
||||
// MemorySanitizer gives a false positive due to use of assembly.
|
||||
__msan_unpoison(out, out_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
void blake3_hasher_reset(blake3_hasher *self) {
|
||||
|
|
|
@ -78,23 +78,14 @@ fn compress(
|
|||
block_len: u32,
|
||||
flags: u32,
|
||||
) -> [u32; 16] {
|
||||
let counter_low = counter as u32;
|
||||
let counter_high = (counter >> 32) as u32;
|
||||
#[rustfmt::skip]
|
||||
let mut state = [
|
||||
chaining_value[0],
|
||||
chaining_value[1],
|
||||
chaining_value[2],
|
||||
chaining_value[3],
|
||||
chaining_value[4],
|
||||
chaining_value[5],
|
||||
chaining_value[6],
|
||||
chaining_value[7],
|
||||
IV[0],
|
||||
IV[1],
|
||||
IV[2],
|
||||
IV[3],
|
||||
counter as u32,
|
||||
(counter >> 32) as u32,
|
||||
block_len,
|
||||
flags,
|
||||
chaining_value[0], chaining_value[1], chaining_value[2], chaining_value[3],
|
||||
chaining_value[4], chaining_value[5], chaining_value[6], chaining_value[7],
|
||||
IV[0], IV[1], IV[2], IV[3],
|
||||
counter_low, counter_high, block_len, flags,
|
||||
];
|
||||
let mut block = *block_words;
|
||||
|
||||
|
|
Loading…
Reference in New Issue