Skip to content

Commit c797428

Browse files
committed
update deps
1 parent 77ec009 commit c797428

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

blake/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blake"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Kaz Wesley <[email protected]>"]
55
license = "MIT/Apache-2.0"
66
description = "BLAKE hash functions"
@@ -9,9 +9,8 @@ keywords = ["crypto", "blake", "hash", "digest"]
99
categories = ["cryptography", "no-std"]
1010

1111
[dependencies]
12-
block-buffer = "0.3"
13-
byte-tools = "0.2"
14-
digest = "^0.7.1"
12+
block-buffer = "0.7"
13+
digest = "0.8"
1514

1615
[badges]
1716
travis-ci = { repository = "RustCrypto/hashes" }

blake/src/lib.rs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#![no_std]
66

77
extern crate block_buffer;
8-
extern crate byte_tools;
98
pub extern crate digest;
109

1110
mod consts;
1211

12+
use block_buffer::BlockBuffer;
1313
use core::mem;
1414
use digest::generic_array::GenericArray;
1515
pub use digest::Digest;
@@ -24,11 +24,11 @@ struct State<T> {
2424
}
2525

2626
macro_rules! define_compressor {
27-
($compressor:ident, $word:ident, $buf:expr, $deserializer:ident, $uval:expr,
27+
($compressor:ident, $word:ident, $Bufsz:ty, $deserializer:path, $uval:expr,
2828
$rounds:expr, $shift0:expr, $shift1:expr, $shift2: expr, $shift3: expr) => {
2929
#[derive(Clone, Copy, Debug)]
3030
struct $compressor {
31-
state: State<$word>
31+
state: State<$word>,
3232
}
3333

3434
impl $compressor {
@@ -38,7 +38,7 @@ macro_rules! define_compressor {
3838
if carry { self.state.t[1] += 1; }
3939
}
4040

41-
fn put_block(&mut self, block: &[u8; $buf]) {
41+
fn put_block(&mut self, block: &GenericArray<u8, $Bufsz>) {
4242
const U: [$word; 16] = $uval;
4343

4444
#[inline(always)]
@@ -102,12 +102,12 @@ macro_rules! define_compressor {
102102
}
103103

104104
macro_rules! define_hasher {
105-
($name:ident, $word:ident, $buf:expr, $Buffer:ident, $bits:expr, $Bytes:ident,
106-
$serializer:ident, $compressor:ident, $iv:expr) => {
107-
#[derive(Clone, Copy)]
105+
($name:ident, $word:ident, $buf:expr, $Bufsz:ty, $bits:expr, $Bytes:ident,
106+
$serializer:path, $compressor:ident, $iv:expr) => {
107+
#[derive(Clone)]
108108
pub struct $name {
109109
compressor: $compressor,
110-
buffer: $Buffer
110+
buffer: BlockBuffer<$Bufsz>,
111111
}
112112

113113
impl core::fmt::Debug for $name {
@@ -130,7 +130,7 @@ macro_rules! define_hasher {
130130
nullt: false,
131131
}
132132
},
133-
buffer: $Buffer::default()
133+
buffer: BlockBuffer::default(),
134134
}
135135
}
136136
}
@@ -140,9 +140,9 @@ macro_rules! define_hasher {
140140
}
141141

142142
impl digest::Input for $name {
143-
fn process(&mut self, data: &[u8]) {
143+
fn input<T: AsRef<[u8]>>(&mut self, data: T) {
144144
let compressor = &mut self.compressor;
145-
self.buffer.input(data, |block| {
145+
self.buffer.input(data.as_ref(), |block| {
146146
compressor.increase_count((mem::size_of::<$word>() * 16) as $word);
147147
compressor.put_block(block);
148148
});
@@ -196,33 +196,35 @@ macro_rules! define_hasher {
196196
out
197197
}
198198
}
199-
}
199+
200+
impl digest::Reset for $name {
201+
fn reset(&mut self) {
202+
*self = Self::default()
203+
}
204+
}
205+
};
200206
}
201207

202-
use block_buffer::{BlockBuffer1024, BlockBuffer512};
203-
use byte_tools::{read_u32_be, read_u64_be, write_u32_be, write_u64_be};
204-
use consts::{BLAKE224_IV, BLAKE256_IV, BLAKE256_U, BLAKE384_IV, BLAKE512_IV, BLAKE512_U, PADDING,
205-
SIGMA};
206-
use digest::generic_array::typenum::{U28, U32, U48, U64};
208+
use block_buffer::byteorder::{ByteOrder, BE};
209+
use consts::{
210+
BLAKE224_IV, BLAKE256_IV, BLAKE256_U, BLAKE384_IV, BLAKE512_IV, BLAKE512_U, PADDING, SIGMA,
211+
};
212+
use digest::generic_array::typenum::{U128, U28, U32, U48, U64};
207213

208214
#[cfg_attr(rustfmt, rustfmt_skip)]
209-
define_compressor!(Compressor256, u32, 64, read_u32_be, BLAKE256_U, 14, 16, 12, 8, 7);
215+
define_compressor!(Compressor256, u32, U64, BE::read_u32, BLAKE256_U, 14, 16, 12, 8, 7);
210216

211217
#[cfg_attr(rustfmt, rustfmt_skip)]
212-
define_hasher!(
213-
Blake224, u32, 64, BlockBuffer512, 224, U28, write_u32_be, Compressor256, BLAKE224_IV);
218+
define_hasher!(Blake224, u32, 64, U64, 224, U28, BE::write_u32, Compressor256, BLAKE224_IV);
214219

215220
#[cfg_attr(rustfmt, rustfmt_skip)]
216-
define_hasher!(
217-
Blake256, u32, 64, BlockBuffer512, 256, U32, write_u32_be, Compressor256, BLAKE256_IV);
221+
define_hasher!(Blake256, u32, 64, U64, 256, U32, BE::write_u32, Compressor256, BLAKE256_IV);
218222

219223
#[cfg_attr(rustfmt, rustfmt_skip)]
220-
define_compressor!(Compressor512, u64, 128, read_u64_be, BLAKE512_U, 16, 32, 25, 16, 11);
224+
define_compressor!(Compressor512, u64, U128, BE::read_u64, BLAKE512_U, 16, 32, 25, 16, 11);
221225

222226
#[cfg_attr(rustfmt, rustfmt_skip)]
223-
define_hasher!(
224-
Blake384, u64, 128, BlockBuffer1024, 384, U48, write_u64_be, Compressor512, BLAKE384_IV);
227+
define_hasher!(Blake384, u64, 128, U128, 384, U48, BE::write_u64, Compressor512, BLAKE384_IV);
225228

226229
#[cfg_attr(rustfmt, rustfmt_skip)]
227-
define_hasher!(
228-
Blake512, u64, 128, BlockBuffer1024, 512, U64, write_u64_be, Compressor512, BLAKE512_IV);
230+
define_hasher!(Blake512, u64, 128, U128, 512, U64, BE::write_u64, Compressor512, BLAKE512_IV);

0 commit comments

Comments
 (0)