Skip to content

Commit 9c38b24

Browse files
committed
sha2: fixup deprecated method warnings
Signed-off-by: Wilfred Mallawa <[email protected]>
1 parent 3412290 commit 9c38b24

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/main.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -944,30 +944,30 @@ async fn generate_kernel_hash() -> Result<(), std::io::Error> {
944944

945945
copy(&mut file, &mut hasher)?;
946946
let hash_bytes = hasher.finalize();
947-
let slice_len = hash_bytes.as_slice().len();
947+
let slice_len = hash_bytes.len();
948948

949949
Lazy::force_mut(&mut dyn_image_measure).kernel_hashes[i][0..slice_len]
950-
.copy_from_slice(hash_bytes.as_slice());
950+
.copy_from_slice(hash_bytes.as_ref());
951951
}
952952
SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_384 => {
953953
let mut hasher = Sha384::new();
954954

955955
copy(&mut file, &mut hasher)?;
956956
let hash_bytes = hasher.finalize();
957-
let slice_len = hash_bytes.as_slice().len();
957+
let slice_len = hash_bytes.len();
958958

959959
Lazy::force_mut(&mut dyn_image_measure).kernel_hashes[i][0..slice_len]
960-
.copy_from_slice(hash_bytes.as_slice());
960+
.copy_from_slice(hash_bytes.as_ref());
961961
}
962962
SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_512 => {
963963
let mut hasher = Sha512::new();
964964

965965
copy(&mut file, &mut hasher)?;
966966
let hash_bytes = hasher.finalize();
967-
let slice_len = hash_bytes.as_slice().len();
967+
let slice_len = hash_bytes.len();
968968

969969
Lazy::force_mut(&mut dyn_image_measure).kernel_hashes[i][0..slice_len]
970-
.copy_from_slice(hash_bytes.as_slice());
970+
.copy_from_slice(hash_bytes.as_ref());
971971
}
972972
_ => continue,
973973
};
@@ -1008,30 +1008,30 @@ async fn generate_app_hash() -> Result<(), std::io::Error> {
10081008

10091009
copy(&mut file, &mut hasher)?;
10101010
let hash_bytes = hasher.finalize();
1011-
let slice_len = hash_bytes.as_slice().len();
1011+
let slice_len = hash_bytes.len();
10121012

10131013
Lazy::force_mut(&mut dyn_image_measure).app_hashes[i][0..slice_len]
1014-
.copy_from_slice(hash_bytes.as_slice());
1014+
.copy_from_slice(hash_bytes.as_ref());
10151015
}
10161016
SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_384 => {
10171017
let mut hasher = Sha384::new();
10181018

10191019
copy(&mut file, &mut hasher)?;
10201020
let hash_bytes = hasher.finalize();
1021-
let slice_len = hash_bytes.as_slice().len();
1021+
let slice_len = hash_bytes.len();
10221022

10231023
Lazy::force_mut(&mut dyn_image_measure).app_hashes[i][0..slice_len]
1024-
.copy_from_slice(hash_bytes.as_slice());
1024+
.copy_from_slice(hash_bytes.as_ref());
10251025
}
10261026
SPDM_ALGORITHMS_MEASUREMENT_HASH_ALGO_TPM_ALG_SHA_512 => {
10271027
let mut hasher = Sha512::new();
10281028

10291029
copy(&mut file, &mut hasher)?;
10301030
let hash_bytes = hasher.finalize();
1031-
let slice_len = hash_bytes.as_slice().len();
1031+
let slice_len = hash_bytes.len();
10321032

10331033
Lazy::force_mut(&mut dyn_image_measure).app_hashes[i][0..slice_len]
1034-
.copy_from_slice(hash_bytes.as_slice());
1034+
.copy_from_slice(hash_bytes.as_ref());
10351035
}
10361036
_ => continue,
10371037
};

0 commit comments

Comments
 (0)