digest internals: Call block_data_order
from one point.
Step towards future memory safety clarifications.
This commit is contained in:
parent
6347be9634
commit
5b437d514f
@ -61,9 +61,8 @@ impl BlockContext {
|
||||
assert_eq!(num_blocks * self.algorithm.block_len, input.len());
|
||||
|
||||
if num_blocks > 0 {
|
||||
let _cpu_features = self.cpu_features;
|
||||
unsafe {
|
||||
(self.algorithm.block_data_order)(&mut self.state, input.as_ptr(), num_blocks);
|
||||
self.block_data_order(input.as_ptr(), num_blocks);
|
||||
}
|
||||
self.completed_data_blocks = self
|
||||
.completed_data_blocks
|
||||
@ -83,9 +82,7 @@ impl BlockContext {
|
||||
|
||||
if padding_pos > block_len - self.algorithm.len_len {
|
||||
pending[padding_pos..block_len].fill(0);
|
||||
unsafe {
|
||||
(self.algorithm.block_data_order)(&mut self.state, pending.as_ptr(), 1);
|
||||
}
|
||||
unsafe { self.block_data_order(pending.as_ptr(), 1) };
|
||||
// We don't increase |self.completed_data_blocks| because the
|
||||
// padding isn't data, and so it isn't included in the data length.
|
||||
padding_pos = 0;
|
||||
@ -104,15 +101,21 @@ impl BlockContext {
|
||||
.unwrap();
|
||||
pending[(block_len - 8)..block_len].copy_from_slice(&u64::to_be_bytes(completed_data_bits));
|
||||
|
||||
unsafe {
|
||||
(self.algorithm.block_data_order)(&mut self.state, pending.as_ptr(), 1);
|
||||
}
|
||||
unsafe { self.block_data_order(pending.as_ptr(), 1) };
|
||||
|
||||
Digest {
|
||||
algorithm: self.algorithm,
|
||||
value: (self.algorithm.format_output)(self.state),
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn block_data_order(&mut self, pending: *const u8, num_blocks: usize) {
|
||||
// CPU features are inspected by assembly implementations.
|
||||
let _cpu_features = self.cpu_features;
|
||||
unsafe {
|
||||
(self.algorithm.block_data_order)(&mut self.state, pending, num_blocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A context for multi-step (Init-Update-Finish) digest calculations.
|
||||
|
Loading…
x
Reference in New Issue
Block a user