aboutsummaryrefslogtreecommitdiff
path: root/reference_impl
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2019-12-24 13:30:04 -0600
committerJack O'Connor <[email protected]>2019-12-24 13:30:04 -0600
commitc9ffbdd36532b89a1163a33071a5569bcef02ceb (patch)
tree63ed15376686614161e1f378c5e812667af7f149 /reference_impl
parent8aae07f91aa22fda0312c3966961f7ab4c3743a5 (diff)
use self.flags instead of self.chunk_state.flags in the reference impl
This is clearer, and because of padding requirements it doesn't change the size of the Hasher struct. (We have a test for this.)
Diffstat (limited to 'reference_impl')
-rw-r--r--reference_impl/reference_impl.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/reference_impl/reference_impl.rs b/reference_impl/reference_impl.rs
index bcc7ccc..3be4e5a 100644
--- a/reference_impl/reference_impl.rs
+++ b/reference_impl/reference_impl.rs
@@ -246,6 +246,7 @@ pub struct Hasher {
key: [u32; 8],
cv_stack: [[u32; 8]; 54], // Space for 54 subtree chaining values:
cv_stack_len: u8, // 2^54 * CHUNK_LEN = 2^64
+ flags: u32,
}
impl Hasher {
@@ -255,6 +256,7 @@ impl Hasher {
key,
cv_stack: [[0; 8]; 54],
cv_stack_len: 0,
+ flags,
}
}
@@ -297,7 +299,7 @@ impl Hasher {
// the same as the number of trailing 1 bits in the previous total
// number of chunks.
while previous_total & 1 == 1 {
- new_cv = parent_cv(self.pop_stack(), new_cv, self.key, self.chunk_state.flags);
+ new_cv = parent_cv(self.pop_stack(), new_cv, self.key, self.flags);
previous_total >>= 1;
}
self.push_stack(new_cv);
@@ -312,7 +314,7 @@ impl Hasher {
let chunk_cv = self.chunk_state.output().chaining_value();
let counter = self.chunk_state.chunk_counter;
self.add_chunk_chaining_value(chunk_cv, counter);
- self.chunk_state = ChunkState::new(self.key, counter + 1, self.chunk_state.flags);
+ self.chunk_state = ChunkState::new(self.key, counter + 1, self.flags);
}
// Compress input bytes into the current chunk state.
@@ -336,7 +338,7 @@ impl Hasher {
self.cv_stack[parent_nodes_remaining],
output.chaining_value(),
self.key,
- self.chunk_state.flags,
+ self.flags,
);
}
output.root_output_bytes(out_slice);