Vendor Command + HID fix (#618)

* Fixes CBOR message passing through Vendor HID

I did all my tests on hardware with this fix, and now I'm surprised that
it didn't end up on develop. So should have been part of a former PR.

* vendor channel test

* forward vendor HID correctly for upgrades

* fixes cargo fmt

* removes script and updates documentation to match
This commit is contained in:
kaczmarczyck
2023-04-26 14:59:22 +02:00
committed by GitHub
parent bcd382e5e9
commit 645c1ba3a7
4 changed files with 28 additions and 41 deletions

View File

@@ -44,7 +44,7 @@ pub fn process_vendor_command(
channel: Channel,
) -> Option<Vec<u8>> {
#[cfg(feature = "vendor_hid")]
if matches!(channel, Channel::VendorHid(_)) {
if matches!(channel, Channel::MainHid(_)) {
return None;
}
process_cbor(env, bytes, channel).unwrap_or_else(|e| Some(vec![e as u8]))
@@ -290,6 +290,8 @@ mod test {
use cbor::cbor_map;
const DUMMY_CHANNEL: Channel = Channel::MainHid([0x12, 0x34, 0x56, 0x78]);
#[cfg(feature = "vendor_hid")]
const VENDOR_CHANNEL: Channel = Channel::VendorHid([0x12, 0x34, 0x56, 0x78]);
#[test]
fn test_process_cbor_unrelated_input() {
@@ -317,6 +319,17 @@ mod test {
.is_some());
}
#[test]
#[cfg(feature = "vendor_hid")]
fn test_process_command_valid_vendor_hid() {
let mut env = TockEnv::default();
let cbor_bytes = vec![VENDOR_COMMAND_UPGRADE_INFO];
assert!(process_cbor(&mut env, &cbor_bytes, VENDOR_CHANNEL)
.unwrap()
.is_some());
assert!(process_vendor_command(&mut env, &cbor_bytes, VENDOR_CHANNEL).is_some());
}
#[test]
fn test_vendor_configure_parameters() {
let dummy_cert = [0xddu8; 20];