Skip to content

Commit 847c7bd

Browse files
msirringhausjschanck
authored andcommitted
Remove apparently deprecated as_slice()-calls for Hash-results
1 parent 43c0cf1 commit 847c7bd

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/ctap2/commands/large_blobs.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ impl PinUvAuthCommand for LargeBlobs {
3939
data.extend([0x0c, 0x00]);
4040
data.extend((self.offset as u32).to_le_bytes());
4141
if let Some(ref set) = self.set {
42-
let mut hasher = Sha256::new();
43-
hasher.update(set.as_slice());
44-
data.extend(hasher.finalize().as_slice());
42+
data.extend(Sha256::digest(set.as_slice()));
4543
}
4644
param = Some(token.derive(&data).map_err(CommandError::Crypto)?);
4745
}
@@ -301,17 +299,15 @@ impl<'de> Deserialize<'de> for LargeBlobsResponse {
301299
let (mut large_blob, mut hash_slice) =
302300
payload.split_at(payload.len() - 16);
303301

304-
let mut hasher = Sha256::new();
305-
hasher.update(large_blob);
306-
let expected_hash = hasher.finalize();
302+
let expected_hash = Sha256::digest(large_blob);
307303
// The initial serialized large-blob array is the value of the serialized large-blob array on a fresh authenticator, as well as immediately after a reset. It is the byte string h'8076be8b528d0075f7aae98d6fa57a6d3c', which is an empty CBOR array (80) followed by LEFT(SHA-256(h'80'), 16).
308304
let default_large_blob = [0x80];
309305
let default_hash = [
310306
0x76, 0xbe, 0x8b, 0x52, 0x8d, 0x00, 0x75, 0xf7, 0xaa, 0xe9, 0x8d,
311307
0x6f, 0xa5, 0x7a, 0x6d, 0x3c,
312308
];
313309
// Once complete, the platform MUST confirm that the embedded SHA-256 hash is correct, based on the definition above. If not, the configuration is corrupt and the platform MUST discard it and act as if the initial serialized large-blob array was received.
314-
if &expected_hash.as_slice()[0..16] != hash_slice {
310+
if &expected_hash[0..16] != hash_slice {
315311
warn!("Large blob array hash doesn't match with the expected value! Assuming an empty array.");
316312
large_blob = &default_large_blob;
317313
hash_slice = &default_hash;

0 commit comments

Comments
 (0)