1use crate::Message;
2use crate::ClientMessage;
3use std::io::{Read, Write};
4
5use crate::logon::version_2::TelemetryKey;
6use crate::logon::version_8::SecurityFlag;
7
8#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
31pub struct CMD_AUTH_LOGON_PROOF_Client {
32 pub client_public_key: [u8; 32],
33 pub client_proof: [u8; 20],
34 pub crc_hash: [u8; 20],
35 pub telemetry_keys: Vec<TelemetryKey>,
36 pub security_flag: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag,
37}
38
39impl CMD_AUTH_LOGON_PROOF_Client {
40 pub(crate) fn write_into_vec(&self, mut w: impl Write) -> Result<(), std::io::Error> {
41 w.write_all(&Self::OPCODE.to_le_bytes())?;
43
44 for i in self.client_public_key.iter() {
46 w.write_all(&i.to_le_bytes())?;
47 }
48
49 for i in self.client_proof.iter() {
51 w.write_all(&i.to_le_bytes())?;
52 }
53
54 for i in self.crc_hash.iter() {
56 w.write_all(&i.to_le_bytes())?;
57 }
58
59 w.write_all(&(self.telemetry_keys.len() as u8).to_le_bytes())?;
61
62 for i in self.telemetry_keys.iter() {
64 i.write_into_vec(&mut w)?;
65 }
66
67 w.write_all(&(self.security_flag.as_int().to_le_bytes()))?;
69
70 if let Some(if_statement) = &self.security_flag.pin {
71 for i in if_statement.pin_salt.iter() {
73 w.write_all(&i.to_le_bytes())?;
74 }
75
76 for i in if_statement.pin_hash.iter() {
78 w.write_all(&i.to_le_bytes())?;
79 }
80
81 }
82
83 if let Some(if_statement) = &self.security_flag.matrix_card {
84 for i in if_statement.matrix_card_proof.iter() {
86 w.write_all(&i.to_le_bytes())?;
87 }
88
89 }
90
91 if let Some(if_statement) = &self.security_flag.authenticator {
92 w.write_all(&(if_statement.authenticator.len() as u8).to_le_bytes())?;
94 w.write_all(if_statement.authenticator.as_bytes())?;
95
96 }
97
98 Ok(())
99 }
100}
101
102impl crate::private::Sealed for CMD_AUTH_LOGON_PROOF_Client {}
103
104impl CMD_AUTH_LOGON_PROOF_Client {
105 #[cfg(feature = "sync")]
106 fn read_inner<R: std::io::Read>(mut r: R) -> Result<Self, crate::errors::ParseErrorKind> {
107 let client_public_key = {
109 let mut client_public_key = [0_u8; 32];
110 r.read_exact(&mut client_public_key)?;
111 client_public_key
112 };
113
114 let client_proof = {
116 let mut client_proof = [0_u8; 20];
117 r.read_exact(&mut client_proof)?;
118 client_proof
119 };
120
121 let crc_hash = {
123 let mut crc_hash = [0_u8; 20];
124 r.read_exact(&mut crc_hash)?;
125 crc_hash
126 };
127
128 let number_of_telemetry_keys = crate::util::read_u8_le(&mut r)?;
130
131 let telemetry_keys = {
133 let mut telemetry_keys = Vec::with_capacity(number_of_telemetry_keys as usize);
134 for _ in 0..number_of_telemetry_keys {
135 telemetry_keys.push(TelemetryKey::read(&mut r)?);
136 }
137 telemetry_keys
138 };
139
140 let security_flag = SecurityFlag::new(crate::util::read_u8_le(&mut r)?);
142
143 let security_flag_pin = if security_flag.is_pin() {
144 let pin_salt = {
146 let mut pin_salt = [0_u8; 16];
147 r.read_exact(&mut pin_salt)?;
148 pin_salt
149 };
150
151 let pin_hash = {
153 let mut pin_hash = [0_u8; 20];
154 r.read_exact(&mut pin_hash)?;
155 pin_hash
156 };
157
158 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin {
159 pin_hash,
160 pin_salt,
161 })
162 }
163 else {
164 None
165 };
166
167 let security_flag_matrix_card = if security_flag.is_matrix_card() {
168 let matrix_card_proof = {
170 let mut matrix_card_proof = [0_u8; 20];
171 r.read_exact(&mut matrix_card_proof)?;
172 matrix_card_proof
173 };
174
175 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard {
176 matrix_card_proof,
177 })
178 }
179 else {
180 None
181 };
182
183 let security_flag_authenticator = if security_flag.is_authenticator() {
184 let authenticator = {
186 let authenticator = crate::util::read_u8_le(&mut r)?;
187 let authenticator = crate::util::read_fixed_string_to_vec(&mut r, authenticator as usize)?;
188 String::from_utf8(authenticator)?
189 };
190
191 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator {
192 authenticator,
193 })
194 }
195 else {
196 None
197 };
198
199 let security_flag = CMD_AUTH_LOGON_PROOF_Client_SecurityFlag {
200 inner: security_flag.as_int(),
201 pin: security_flag_pin,
202 matrix_card: security_flag_matrix_card,
203 authenticator: security_flag_authenticator,
204 };
205
206 Ok(Self {
207 client_public_key,
208 client_proof,
209 crc_hash,
210 telemetry_keys,
211 security_flag,
212 })
213 }
214
215 #[cfg(feature = "tokio")]
216 async fn tokio_read_inner<R: tokio::io::AsyncReadExt + Unpin + Send>(mut r: R) -> Result<Self, crate::errors::ParseErrorKind> {
217 let client_public_key = {
219 let mut client_public_key = [0_u8; 32];
220 r.read_exact(&mut client_public_key).await?;
221 client_public_key
222 };
223
224 let client_proof = {
226 let mut client_proof = [0_u8; 20];
227 r.read_exact(&mut client_proof).await?;
228 client_proof
229 };
230
231 let crc_hash = {
233 let mut crc_hash = [0_u8; 20];
234 r.read_exact(&mut crc_hash).await?;
235 crc_hash
236 };
237
238 let number_of_telemetry_keys = crate::util::tokio_read_u8_le(&mut r).await?;
240
241 let telemetry_keys = {
243 let mut telemetry_keys = Vec::with_capacity(number_of_telemetry_keys as usize);
244 for _ in 0..number_of_telemetry_keys {
245 telemetry_keys.push(TelemetryKey::tokio_read(&mut r).await?);
246 }
247 telemetry_keys
248 };
249
250 let security_flag = SecurityFlag::new(crate::util::tokio_read_u8_le(&mut r).await?);
252
253 let security_flag_pin = if security_flag.is_pin() {
254 let pin_salt = {
256 let mut pin_salt = [0_u8; 16];
257 r.read_exact(&mut pin_salt).await?;
258 pin_salt
259 };
260
261 let pin_hash = {
263 let mut pin_hash = [0_u8; 20];
264 r.read_exact(&mut pin_hash).await?;
265 pin_hash
266 };
267
268 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin {
269 pin_hash,
270 pin_salt,
271 })
272 }
273 else {
274 None
275 };
276
277 let security_flag_matrix_card = if security_flag.is_matrix_card() {
278 let matrix_card_proof = {
280 let mut matrix_card_proof = [0_u8; 20];
281 r.read_exact(&mut matrix_card_proof).await?;
282 matrix_card_proof
283 };
284
285 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard {
286 matrix_card_proof,
287 })
288 }
289 else {
290 None
291 };
292
293 let security_flag_authenticator = if security_flag.is_authenticator() {
294 let authenticator = {
296 let authenticator = crate::util::tokio_read_u8_le(&mut r).await?;
297 let authenticator = crate::util::tokio_read_fixed_string_to_vec(&mut r, authenticator as usize).await?;
298 String::from_utf8(authenticator)?
299 };
300
301 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator {
302 authenticator,
303 })
304 }
305 else {
306 None
307 };
308
309 let security_flag = CMD_AUTH_LOGON_PROOF_Client_SecurityFlag {
310 inner: security_flag.as_int(),
311 pin: security_flag_pin,
312 matrix_card: security_flag_matrix_card,
313 authenticator: security_flag_authenticator,
314 };
315
316 Ok(Self {
317 client_public_key,
318 client_proof,
319 crc_hash,
320 telemetry_keys,
321 security_flag,
322 })
323 }
324
325 #[cfg(feature = "async-std")]
326 async fn astd_read_inner<R: async_std::io::ReadExt + Unpin + Send>(mut r: R) -> Result<Self, crate::errors::ParseErrorKind> {
327 let client_public_key = {
329 let mut client_public_key = [0_u8; 32];
330 r.read_exact(&mut client_public_key).await?;
331 client_public_key
332 };
333
334 let client_proof = {
336 let mut client_proof = [0_u8; 20];
337 r.read_exact(&mut client_proof).await?;
338 client_proof
339 };
340
341 let crc_hash = {
343 let mut crc_hash = [0_u8; 20];
344 r.read_exact(&mut crc_hash).await?;
345 crc_hash
346 };
347
348 let number_of_telemetry_keys = crate::util::astd_read_u8_le(&mut r).await?;
350
351 let telemetry_keys = {
353 let mut telemetry_keys = Vec::with_capacity(number_of_telemetry_keys as usize);
354 for _ in 0..number_of_telemetry_keys {
355 telemetry_keys.push(TelemetryKey::astd_read(&mut r).await?);
356 }
357 telemetry_keys
358 };
359
360 let security_flag = SecurityFlag::new(crate::util::astd_read_u8_le(&mut r).await?);
362
363 let security_flag_pin = if security_flag.is_pin() {
364 let pin_salt = {
366 let mut pin_salt = [0_u8; 16];
367 r.read_exact(&mut pin_salt).await?;
368 pin_salt
369 };
370
371 let pin_hash = {
373 let mut pin_hash = [0_u8; 20];
374 r.read_exact(&mut pin_hash).await?;
375 pin_hash
376 };
377
378 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin {
379 pin_hash,
380 pin_salt,
381 })
382 }
383 else {
384 None
385 };
386
387 let security_flag_matrix_card = if security_flag.is_matrix_card() {
388 let matrix_card_proof = {
390 let mut matrix_card_proof = [0_u8; 20];
391 r.read_exact(&mut matrix_card_proof).await?;
392 matrix_card_proof
393 };
394
395 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard {
396 matrix_card_proof,
397 })
398 }
399 else {
400 None
401 };
402
403 let security_flag_authenticator = if security_flag.is_authenticator() {
404 let authenticator = {
406 let authenticator = crate::util::astd_read_u8_le(&mut r).await?;
407 let authenticator = crate::util::astd_read_fixed_string_to_vec(&mut r, authenticator as usize).await?;
408 String::from_utf8(authenticator)?
409 };
410
411 Some(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator {
412 authenticator,
413 })
414 }
415 else {
416 None
417 };
418
419 let security_flag = CMD_AUTH_LOGON_PROOF_Client_SecurityFlag {
420 inner: security_flag.as_int(),
421 pin: security_flag_pin,
422 matrix_card: security_flag_matrix_card,
423 authenticator: security_flag_authenticator,
424 };
425
426 Ok(Self {
427 client_public_key,
428 client_proof,
429 crc_hash,
430 telemetry_keys,
431 security_flag,
432 })
433 }
434
435}
436
437impl Message for CMD_AUTH_LOGON_PROOF_Client {
438 const OPCODE: u8 = 0x01;
439
440 #[cfg(feature = "sync")]
441 fn read<R: std::io::Read, I: crate::private::Sealed>(r: R) -> Result<Self, crate::errors::ParseError> {
442 Self::read_inner(r).map_err(|kind| crate::errors::ParseError::new(1, "CMD_AUTH_LOGON_PROOF_Client", kind))
443 }
444
445 #[cfg(feature = "sync")]
446 fn write<W: std::io::Write>(&self, mut w: W) -> Result<(), std::io::Error> {
447 let mut v = Vec::with_capacity(self.size() + 1);
448 self.write_into_vec(&mut v)?;
449 w.write_all(&v)
450 }
451
452 #[cfg(feature = "tokio")]
453 fn tokio_read<'async_trait, R, I: crate::private::Sealed>(
454 r: R,
455 ) -> core::pin::Pin<Box<
456 dyn core::future::Future<Output = Result<Self, crate::errors::ParseError>>
457 + Send + 'async_trait,
458 >> where
459 R: 'async_trait + tokio::io::AsyncReadExt + Unpin + Send,
460 Self: 'async_trait,
461 {
462 Box::pin(async move {Self::tokio_read_inner(r).await.map_err(|kind| crate::errors::ParseError::new(1, "CMD_AUTH_LOGON_PROOF_Client", kind))})
463 }
464
465 #[cfg(feature = "tokio")]
466 fn tokio_write<'life0, 'async_trait, W>(
467 &'life0 self,
468 mut w: W,
469 ) -> core::pin::Pin<Box<
470 dyn core::future::Future<Output = Result<(), std::io::Error>>
471 + Send + 'async_trait
472 >> where
473 W: 'async_trait + tokio::io::AsyncWriteExt + Unpin + Send,
474 'life0: 'async_trait,
475 Self: 'async_trait,
476 {
477 Box::pin(async move {
478 let mut v = Vec::with_capacity(self.size() + 1);
479 self.write_into_vec(&mut v)?;
480 w.write_all(&v).await
481 })
482 }
483
484 #[cfg(feature = "async-std")]
485 fn astd_read<'async_trait, R, I: crate::private::Sealed>(
486 r: R,
487 ) -> core::pin::Pin<Box<
488 dyn core::future::Future<Output = Result<Self, crate::errors::ParseError>>
489 + Send + 'async_trait,
490 >> where
491 R: 'async_trait + async_std::io::ReadExt + Unpin + Send,
492 Self: 'async_trait,
493 {
494 Box::pin(async move {Self::astd_read_inner(r).await.map_err(|kind| crate::errors::ParseError::new(1, "CMD_AUTH_LOGON_PROOF_Client", kind))})
495 }
496
497 #[cfg(feature = "async-std")]
498 fn astd_write<'life0, 'async_trait, W>(
499 &'life0 self,
500 mut w: W,
501 ) -> core::pin::Pin<Box<
502 dyn core::future::Future<Output = Result<(), std::io::Error>>
503 + Send + 'async_trait
504 >> where
505 W: 'async_trait + async_std::io::WriteExt + Unpin + Send,
506 'life0: 'async_trait,
507 Self: 'async_trait,
508 {
509 Box::pin(async move {
510 let mut v = Vec::with_capacity(self.size() + 1);
511 self.write_into_vec(&mut v)?;
512 w.write_all(&v).await
513 })
514 }
515
516}
517
518impl ClientMessage for CMD_AUTH_LOGON_PROOF_Client {}
519impl CMD_AUTH_LOGON_PROOF_Client {
520 pub(crate) fn size(&self) -> usize {
521 32 + 20 + 20 + 1 + self.telemetry_keys.len() * 30 + self.security_flag.size() }
528}
529
530#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
531pub struct CMD_AUTH_LOGON_PROOF_Client_SecurityFlag {
532 inner: u8,
533 pin: Option<CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin>,
534 matrix_card: Option<CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard>,
535 authenticator: Option<CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator>,
536}
537
538impl CMD_AUTH_LOGON_PROOF_Client_SecurityFlag {
539 pub const fn new(inner: u8, pin: Option<CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin>,matrix_card: Option<CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard>,authenticator: Option<CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator>,) -> Self {
540 Self {
541 inner,
542 pin,
543 matrix_card,
544 authenticator,
545 }
546 }
547
548 pub const fn empty() -> Self {
549 Self {
550 inner: 0,
551 pin: None,
552 matrix_card: None,
553 authenticator: None,
554 }
555 }
556
557 pub const fn is_empty(&self) -> bool {
558 self.inner == 0
559 && self.pin.is_none()
560 && self.matrix_card.is_none()
561 && self.authenticator.is_none()
562 }
563
564 pub const fn new_pin(pin: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin) -> Self {
565 Self {
566 inner: SecurityFlag::PIN,
567 pin: Some(pin),
568 matrix_card: None,
569 authenticator: None,
570 }
571 }
572
573 #[allow(clippy::missing_const_for_fn)] pub fn set_pin(mut self, pin: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin) -> Self {
575 self.inner |= SecurityFlag::PIN;
576 self.pin = Some(pin);
577 self
578 }
579
580 pub const fn get_pin(&self) -> Option<&CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin> {
581 self.pin.as_ref()
582 }
583
584 #[allow(clippy::missing_const_for_fn)] pub fn clear_pin(mut self) -> Self {
586 self.inner &= SecurityFlag::PIN.reverse_bits();
587 self.pin = None;
588 self
589 }
590
591 pub const fn new_matrix_card(matrix_card: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard) -> Self {
592 Self {
593 inner: SecurityFlag::MATRIX_CARD,
594 pin: None,
595 matrix_card: Some(matrix_card),
596 authenticator: None,
597 }
598 }
599
600 #[allow(clippy::missing_const_for_fn)] pub fn set_matrix_card(mut self, matrix_card: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard) -> Self {
602 self.inner |= SecurityFlag::MATRIX_CARD;
603 self.matrix_card = Some(matrix_card);
604 self
605 }
606
607 pub const fn get_matrix_card(&self) -> Option<&CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard> {
608 self.matrix_card.as_ref()
609 }
610
611 #[allow(clippy::missing_const_for_fn)] pub fn clear_matrix_card(mut self) -> Self {
613 self.inner &= SecurityFlag::MATRIX_CARD.reverse_bits();
614 self.matrix_card = None;
615 self
616 }
617
618 pub const fn new_authenticator(authenticator: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator) -> Self {
619 Self {
620 inner: SecurityFlag::AUTHENTICATOR,
621 pin: None,
622 matrix_card: None,
623 authenticator: Some(authenticator),
624 }
625 }
626
627 #[allow(clippy::missing_const_for_fn)] pub fn set_authenticator(mut self, authenticator: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator) -> Self {
629 self.inner |= SecurityFlag::AUTHENTICATOR;
630 self.authenticator = Some(authenticator);
631 self
632 }
633
634 pub const fn get_authenticator(&self) -> Option<&CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator> {
635 self.authenticator.as_ref()
636 }
637
638 #[allow(clippy::missing_const_for_fn)] pub fn clear_authenticator(mut self) -> Self {
640 self.inner &= SecurityFlag::AUTHENTICATOR.reverse_bits();
641 self.authenticator = None;
642 self
643 }
644
645 pub(crate) const fn as_int(&self) -> u8 {
646 self.inner
647 }
648
649}
650impl CMD_AUTH_LOGON_PROOF_Client_SecurityFlag {
651 pub(crate) fn size(&self) -> usize {
652 1 + {
654 if let Some(s) = &self.pin {
655 36
656 } else {
657 0
658 }
659 }
660 + {
661 if let Some(s) = &self.matrix_card {
662 20
663 } else {
664 0
665 }
666 }
667 + {
668 if let Some(s) = &self.authenticator {
669 s.size()
670 } else {
671 0
672 }
673 }
674 }
675}
676
677#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
678pub struct CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin {
679 pub pin_hash: [u8; 20],
680 pub pin_salt: [u8; 16],
681}
682
683#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
684pub struct CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_MatrixCard {
685 pub matrix_card_proof: [u8; 20],
686}
687
688#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
689pub struct CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator {
690 pub authenticator: String,
691}
692
693impl CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Authenticator {
694 pub(crate) fn size(&self) -> usize {
695 self.authenticator.len() + 1 }
697}
698
699#[cfg(test)]
700mod test {
701 #![allow(clippy::missing_const_for_fn)]
702 use super::CMD_AUTH_LOGON_PROOF_Client;
703 use crate::all::*;
704 use super::*;
705 use super::super::*;
706 use crate::logon::version_8::opcodes::ClientOpcodeMessage;
707
708 const HEADER_SIZE: usize = 1;
709 const RAW0: [u8; 135] = [ 0x01, 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
710 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1, 0xF7,
711 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D, 0xD7, 0x08,
712 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8, 0xF2, 0xDE, 0x5C,
713 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, 0x4E, 0xF5, 0x2D, 0xE1,
714 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC, 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A,
715 0x58, 0xBB, 0x00, 0xD0, 0x02, 0xFF, 0x00, 0xEF, 0xBE, 0xAD, 0xDE, 0x01,
716 0x02, 0x03, 0x04, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
717 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0xFE,
718 0x00, 0xEE, 0xBE, 0xAD, 0xDE, 0x00, 0x01, 0x02, 0x03, 0x01, 0x02, 0x03,
719 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
720 0x10, 0x11, 0x12, 0x13, 0x14, 0x00, ];
721
722 pub(crate) fn expected0() -> CMD_AUTH_LOGON_PROOF_Client {
723 CMD_AUTH_LOGON_PROOF_Client {
724 client_public_key: [ 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
725 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1,
726 0xF7, 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D,
727 0xD7, 0x08, ],
728 client_proof: [ 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8,
729 0xF2, 0xDE, 0x5C, 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, ],
730 crc_hash: [ 0x4E, 0xF5, 0x2D, 0xE1, 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC,
731 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A, 0x58, 0xBB, 0x00, 0xD0, ],
732 telemetry_keys: vec![
733 TelemetryKey {
734 unknown1: 0xFF,
735 unknown2: 0xDEADBEEF,
736 unknown3: [ 0x01, 0x02, 0x03, 0x04, ],
737 cd_key_proof: [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
738 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11,
739 0x12, 0x13, ],
740 },
741 TelemetryKey {
742 unknown1: 0xFE,
743 unknown2: 0xDEADBEEE,
744 unknown3: [ 0x00, 0x01, 0x02, 0x03, ],
745 cd_key_proof: [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
746 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
747 0x13, 0x14, ],
748 },
749 ],
750 security_flag: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag::empty()
751 ,
752 }
753
754 }
755
756 #[cfg(feature = "sync")]
758 #[cfg_attr(feature = "sync", test)]
759 fn cmd_auth_logon_proof_client0() {
760 let expected = expected0();
761 let t = ClientOpcodeMessage::read(&mut std::io::Cursor::new(&RAW0)).unwrap();
762 let t = match t {
763 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
764 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
765 };
766
767 assert_eq!(&t, &expected);
768 assert_eq!(t.size() + HEADER_SIZE, RAW0.len());
769
770 let mut dest = Vec::with_capacity(RAW0.len());
771 expected.write(&mut std::io::Cursor::new(&mut dest)).unwrap();
772
773 assert_eq!(dest, RAW0);
774 }
775
776 #[cfg(feature = "tokio")]
778 #[cfg_attr(feature = "tokio", tokio::test)]
779 async fn tokio_cmd_auth_logon_proof_client0() {
780 let expected = expected0();
781 let t = ClientOpcodeMessage::tokio_read(&mut std::io::Cursor::new(&RAW0)).await.unwrap();
782 let t = match t {
783 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
784 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
785 };
786
787 assert_eq!(&t, &expected);
788 assert_eq!(t.size() + HEADER_SIZE, RAW0.len());
789
790 let mut dest = Vec::with_capacity(RAW0.len());
791 expected.tokio_write(&mut std::io::Cursor::new(&mut dest)).await.unwrap();
792
793 assert_eq!(dest, RAW0);
794 }
795
796 #[cfg(feature = "async-std")]
798 #[cfg_attr(feature = "async-std", async_std::test)]
799 async fn astd_cmd_auth_logon_proof_client0() {
800 let expected = expected0();
801 let t = ClientOpcodeMessage::astd_read(&mut async_std::io::Cursor::new(&RAW0)).await.unwrap();
802 let t = match t {
803 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
804 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
805 };
806
807 assert_eq!(&t, &expected);
808 assert_eq!(t.size() + HEADER_SIZE, RAW0.len());
809
810 let mut dest = Vec::with_capacity(RAW0.len());
811 expected.astd_write(&mut async_std::io::Cursor::new(&mut dest)).await.unwrap();
812
813 assert_eq!(dest, RAW0);
814 }
815
816 const RAW1: [u8; 105] = [ 0x01, 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
817 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1, 0xF7,
818 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D, 0xD7, 0x08,
819 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8, 0xF2, 0xDE, 0x5C,
820 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, 0x4E, 0xF5, 0x2D, 0xE1,
821 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC, 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A,
822 0x58, 0xBB, 0x00, 0xD0, 0x01, 0xFF, 0x00, 0xEF, 0xBE, 0xAD, 0xDE, 0x01,
823 0x02, 0x03, 0x04, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
824 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x00, ];
825
826 pub(crate) fn expected1() -> CMD_AUTH_LOGON_PROOF_Client {
827 CMD_AUTH_LOGON_PROOF_Client {
828 client_public_key: [ 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
829 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1,
830 0xF7, 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D,
831 0xD7, 0x08, ],
832 client_proof: [ 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8,
833 0xF2, 0xDE, 0x5C, 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, ],
834 crc_hash: [ 0x4E, 0xF5, 0x2D, 0xE1, 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC,
835 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A, 0x58, 0xBB, 0x00, 0xD0, ],
836 telemetry_keys: vec![
837 TelemetryKey {
838 unknown1: 0xFF,
839 unknown2: 0xDEADBEEF,
840 unknown3: [ 0x01, 0x02, 0x03, 0x04, ],
841 cd_key_proof: [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
842 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11,
843 0x12, 0x13, ],
844 },
845 ],
846 security_flag: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag::empty()
847 ,
848 }
849
850 }
851
852 #[cfg(feature = "sync")]
854 #[cfg_attr(feature = "sync", test)]
855 fn cmd_auth_logon_proof_client1() {
856 let expected = expected1();
857 let t = ClientOpcodeMessage::read(&mut std::io::Cursor::new(&RAW1)).unwrap();
858 let t = match t {
859 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
860 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
861 };
862
863 assert_eq!(&t, &expected);
864 assert_eq!(t.size() + HEADER_SIZE, RAW1.len());
865
866 let mut dest = Vec::with_capacity(RAW1.len());
867 expected.write(&mut std::io::Cursor::new(&mut dest)).unwrap();
868
869 assert_eq!(dest, RAW1);
870 }
871
872 #[cfg(feature = "tokio")]
874 #[cfg_attr(feature = "tokio", tokio::test)]
875 async fn tokio_cmd_auth_logon_proof_client1() {
876 let expected = expected1();
877 let t = ClientOpcodeMessage::tokio_read(&mut std::io::Cursor::new(&RAW1)).await.unwrap();
878 let t = match t {
879 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
880 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
881 };
882
883 assert_eq!(&t, &expected);
884 assert_eq!(t.size() + HEADER_SIZE, RAW1.len());
885
886 let mut dest = Vec::with_capacity(RAW1.len());
887 expected.tokio_write(&mut std::io::Cursor::new(&mut dest)).await.unwrap();
888
889 assert_eq!(dest, RAW1);
890 }
891
892 #[cfg(feature = "async-std")]
894 #[cfg_attr(feature = "async-std", async_std::test)]
895 async fn astd_cmd_auth_logon_proof_client1() {
896 let expected = expected1();
897 let t = ClientOpcodeMessage::astd_read(&mut async_std::io::Cursor::new(&RAW1)).await.unwrap();
898 let t = match t {
899 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
900 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
901 };
902
903 assert_eq!(&t, &expected);
904 assert_eq!(t.size() + HEADER_SIZE, RAW1.len());
905
906 let mut dest = Vec::with_capacity(RAW1.len());
907 expected.astd_write(&mut async_std::io::Cursor::new(&mut dest)).await.unwrap();
908
909 assert_eq!(dest, RAW1);
910 }
911
912 const RAW2: [u8; 75] = [ 0x01, 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
913 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1, 0xF7,
914 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D, 0xD7, 0x08,
915 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8, 0xF2, 0xDE, 0x5C,
916 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, 0x4E, 0xF5, 0x2D, 0xE1,
917 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC, 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A,
918 0x58, 0xBB, 0x00, 0xD0, 0x00, 0x00, ];
919
920 pub(crate) fn expected2() -> CMD_AUTH_LOGON_PROOF_Client {
921 CMD_AUTH_LOGON_PROOF_Client {
922 client_public_key: [ 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
923 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1,
924 0xF7, 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D,
925 0xD7, 0x08, ],
926 client_proof: [ 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8,
927 0xF2, 0xDE, 0x5C, 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, ],
928 crc_hash: [ 0x4E, 0xF5, 0x2D, 0xE1, 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC,
929 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A, 0x58, 0xBB, 0x00, 0xD0, ],
930 telemetry_keys: vec![ ],
931 security_flag: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag::empty()
932 ,
933 }
934
935 }
936
937 #[cfg(feature = "sync")]
939 #[cfg_attr(feature = "sync", test)]
940 fn cmd_auth_logon_proof_client2() {
941 let expected = expected2();
942 let t = ClientOpcodeMessage::read(&mut std::io::Cursor::new(&RAW2)).unwrap();
943 let t = match t {
944 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
945 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
946 };
947
948 assert_eq!(&t, &expected);
949 assert_eq!(t.size() + HEADER_SIZE, RAW2.len());
950
951 let mut dest = Vec::with_capacity(RAW2.len());
952 expected.write(&mut std::io::Cursor::new(&mut dest)).unwrap();
953
954 assert_eq!(dest, RAW2);
955 }
956
957 #[cfg(feature = "tokio")]
959 #[cfg_attr(feature = "tokio", tokio::test)]
960 async fn tokio_cmd_auth_logon_proof_client2() {
961 let expected = expected2();
962 let t = ClientOpcodeMessage::tokio_read(&mut std::io::Cursor::new(&RAW2)).await.unwrap();
963 let t = match t {
964 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
965 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
966 };
967
968 assert_eq!(&t, &expected);
969 assert_eq!(t.size() + HEADER_SIZE, RAW2.len());
970
971 let mut dest = Vec::with_capacity(RAW2.len());
972 expected.tokio_write(&mut std::io::Cursor::new(&mut dest)).await.unwrap();
973
974 assert_eq!(dest, RAW2);
975 }
976
977 #[cfg(feature = "async-std")]
979 #[cfg_attr(feature = "async-std", async_std::test)]
980 async fn astd_cmd_auth_logon_proof_client2() {
981 let expected = expected2();
982 let t = ClientOpcodeMessage::astd_read(&mut async_std::io::Cursor::new(&RAW2)).await.unwrap();
983 let t = match t {
984 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
985 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
986 };
987
988 assert_eq!(&t, &expected);
989 assert_eq!(t.size() + HEADER_SIZE, RAW2.len());
990
991 let mut dest = Vec::with_capacity(RAW2.len());
992 expected.astd_write(&mut async_std::io::Cursor::new(&mut dest)).await.unwrap();
993
994 assert_eq!(dest, RAW2);
995 }
996
997 const RAW3: [u8; 111] = [ 0x01, 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
998 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1, 0xF7,
999 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D, 0xD7, 0x08,
1000 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8, 0xF2, 0xDE, 0x5C,
1001 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, 0x4E, 0xF5, 0x2D, 0xE1,
1002 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC, 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A,
1003 0x58, 0xBB, 0x00, 0xD0, 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
1004 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0x01,
1005 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
1006 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, ];
1007
1008 pub(crate) fn expected3() -> CMD_AUTH_LOGON_PROOF_Client {
1009 CMD_AUTH_LOGON_PROOF_Client {
1010 client_public_key: [ 0xF1, 0x3E, 0xE5, 0xD1, 0x83, 0xC4, 0xC8, 0xA9,
1011 0x50, 0x0E, 0x3F, 0x5A, 0x5D, 0x8A, 0xEE, 0x4E, 0x2E, 0x45, 0xE1,
1012 0xF7, 0xCC, 0x8F, 0x1C, 0xF5, 0xEE, 0x8E, 0x11, 0xCE, 0xD3, 0x1D,
1013 0xD7, 0x08, ],
1014 client_proof: [ 0x6B, 0x1E, 0x48, 0x1B, 0x4D, 0x04, 0xA1, 0x18, 0xD8,
1015 0xF2, 0xDE, 0x5C, 0x59, 0xD5, 0x5C, 0x81, 0x2E, 0x65, 0xEC, 0x3E, ],
1016 crc_hash: [ 0x4E, 0xF5, 0x2D, 0xE1, 0x80, 0x5E, 0x1A, 0x67, 0x15, 0xEC,
1017 0xC8, 0x41, 0xEE, 0xB8, 0x90, 0x8A, 0x58, 0xBB, 0x00, 0xD0, ],
1018 telemetry_keys: vec![ ],
1019 security_flag: CMD_AUTH_LOGON_PROOF_Client_SecurityFlag::empty()
1020 .set_pin(CMD_AUTH_LOGON_PROOF_Client_SecurityFlag_Pin {
1021 pin_hash: [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1022 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12,
1023 0x13, ],
1024 pin_salt: [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
1025 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, ],
1026 })
1027 ,
1028 }
1029
1030 }
1031
1032 #[cfg(feature = "sync")]
1034 #[cfg_attr(feature = "sync", test)]
1035 fn cmd_auth_logon_proof_client3() {
1036 let expected = expected3();
1037 let t = ClientOpcodeMessage::read(&mut std::io::Cursor::new(&RAW3)).unwrap();
1038 let t = match t {
1039 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
1040 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
1041 };
1042
1043 assert_eq!(&t, &expected);
1044 assert_eq!(t.size() + HEADER_SIZE, RAW3.len());
1045
1046 let mut dest = Vec::with_capacity(RAW3.len());
1047 expected.write(&mut std::io::Cursor::new(&mut dest)).unwrap();
1048
1049 assert_eq!(dest, RAW3);
1050 }
1051
1052 #[cfg(feature = "tokio")]
1054 #[cfg_attr(feature = "tokio", tokio::test)]
1055 async fn tokio_cmd_auth_logon_proof_client3() {
1056 let expected = expected3();
1057 let t = ClientOpcodeMessage::tokio_read(&mut std::io::Cursor::new(&RAW3)).await.unwrap();
1058 let t = match t {
1059 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
1060 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
1061 };
1062
1063 assert_eq!(&t, &expected);
1064 assert_eq!(t.size() + HEADER_SIZE, RAW3.len());
1065
1066 let mut dest = Vec::with_capacity(RAW3.len());
1067 expected.tokio_write(&mut std::io::Cursor::new(&mut dest)).await.unwrap();
1068
1069 assert_eq!(dest, RAW3);
1070 }
1071
1072 #[cfg(feature = "async-std")]
1074 #[cfg_attr(feature = "async-std", async_std::test)]
1075 async fn astd_cmd_auth_logon_proof_client3() {
1076 let expected = expected3();
1077 let t = ClientOpcodeMessage::astd_read(&mut async_std::io::Cursor::new(&RAW3)).await.unwrap();
1078 let t = match t {
1079 ClientOpcodeMessage::CMD_AUTH_LOGON_PROOF(t) => t,
1080 opcode => panic!("incorrect opcode. Expected CMD_AUTH_LOGON_PROOF, got {opcode:#?}"),
1081 };
1082
1083 assert_eq!(&t, &expected);
1084 assert_eq!(t.size() + HEADER_SIZE, RAW3.len());
1085
1086 let mut dest = Vec::with_capacity(RAW3.len());
1087 expected.astd_write(&mut async_std::io::Cursor::new(&mut dest)).await.unwrap();
1088
1089 assert_eq!(dest, RAW3);
1090 }
1091
1092}
1093