Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new proposal types #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openmls/src/group/core_group/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl ProposalQueue {
// Parse proposals and build adds and member list
for queued_proposal in queued_proposal_list {
match queued_proposal.proposal {
Proposal::Add(_) => {
Proposal::Add(_) | Proposal::DeviceAdd(_) => {
adds.add(queued_proposal.proposal_reference());
proposal_pool.insert(queued_proposal.proposal_reference(), queued_proposal);
}
Expand All @@ -480,7 +480,8 @@ impl ProposalQueue {
let proposal_reference = queued_proposal.proposal_reference();
proposal_pool.insert(proposal_reference, queued_proposal);
}
Proposal::Remove(ref remove_proposal) => {
Proposal::Remove(ref remove_proposal)
| Proposal::DeviceRemove(ref remove_proposal) => {
let removed = remove_proposal.removed();
members
.entry(removed)
Expand Down
10 changes: 10 additions & 0 deletions openmls/src/messages/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ pub enum ProposalType {
ExternalInit,
GroupContextExtensions,
AppAck,
DeviceAdd,
DeviceRemove,
Unknown(u16),
}

Expand Down Expand Up @@ -144,6 +146,8 @@ impl From<u16> for ProposalType {
6 => ProposalType::ExternalInit,
7 => ProposalType::GroupContextExtensions,
8 => ProposalType::AppAck,
9 => ProposalType::DeviceAdd,
10 => ProposalType::DeviceRemove,
unknown => ProposalType::Unknown(unknown),
}
}
Expand All @@ -160,6 +164,8 @@ impl From<ProposalType> for u16 {
ProposalType::ExternalInit => 6,
ProposalType::GroupContextExtensions => 7,
ProposalType::AppAck => 8,
ProposalType::DeviceAdd => 9,
ProposalType::DeviceRemove => 10,
ProposalType::Unknown(unknown) => unknown,
}
}
Expand Down Expand Up @@ -208,6 +214,8 @@ pub enum Proposal {
// was moved to `draft-ietf-mls-extensions-00`.
#[tls_codec(discriminant = 8)]
AppAck(AppAckProposal),
DeviceAdd(AddProposal),
DeviceRemove(RemoveProposal),
}

impl Proposal {
Expand All @@ -222,6 +230,8 @@ impl Proposal {
Proposal::ExternalInit(_) => ProposalType::ExternalInit,
Proposal::GroupContextExtensions(_) => ProposalType::GroupContextExtensions,
Proposal::AppAck(_) => ProposalType::AppAck,
Proposal::DeviceAdd(_) => ProposalType::DeviceAdd,
Proposal::DeviceRemove(_) => ProposalType::DeviceRemove,
}
}

Expand Down
12 changes: 12 additions & 0 deletions openmls/src/messages/proposals_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ pub enum ProposalIn {
// was moved to `draft-ietf-mls-extensions-00`.
#[tls_codec(discriminant = 8)]
AppAck(AppAckProposal),
DeviceAdd(AddProposalIn),
DeviceRemoveProposal(RemoveProposal),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this one isn't just DeviceRemove for consistency?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason... this should be DeviceRemove 🙂

}

impl ProposalIn {
Expand All @@ -84,6 +86,8 @@ impl ProposalIn {
ProposalIn::ExternalInit(_) => ProposalType::ExternalInit,
ProposalIn::GroupContextExtensions(_) => ProposalType::GroupContextExtensions,
ProposalIn::AppAck(_) => ProposalType::AppAck,
ProposalIn::DeviceAdd(_) => ProposalType::DeviceAdd,
ProposalIn::DeviceRemoveProposal(_) => ProposalType::DeviceRemove,
}
}

Expand Down Expand Up @@ -117,6 +121,10 @@ impl ProposalIn {
Proposal::GroupContextExtensions(group_context_extension)
}
ProposalIn::AppAck(app_ack) => Proposal::AppAck(app_ack),
ProposalIn::DeviceAdd(add) => {
Proposal::DeviceAdd(add.validate(crypto, protocol_version, ciphersuite)?)
}
ProposalIn::DeviceRemoveProposal(remove) => Proposal::DeviceRemove(remove),
})
}
}
Expand Down Expand Up @@ -294,6 +302,8 @@ impl From<ProposalIn> for crate::messages::proposals::Proposal {
Self::GroupContextExtensions(group_context_extension)
}
ProposalIn::AppAck(app_ack) => Self::AppAck(app_ack),
ProposalIn::DeviceAdd(add) => Self::DeviceAdd(add.into()),
ProposalIn::DeviceRemoveProposal(remove) => Self::DeviceRemove(remove),
}
}
}
Expand All @@ -311,6 +321,8 @@ impl From<crate::messages::proposals::Proposal> for ProposalIn {
Self::GroupContextExtensions(group_context_extension)
}
Proposal::AppAck(app_ack) => Self::AppAck(app_ack),
Proposal::DeviceAdd(add) => Self::DeviceAdd(add.into()),
Proposal::DeviceRemove(remove) => Self::DeviceRemoveProposal(remove),
}
}
}
Expand Down