From 95c6b12d9caa7467f2982b8327529a9832a22b0f Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 4 Apr 2022 21:09:49 +0200 Subject: [PATCH] xmpp-parsers: Run cargo fmt on legacy_omemo --- parsers/src/legacy_omemo.rs | 144 ++++++++++++++++++++++-------------- 1 file changed, 90 insertions(+), 54 deletions(-) diff --git a/parsers/src/legacy_omemo.rs b/parsers/src/legacy_omemo.rs index a7364d3..4b0eea4 100644 --- a/parsers/src/legacy_omemo.rs +++ b/parsers/src/legacy_omemo.rs @@ -4,9 +4,9 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. +use crate::message::MessagePayload; use crate::pubsub::PubSubPayload; use crate::util::helpers::Base64; -use crate::message::MessagePayload; generate_element!( /// Element of the device list @@ -136,7 +136,6 @@ generate_attribute!( bool ); - generate_element!( /// Part of the OMEMO element header Key, "key", LEGACY_OMEMO, @@ -177,7 +176,6 @@ generate_element!( ] ); - impl MessagePayload for Encrypted {} #[cfg(test)] @@ -202,42 +200,55 @@ mod tests { "#.parse().unwrap(); let bundle: Bundle = elem.try_into().unwrap(); let bundle2 = Bundle { - signed_pre_key_public: Some( - SignedPreKeyPublic { - signed_pre_key_id: Some( - 1, - ), - data: vec![ 5, 128, 27, 0, 32, 53, 229, 179, 231, 247, 154, 123, 68, 96, 182, 93, 184, 16, 202, 92, 188, 105, 18, 146, 224, 22, 137, 250, 16, 252, 97, 184, 94, ], - }, - ), - signed_pre_key_signature: Some( - SignedPreKeySignature { - data: vec![ 176, 130, 85, 52, 54, 98, 252, 216, 5, 178, 188, 184, 56, 23, 76, 249, 167, 114, 26, 219, 75, 17, 118, 212, 135, 248, 127, 229, 213, 78, 102, 247, 140, 131, 37, 104, 33, 216, 48, 5, 76, 234, 241, 104, 29, 219, 22, 19, 64, 200, 168, 55, 60, 24, 121, 180, 215, 251, 218, 116, 135, 215, 174, 140, ], - }, - ), - identity_key: Some( - IdentityKey { - data: vec![ 5, 1, 93, 218, 159, 206, 171, 222, 239, 0, 7, 75, 40, 13, 61, 14, 87, 18, 131, 76, 117, 197, 105, 246, 235, 74, 117, 141, 167, 178, 34, 16, 25, ], - }, - ), - prekeys: Some( - Prekeys { - keys: vec![ - PreKeyPublic { - pre_key_id: 1, - data: vec![ 5, 184, 199, 176, 94, 103, 118, 211, 85, 241, 58, 17, 112, 148, 216, 72, 209, 158, 62, 0, 22, 176, 81, 164, 72, 190, 142, 27, 176, 123, 45, 116, 94, ], - }, - PreKeyPublic { - pre_key_id: 2, - data: vec![ 5, 229, 135, 177, 176, 77, 199, 91, 158, 175, 88, 154, 254, 117, 191, 234, 217, 255, 58, 90, 135, 150, 95, 98, 182, 56, 212, 76, 139, 213, 223, 220, 123, ], - }, - PreKeyPublic { - pre_key_id: 3, - data: vec![ 5, 229, 107, 231, 19, 230, 52, 74, 228, 192, 173, 232, 112, 249, 175, 208, 218, 33, 203, 112, 184, 60, 164, 1, 159, 19, 46, 58, 168, 151, 162, 210, 88, ], - }, - ], - }, - ), + signed_pre_key_public: Some(SignedPreKeyPublic { + signed_pre_key_id: Some(1), + data: vec![ + 5, 128, 27, 0, 32, 53, 229, 179, 231, 247, 154, 123, 68, 96, 182, 93, 184, 16, + 202, 92, 188, 105, 18, 146, 224, 22, 137, 250, 16, 252, 97, 184, 94, + ], + }), + signed_pre_key_signature: Some(SignedPreKeySignature { + data: vec![ + 176, 130, 85, 52, 54, 98, 252, 216, 5, 178, 188, 184, 56, 23, 76, 249, 167, + 114, 26, 219, 75, 17, 118, 212, 135, 248, 127, 229, 213, 78, 102, 247, 140, + 131, 37, 104, 33, 216, 48, 5, 76, 234, 241, 104, 29, 219, 22, 19, 64, 200, 168, + 55, 60, 24, 121, 180, 215, 251, 218, 116, 135, 215, 174, 140, + ], + }), + identity_key: Some(IdentityKey { + data: vec![ + 5, 1, 93, 218, 159, 206, 171, 222, 239, 0, 7, 75, 40, 13, 61, 14, 87, 18, 131, + 76, 117, 197, 105, 246, 235, 74, 117, 141, 167, 178, 34, 16, 25, + ], + }), + prekeys: Some(Prekeys { + keys: vec![ + PreKeyPublic { + pre_key_id: 1, + data: vec![ + 5, 184, 199, 176, 94, 103, 118, 211, 85, 241, 58, 17, 112, 148, 216, + 72, 209, 158, 62, 0, 22, 176, 81, 164, 72, 190, 142, 27, 176, 123, 45, + 116, 94, + ], + }, + PreKeyPublic { + pre_key_id: 2, + data: vec![ + 5, 229, 135, 177, 176, 77, 199, 91, 158, 175, 88, 154, 254, 117, 191, + 234, 217, 255, 58, 90, 135, 150, 95, 98, 182, 56, 212, 76, 139, 213, + 223, 220, 123, + ], + }, + PreKeyPublic { + pre_key_id: 3, + data: vec![ + 5, 229, 107, 231, 19, 230, 52, 74, 228, 192, 173, 232, 112, 249, 175, + 208, 218, 33, 203, 112, 184, 60, 164, 1, 159, 19, 46, 58, 168, 151, + 162, 210, 88, + ], + }, + ], + }), }; assert_eq!(bundle, bundle2); } @@ -249,19 +260,15 @@ mod tests { - "#.parse().unwrap(); + "# + .parse() + .unwrap(); let list: DeviceList = elem.try_into().unwrap(); let list2 = DeviceList { devices: vec![ - Device { - id: 1164059891, - }, - Device { - id: 26052318, - }, - Device { - id: 564866972, - }, + Device { id: 1164059891 }, + Device { id: 26052318 }, + Device { id: 564866972 }, ], }; assert_eq!(list, list2); @@ -287,25 +294,54 @@ mod tests { Key { rid: 1236, prekey: IsPreKey::True, - data: vec![ 51, 8, 233, 244, 1, 18, 33, 5, 114, 150, 199, 11, 62, 152, 255, 30, 90, 48, 105, 56, 136, 177, 160, 99, 239, 113, 194, 84, 73, 101, 94, 149, 83, 180, 193, 189, 17, 140, 17, 123, 26, 33, 5, 1, 93, 218, 159, 206, 171, 222, 239, 0, 7, 75, 40, 13, 61, 14, 87, 18, 131, 76, 117, 197, 105, 246, 235, 74, 117, 141, 167, 178, 34, 16, 25, 34, 98, 51, 10, 33, 5, 133, 164, 56, 35, 224, 238, 66, 10, 58, 188, 34, 194, 140, 123, 184, 185, 236, 3, 102, 101, 135, 184, 25, 124, 184, 156, 53, 34, 76, 153, 198, 21, 16, 0, 24, 0, 34, 48, 168, 17, 88, 21, 78, 21, 165, 104, 137, 103, 55, 117, 121, 6, 13, 97, 65, 126, 206, 15, 87, 47, 178, 210, 195, 230, 81, 247, 205, 147, 26, 116, 189, 202, 120, 227, 68, 44, 68, 165, 5, 183, 138, 152, 216, 28, 96, 47, 222, 220, 118, 103, 110, 5, 179, 6, 40, 156, 223, 172, 141, 2, 48, 22 ], + data: vec![ + 51, 8, 233, 244, 1, 18, 33, 5, 114, 150, 199, 11, 62, 152, 255, 30, 90, + 48, 105, 56, 136, 177, 160, 99, 239, 113, 194, 84, 73, 101, 94, 149, + 83, 180, 193, 189, 17, 140, 17, 123, 26, 33, 5, 1, 93, 218, 159, 206, + 171, 222, 239, 0, 7, 75, 40, 13, 61, 14, 87, 18, 131, 76, 117, 197, + 105, 246, 235, 74, 117, 141, 167, 178, 34, 16, 25, 34, 98, 51, 10, 33, + 5, 133, 164, 56, 35, 224, 238, 66, 10, 58, 188, 34, 194, 140, 123, 184, + 185, 236, 3, 102, 101, 135, 184, 25, 124, 184, 156, 53, 34, 76, 153, + 198, 21, 16, 0, 24, 0, 34, 48, 168, 17, 88, 21, 78, 21, 165, 104, 137, + 103, 55, 117, 121, 6, 13, 97, 65, 126, 206, 15, 87, 47, 178, 210, 195, + 230, 81, 247, 205, 147, 26, 116, 189, 202, 120, 227, 68, 44, 68, 165, + 5, 183, 138, 152, 216, 28, 96, 47, 222, 220, 118, 103, 110, 5, 179, 6, + 40, 156, 223, 172, 141, 2, 48, 22, + ], }, Key { rid: 26052318, prekey: IsPreKey::False, - data: vec![ 51, 10, 33, 5, 53, 122, 118, 155, 166, 47, 83, 177, 3, 211, 29, 32, 89, 174, 216, 77, 125, 249, 194, 22, 12, 117, 152, 126, 23, 110, 110, 250, 52, 134, 104, 122, 16, 0, 24, 28, 34, 48, 53, 207, 127, 231, 215, 158, 98, 47, 41, 85, 148, 33, 48, 146, 76, 86, 66, 148, 144, 83, 255, 202, 180, 223, 27, 122, 53, 149, 250, 71, 26, 199, 130, 169, 191, 201, 78, 11, 67, 202, 212, 15, 137, 138, 211, 164, 121, 118, 87, 249, 157, 176, 206, 136, 62, 40 ], + data: vec![ + 51, 10, 33, 5, 53, 122, 118, 155, 166, 47, 83, 177, 3, 211, 29, 32, 89, + 174, 216, 77, 125, 249, 194, 22, 12, 117, 152, 126, 23, 110, 110, 250, + 52, 134, 104, 122, 16, 0, 24, 28, 34, 48, 53, 207, 127, 231, 215, 158, + 98, 47, 41, 85, 148, 33, 48, 146, 76, 86, 66, 148, 144, 83, 255, 202, + 180, 223, 27, 122, 53, 149, 250, 71, 26, 199, 130, 169, 191, 201, 78, + 11, 67, 202, 212, 15, 137, 138, 211, 164, 121, 118, 87, 249, 157, 176, + 206, 136, 62, 40, + ], }, Key { rid: 1164059891, prekey: IsPreKey::False, - data: vec![ 51, 10, 33, 5, 89, 225, 207, 218, 111, 18, 61, 108, 215, 6, 132, 30, 233, 57, 170, 148, 42, 133, 74, 233, 106, 252, 156, 23, 61, 33, 171, 242, 152, 192, 143, 40, 16, 0, 24, 9, 34, 48, 121, 209, 6, 55, 163, 34, 119, 28, 175, 104, 242, 60, 206, 138, 203, 114, 145, 180, 99, 183, 187, 121, 193, 164, 145, 222, 111, 116, 58, 203, 237, 11, 117, 181, 118, 135, 111, 72, 131, 200, 79, 235, 101, 145, 233, 22, 35, 77, 223, 194, 51, 126, 158, 111, 30, 254 ], + data: vec![ + 51, 10, 33, 5, 89, 225, 207, 218, 111, 18, 61, 108, 215, 6, 132, 30, + 233, 57, 170, 148, 42, 133, 74, 233, 106, 252, 156, 23, 61, 33, 171, + 242, 152, 192, 143, 40, 16, 0, 24, 9, 34, 48, 121, 209, 6, 55, 163, 34, + 119, 28, 175, 104, 242, 60, 206, 138, 203, 114, 145, 180, 99, 183, 187, + 121, 193, 164, 145, 222, 111, 116, 58, 203, 237, 11, 117, 181, 118, + 135, 111, 72, 131, 200, 79, 235, 101, 145, 233, 22, 35, 77, 223, 194, + 51, 126, 158, 111, 30, 254, + ], }, ], iv: IV { - data: vec![ 73, 143, 210, 8, 99, 237, 208, 41, 192, 218, 135, 65 ], + data: vec![73, 143, 210, 8, 99, 237, 208, 41, 192, 218, 135, 65], }, }, payload: Some(Payload { - data: vec![ 85, 171 ], + data: vec![85, 171], }), }; assert_eq!(encrypted, encrypted2);