mirror of
https://github.com/trezor/trezor-firmware.git
synced 2026-02-20 00:33:30 +01:00
fixup! feat(rust/trezor-thp): secure channel layer: device side
This commit is contained in:
@@ -727,7 +727,8 @@ fn test_invalid_channel_id() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn recompute_crc<R: Role>(wire: &mut VecDeque<Packet>) {
|
||||
// NOTE: does not work with CRC across packet boundary.
|
||||
fn recompute_crc(wire: &mut VecDeque<Packet>) {
|
||||
let payload_len: usize = u16::from_be_bytes([wire[0][3], wire[0][4]]).into();
|
||||
let mut crc_start = 5 + payload_len - crc32::CHECKSUM_LEN;
|
||||
let mut buf = Vec::new();
|
||||
@@ -763,9 +764,9 @@ fn damage_nth_fix_crc(
|
||||
// only way to damage continuations which are 1XXXXXXX (X = any)
|
||||
wire[pi][byte_index] ^= 0b1000_0000;
|
||||
if dir == HostToDevice {
|
||||
recompute_crc::<Device>(wire);
|
||||
recompute_crc(wire);
|
||||
} else {
|
||||
recompute_crc::<Host>(wire);
|
||||
recompute_crc(wire);
|
||||
}
|
||||
log::trace!("damaged+crc {}", hex::encode(&wire[pi]));
|
||||
index = None;
|
||||
|
||||
Reference in New Issue
Block a user