实现 Windows 与 Web 加密文字群聊预览
This commit is contained in:
1 parent
709e6aa6a6
commit
ea6aec3323
19 files changed
+809
-31
No files matched your search
@@ -335,11 +335,42 @@ impl Engine {
|
||||
expected_key: &[u8],
|
||||
associated_data: &[u8],
|
||||
wire: &[u8],
|
||||
) -> EngineResult<Vec<u8>> {
|
||||
self.decrypt_message(None, peer, expected_key, associated_data, wire)
|
||||
}
|
||||
|
||||
pub fn decrypt_group(
|
||||
&self,
|
||||
id: &[u8],
|
||||
peer: &str,
|
||||
expected_key: &[u8],
|
||||
associated_data: &[u8],
|
||||
wire: &[u8],
|
||||
) -> EngineResult<Vec<u8>> {
|
||||
self.decrypt_message(
|
||||
Some(&group_id_from(id)?),
|
||||
peer,
|
||||
expected_key,
|
||||
associated_data,
|
||||
wire,
|
||||
)
|
||||
}
|
||||
|
||||
fn decrypt_message(
|
||||
&self,
|
||||
expected_group: Option<&GroupId>,
|
||||
peer: &str,
|
||||
expected_key: &[u8],
|
||||
associated_data: &[u8],
|
||||
wire: &[u8],
|
||||
) -> EngineResult<Vec<u8>> {
|
||||
let protocol = MlsMessageIn::tls_deserialize_exact(wire)
|
||||
.map_err(|_| "invalid ciphertext")?
|
||||
.try_into_protocol_message()
|
||||
.map_err(|_| "invalid ciphertext")?;
|
||||
if expected_group.is_some_and(|id| id != protocol.group_id()) {
|
||||
return Err("unexpected MLS group");
|
||||
}
|
||||
let mut group = self
|
||||
.load_group(protocol.group_id())?
|
||||
.ok_or("unknown conversation")?;
|
||||
|
||||
Reference in new issue
Block a user