-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eaf7da8
Showing
15 changed files
with
828 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
name: Build and test Rust code | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
rust-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install cargo-machete | ||
uses: taiki-e/install-action@cargo-machete | ||
- name: Run cargo-machete | ||
run: cargo machete | ||
|
||
- name: Set up Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: stable | ||
components: clippy, rustfmt | ||
|
||
- name: Rustfmt | ||
run: cargo fmt -- --check | ||
|
||
- name: Clippy | ||
run: cargo clippy --locked --all-targets -- -D warnings | ||
|
||
- name: Build | ||
run: cargo build --verbose | ||
|
||
- name: Tests | ||
run: cargo test --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
name: REUSE Compliance Check | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: REUSE Compliance Check | ||
uses: fsfe/reuse-action@v5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
*/target | ||
*/Cargo.lock | ||
*/test | ||
target | ||
.DS_Store | ||
.vscode | ||
.ruby-version | ||
.env |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
[package] | ||
name = "mimi-protocol" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde_bytes = "0.11.15" |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
SPDX-License-Identifier: CC-BY-4.0 | ||
--> | ||
|
||
# MIMI Message Content | ||
|
||
This repository contains the code for a Rust implementation of the [MIMI protocol draft](https://datatracker.ietf.org/doc/draft-ietf-mimi-protocol/). | ||
|
||
## Licensing | ||
|
||
All crates in this repository are licensed under the [AGPL 3.0](https://www.gnu.org/licenses/agpl-3.0.html). This README file is licensed under [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
version = 1 | ||
|
||
[[annotations]] | ||
path = ["Cargo.lock"] | ||
SPDX-FileCopyrightText = "2024 Phoenix R&D GmbH <[email protected]>" | ||
SPDX-License-Identifier = "AGPL-3.0-or-later" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
use serde_bytes::ByteBuf; | ||
|
||
use super::{CipherSuite, GroupInfo, RatchetTreeOption}; | ||
|
||
// "to-be-signed" | ||
#[repr(u8)] | ||
pub enum GroupInfoRequestTBS { | ||
Mls10 { | ||
cipher_suite: CipherSuite, | ||
requesting_signature_key: SignaturePublicKey, | ||
requesting_credential: Credential, | ||
group_info_public_key: HPKEPublicKey, | ||
joining_code: Option<String>, // TODO: Or ByteBuf? | ||
} = 1, | ||
} | ||
|
||
// TODO: The signed variant's joining code is not optional? | ||
|
||
// "to-be-encrypted" | ||
pub struct GroupInfoRatchetTreeTBE { | ||
group_info: GroupInfo, | ||
ratchet_tree_option: RatchetTreeOption, | ||
} | ||
|
||
// "to-be-signed" | ||
#[repr(u8)] | ||
pub enum GroupInfoResponseTBS { | ||
Mls10 { | ||
status: GroupInfoCode, | ||
cipher_suite: CipherSuite, | ||
room_id: ByteBuf, | ||
hub_sender: ExternalSender, | ||
encrypted_groupinfo_and_tree: ByteBuf, | ||
} = 1, | ||
} | ||
|
||
// TODO: How to get signed/encrypted structs? Macros? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
use super::{Capabilities, CipherSuite, IdentifierUri, KeyPackage, RequiredCapabilities}; | ||
|
||
#[repr(u8)] | ||
pub enum KeyMaterialRequest { | ||
Mls10 { | ||
requesting_user: IdentifierUri, | ||
target_user: IdentifierUri, | ||
room_id: IdentifierUri, | ||
acceptable_ciphersuites: Vec<CipherSuite>, | ||
required_capabilities: RequiredCapabilities, | ||
} = 1, | ||
} | ||
|
||
#[repr(u8)] | ||
pub enum KeyMaterialUserCode { | ||
Success = 0, | ||
PartialSuccess = 1, | ||
IncompatibleProtocol = 2, | ||
NoCompatibleMaterial = 3, | ||
UserUnknown = 4, | ||
NoConsent = 5, | ||
NoConsentForThisRoom = 6, | ||
UserDeleted = 7, | ||
Custom(u8), | ||
} | ||
|
||
#[repr(u8)] | ||
pub enum Mls10ClientKeyMaterial { | ||
Success { | ||
// TODO: Ask if field order of client_status and client_uri can be swapped | ||
client_uri: IdentifierUri, | ||
key_package: KeyPackage, | ||
} = 0, | ||
KeyMaterialExhausted { | ||
client_uri: IdentifierUri, | ||
} = 1, | ||
NothingCompatible { | ||
client_uri: IdentifierUri, | ||
client_capabilities: Option<Capabilities>, | ||
} = 2, | ||
} | ||
|
||
#[repr(u8)] | ||
pub enum KeyMaterialResponse { | ||
Mls10 { | ||
user_status: KeyMaterialUserCode, | ||
user_uri: IdentifierUri, | ||
clients: Vec<Mls10ClientKeyMaterial>, | ||
} = 1, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
mod group_info; | ||
mod key_material; | ||
mod notify; | ||
mod submit_message; | ||
mod update; | ||
|
||
// TODO: Import this from mls crate | ||
#[repr(u16)] | ||
pub enum CipherSuite { | ||
Reserved = 0, | ||
MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 = 1, | ||
Custom(u16), | ||
} | ||
// TODO: Import this from mls crate | ||
pub type RequiredCapabilities = (); | ||
// TODO: Import this from mls crate | ||
pub type Capabilities = (); | ||
// TODO: Import this from mls crate | ||
pub type KeyPackage = (); | ||
// TODO: Import this from mls crate | ||
pub type MlsMessage = (); | ||
// TODO: Import this from mls crate | ||
pub type Welcome = (); | ||
// TODO: Import this from mls crate | ||
pub type GroupInfo = (); | ||
// TODO: Import this from mls crate | ||
pub type PartialGroupInfo = (); | ||
// TODO: Import this from mls crate | ||
pub type RatchetTreeOption = (); | ||
// TODO: Import this from mls crate | ||
pub type ProposalRef = (); | ||
|
||
#[repr(u8)] | ||
pub enum Protocol { | ||
Reserved = 0, | ||
Mls10 = 1, | ||
Custom(u8), | ||
} | ||
|
||
pub struct IdentifierUri(String); // TODO: Or ByteBuf? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
use super::{MlsMessage, RatchetTreeOption}; | ||
|
||
struct Frank { | ||
franking_tag: [u8; 32], // TODO: The RFC starts mixing camelCase and snake_case | ||
server_frank: [u8; 32], | ||
server_frank_context_hash: [u8; 32], | ||
} | ||
|
||
enum Mls10FanoutMessage { | ||
Application { | ||
timestamp: u64, | ||
message: MlsMessage, // Must have wire_format = Application | ||
frank: Option<Frank>, // In RFC, optional doesn't have the <> | ||
}, | ||
Welcome { | ||
timestamp: u64, | ||
message: MlsMessage, // Must have wire_format = Welcome | ||
ratchet_tree_option: RatchetTreeOption, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-FileCopyrightText: 2024 Phoenix R&D GmbH <[email protected]> | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
use super::{IdentifierUri, MlsMessage}; | ||
|
||
#[repr(u8)] | ||
pub enum SubmitMessageRequest { | ||
Mls10 { | ||
app_message: MlsMessage, | ||
sending_uri: IdentifierUri, | ||
} = 1, | ||
} | ||
|
||
#[repr(u8)] | ||
pub enum SubmitResponseStatus { | ||
Success { | ||
// TODO: RFC also calls this "Accepted" | ||
accepted_timestamp: u64, | ||
server_frank: Option<[u8; 32]>, | ||
} = 0, | ||
NotAllowed {} = 1, | ||
EpochTooOld { | ||
current_epoch: u64, | ||
} = 2, | ||
} | ||
|
||
#[repr(u8)] | ||
pub enum SubmitMessageResponse { | ||
Mls10 { status: SubmitResponseStatus } = 1, | ||
} |
Oops, something went wrong.