-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing safe encrypt/decrypt with context
- Loading branch information
Ellen Arteca
committed
Jan 28, 2025
1 parent
29affc7
commit 30369cc
Showing
2 changed files
with
206 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,32 @@ | ||
use crate::client::MlsError; | ||
use crate::tree_kem::hpke_encryption::HpkeEncryptable; | ||
use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize}; | ||
|
||
pub type ComponentID = u32; | ||
|
||
#[derive(Clone, Debug, PartialEq, MlsSize, MlsEncode, MlsDecode)] | ||
pub struct ComponentOperationLabel { | ||
component_id: ComponentID, | ||
context: Vec<u8>, | ||
} | ||
|
||
impl HpkeEncryptable for ComponentOperationLabel { | ||
const ENCRYPT_LABEL: &'static str = "MLS 1.0 Application"; | ||
|
||
fn from_bytes(bytes: Vec<u8>) -> Result<Self, MlsError> { | ||
Self::mls_decode(&mut bytes.as_slice()).map_err(Into::into) | ||
} | ||
|
||
fn get_bytes(&self) -> Result<Vec<u8>, MlsError> { | ||
self.mls_encode_to_vec().map_err(Into::into) | ||
} | ||
} | ||
|
||
impl ComponentOperationLabel { | ||
pub fn new(component_id: u32, context: Vec<u8>) -> Self { | ||
Self { | ||
component_id, | ||
context, | ||
} | ||
} | ||
} |
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