diff --git a/Cargo.lock b/Cargo.lock index d52c2cf372..293e169af0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1331,6 +1331,7 @@ version = "0.1.0" dependencies = [ "base64 0.22.1", "clap", + "openmls", "proteus-wasm", ] diff --git a/decode/Cargo.toml b/decode/Cargo.toml index 341cc489eb..60c6e5c201 100644 --- a/decode/Cargo.toml +++ b/decode/Cargo.toml @@ -8,3 +8,4 @@ license = "GPL-3.0-only" clap = { version = "4.5.26", features = ["derive"] } proteus-wasm = { workspace = true, features = ["serde"]} base64 = { workspace = true } +openmls = { workspace = true } diff --git a/decode/README.md b/decode/README.md index c9e4afcb03..d71d3d7fac 100644 --- a/decode/README.md +++ b/decode/README.md @@ -25,3 +25,49 @@ ProteusPreKeyBundle { signature: None, } ``` + +### Decode MLS message + +``` +decode mls-message AAEAATQAAQAA0T+Dx7aERkqm8jl1oWIAQgpjb25mZXJlbmNlAAAAAHN0YWdpbmcuemluZnJhLmlvAAAAAAAAAEMCAAAAAAACAAMAAAAHQEgwRgIhAOrk4aL0X6mJwCJWyNzKHIr5qXt05gx5FyP4rmcgviyYAiEAmUwSh7zTqTJAifMn/UnAVNjZKR19DukHS6iVkIP64Oo= +``` +Output: +``` +MlsMessageIn { + version: Mls10, + body: PublicMessage( + PublicMessageIn { + content: FramedContentIn { + group_id: GroupId { + value: VLBytes { 0x00010000d13f83c7b684464aa6f23975a16200420a636f6e666572656e63650000000073746167696e672e7a696e6672612e696f }, + }, + epoch: GroupEpoch( + 67, + ), + sender: External( + SenderExtensionIndex( + 0, + ), + ), + authenticated_data: VLBytes { b"" }, + body: Proposal( + Remove( + RemoveProposal { + removed: LeafNodeIndex( + 7, + ), + }, + ), + ), + }, + auth: FramedContentAuthData { + signature: Signature { + value: VLBytes { 0x3046022100eae4e1a2f45fa989c02256c8dcca1c8af9a97b74e60c791723f8ae6720be2c98022100994c1287bcd3a9324089f327fd49c054d8d9291d7d0ee9074ba8959083fae0ea }, + }, + confirmation_tag: None, + }, + membership_tag: None, + }, + ), +} +``` diff --git a/decode/src/main.rs b/decode/src/main.rs index b3c9272d29..da6d3778b9 100644 --- a/decode/src/main.rs +++ b/decode/src/main.rs @@ -1,5 +1,6 @@ use base64::Engine; use clap::{Parser, Subcommand}; +use openmls::prelude::{MlsMessageIn, TlsDeserializeTrait}; use proteus_wasm::internal::message::SessionTag; use proteus_wasm::internal::util::fmt_hex; use proteus_wasm::keys::{PreKeyBundle, Signature}; @@ -121,6 +122,8 @@ enum Command { /// Base64 encoded proteus message message: String, }, + /// Decode a MLS message + MlsMessage { message: String }, } fn main() -> Result<(), Box> { @@ -138,5 +141,11 @@ fn main() -> Result<(), Box> { println!("{:#?}", ProteusEnvelope::from(message)); Ok(()) } + Command::MlsMessage { message } => { + let bytes = base64::prelude::BASE64_STANDARD.decode(message)?; + let message = MlsMessageIn::tls_deserialize(&mut bytes.as_slice())?; + println!("{message:#?}"); + Ok(()) + } } }