Skip to content

Commit 7c0c7e0

Browse files
committed
sha1: to_u32x16: take array instead of slice
This bumps the MSRV to 1.47.0 due to rust#74060[0] [0]: rust-lang/rust#74060
1 parent fa173d3 commit 7c0c7e0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/sha1.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::fmt;
1+
use std::{fmt, convert::TryInto};
22

33
const H0: u32 = 0x67452301;
44
const H1: u32 = 0xEFCDAB89;
@@ -184,7 +184,7 @@ fn process_block(blk: &mut Sha1State, dat: [u32;16]) {
184184
blk.e = blk.e.wrapping_add(v.e);
185185
}
186186

187-
fn to_u32x16(v: &[u8]) -> [u32;16] {
187+
fn to_u32x16(v: &[u8;64]) -> [u32;16] {
188188
let mut res: [u32;16] = [0; 16];
189189
for i in 0..16 {
190190
res[i] = ((v[i*4] as u32) << 24) | ((v[i*4 + 1] as u32) << 16) | ((v[i*4 + 2] as u32) << 8) | (v[i*4 + 3] as u32);
@@ -200,15 +200,15 @@ pub fn sha1(dat: &[u8]) -> Sha1State {
200200
let mut off: usize = 0;
201201

202202
while off + 64 <= len {
203-
process_block(&mut res, to_u32x16(&dat[off..off + 64]));
203+
process_block(&mut res, to_u32x16(dat[off..off + 64].try_into().unwrap()));
204204
off += 64;
205205
}
206206
let mut pad: [u8;64] = [0;64];
207207
for i in off..len {
208208
pad[i - off] = dat[i];
209209
}
210210
pad[len - off] = 0x80;
211-
let mut padu32 = to_u32x16(&pad[..]);
211+
let mut padu32 = to_u32x16(&pad);
212212

213213
let lenh = ((len * 8) >> 32) as u32;
214214
let lenl = ((len * 8) & 0xffff_ffff) as u32;

0 commit comments

Comments
 (0)