Skip to content

Commit

Permalink
universal-hash: rename update_block => update
Browse files Browse the repository at this point in the history
Updating (in the IUF sense) the UHF state by a block is the core
"update" primitive, so it makes sense to make it first-class.
  • Loading branch information
tarcieri committed May 23, 2020
1 parent dcbdbbc commit 9a611e8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions universal-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait UniversalHash: Clone {
fn new(key: &Key<Self>) -> Self;

/// Input a block into the universal hash function
fn update_block(&mut self, block: &Block<Self>);
fn update(&mut self, block: &Block<Self>);

/// Input data into the universal hash function. If the length of the
/// data is not a multiple of the block size, the remaining data is
Expand All @@ -60,15 +60,15 @@ pub trait UniversalHash: Clone {
let mut chunks = data.chunks_exact(Self::BlockSize::to_usize());

for chunk in &mut chunks {
self.update_block(GenericArray::from_slice(chunk));
self.update(GenericArray::from_slice(chunk));
}

let rem = chunks.remainder();

if !rem.is_empty() {
let mut padded_block = GenericArray::default();
padded_block[..rem.len()].copy_from_slice(rem);
self.update_block(&padded_block);
self.update(&padded_block);
}
}

Expand Down

0 comments on commit 9a611e8

Please sign in to comment.