From 09d16deb8cc506bba6df2bbbf51d23eeb88a7736 Mon Sep 17 00:00:00 2001 From: QuantumEntangledAndy Date: Sun, 29 Aug 2021 14:57:03 +0700 Subject: [PATCH] Disable support for unknown 03 encryption --- crates/core/src/bc/de.rs | 41 +++++++++++++++++++++ crates/core/src/bc/samples/battery_enc.bin | Bin 0 -> 195 bytes crates/core/src/bc_protocol/login.rs | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 crates/core/src/bc/samples/battery_enc.bin diff --git a/crates/core/src/bc/de.rs b/crates/core/src/bc/de.rs index d546f18..46d998b 100644 --- a/crates/core/src/bc/de.rs +++ b/crates/core/src/bc/de.rs @@ -268,6 +268,47 @@ mod tests { } } + #[test] + // This is an 0xdd03 encryption from an Argus 2 + // + // It is currently unsupported + fn test_03_enc_login() { + let sample = include_bytes!("samples/battery_enc.bin"); + + let encryption_protocol = + std::sync::Arc::new(std::sync::Mutex::new(EncryptionProtocol::BCEncrypt)); + let mut context = BcContext::new(encryption_protocol); + + let (buf, header) = bc_header(&sample[..]).unwrap(); + assert!(bc_body(&mut context, &header, buf).is_err()); + // It should error because we don't support it + // + // The following would be its contents if we + // did support it (maybe one day :) left it here + // for then) + // + // + // let (_, body) = bc_body(&mut context, &header, buf).unwrap(); + // assert_eq!(header.msg_id, 1); + // assert_eq!(header.body_len, 175); + // assert_eq!(header.channel_id, 0); + // assert_eq!(header.stream_type, 0); + // assert_eq!(header.payload_offset, None); + // assert_eq!(header.response_code, 0xdd03); + // assert_eq!(header.class, 0x6614); + // match body { + // BcBody::ModernMsg(ModernMsg { + // payload: + // Some(BcPayloads::BcXml(BcXml { + // encryption: Some(encryption), + // .. + // })), + // .. + // }) => assert_eq!(encryption.nonce, "0-AhnEZyUg6eKrJFIWgXPF"), + // _ => panic!(), + // } + } + #[test] fn test_bc_legacy_login() { let sample = include_bytes!("samples/model_sample_legacy_login.bin"); diff --git a/crates/core/src/bc/samples/battery_enc.bin b/crates/core/src/bc/samples/battery_enc.bin new file mode 100644 index 0000000000000000000000000000000000000000..8c9514c86a838c9184fd3cf18059abc438f46279 GIT binary patch literal 195 zcmexxZx0tE0|Uc)AZB1-WMIB4lBO)=qGsmFH!C+TRK+AD>YSmhT(&*C^n_}cAf0q? z-PMr{ESXhdZeNxCgY}iei|*U=%9P8qOZTS5dMKH)M|4)j`vYm$yL!yLnJLK;Ao=Vn zPnYhr*vL|IUf;t8k*?PE5Pd-Lh{J_WK^peq9+%==gZLN(bZ2OKlv@hu8?LA*&EZXR g6Pr-z7g-wM2{cDgn9qcZt1Ukg=&tah!v+xh0m2wM*Z=?k literal 0 HcmV?d00001 diff --git a/crates/core/src/bc_protocol/login.rs b/crates/core/src/bc_protocol/login.rs index f8550fd..2a61ad0 100644 --- a/crates/core/src/bc_protocol/login.rs +++ b/crates/core/src/bc_protocol/login.rs @@ -35,7 +35,7 @@ impl BcCamera { channel_id: self.channel_id, msg_num: self.new_message_num(), stream_type: 0, - response_code: 0xdc03, + response_code: 0xdc02, class: 0x6514, }, body: BcBody::LegacyMsg(LegacyMsg::LoginMsg {