mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-08-12 01:53:18 +00:00
Merge branch 'main' into dependabot/cargo/quinn-proto-0.11.16
This commit is contained in:
commit
1ad85814fa
@ -157,6 +157,19 @@ impl GroupV1Convo {
|
|||||||
|
|
||||||
let key_package_in = KeyPackageIn::tls_deserialize(&mut keypkg_bytes.as_slice())?;
|
let key_package_in = KeyPackageIn::tls_deserialize(&mut keypkg_bytes.as_slice())?;
|
||||||
let keypkg = key_package_in.validate(provider.crypto(), ProtocolVersion::Mls10)?; //TODO: P3 - Hardcoded Protocol Version
|
let keypkg = key_package_in.validate(provider.crypto(), ProtocolVersion::Mls10)?; //TODO: P3 - Hardcoded Protocol Version
|
||||||
|
// SECURITY: validate() only proves the package is well-formed and self-signed
|
||||||
|
// — NOT that it belongs to the signer we asked the registry for. Bind the
|
||||||
|
// fetched leaf's signature_key to the requested id (a signer id is
|
||||||
|
// hex(Ed25519 verifying key)); reject a mismatch so a malicious/compromised
|
||||||
|
// registry cannot insert an attacker's leaf under a victim's identity
|
||||||
|
// (confidentiality break + sender-attribution spoof). Bind to the key, not the
|
||||||
|
// spoofable credential bytes.
|
||||||
|
let leaf_key = hex::encode(keypkg.leaf_node().signature_key().as_slice());
|
||||||
|
if leaf_key != signer.as_str() {
|
||||||
|
return Err(ChatError::Protocol(format!(
|
||||||
|
"keypackage for signer {signer} is bound to a different signing key ({leaf_key})"
|
||||||
|
)));
|
||||||
|
}
|
||||||
Ok(keypkg)
|
Ok(keypkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -152,8 +152,24 @@ fn fetch_key_packages<S: ExternalServices>(
|
|||||||
.retrieve(member.as_str())
|
.retrieve(member.as_str())
|
||||||
.map_err(ChatError::generic)?
|
.map_err(ChatError::generic)?
|
||||||
.ok_or_else(|| ChatError::generic("No key package"))?;
|
.ok_or_else(|| ChatError::generic("No key package"))?;
|
||||||
let member_id = KeyPackageIn::tls_deserialize(&mut key_package.as_slice())?
|
let validated = KeyPackageIn::tls_deserialize(&mut key_package.as_slice())?
|
||||||
.validate(service_ctx.mls_provider.crypto(), ProtocolVersion::Mls10)?
|
.validate(service_ctx.mls_provider.crypto(), ProtocolVersion::Mls10)?;
|
||||||
|
// SECURITY: a validated KeyPackage only proves it is well-formed and
|
||||||
|
// self-signed — NOT that it belongs to the signer we asked the registry
|
||||||
|
// for. `member_id` below is read from the package's OWN credential and was
|
||||||
|
// never checked equal to `member`, so a malicious/compromised registry (or
|
||||||
|
// a cache poisoned by an untrusted transport) can return an attacker's
|
||||||
|
// package for a victim's id, inserting the attacker's leaf under the
|
||||||
|
// victim's identity: confidentiality break + sender-attribution spoof.
|
||||||
|
// A signer id is hex(Ed25519 verifying key), so bind the leaf's
|
||||||
|
// signature_key (not the spoofable credential bytes) to the requested id.
|
||||||
|
let leaf_key = hex::encode(validated.leaf_node().signature_key().as_slice());
|
||||||
|
if leaf_key != member.as_str() {
|
||||||
|
return Err(ChatError::generic(format!(
|
||||||
|
"key package for {member} is bound to a different signing key ({leaf_key})"
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
let member_id = validated
|
||||||
.leaf_node()
|
.leaf_node()
|
||||||
.credential()
|
.credential()
|
||||||
.serialized_content()
|
.serialized_content()
|
||||||
|
|||||||
@ -20,13 +20,13 @@ fn main() {
|
|||||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
||||||
|
|
||||||
match target_os.as_str() {
|
match target_os.as_str() {
|
||||||
"macos" | "linux" => {}
|
"macos" | "linux" | "ios" => {}
|
||||||
other => panic!("unsupported OS for logos-delivery transport: {other}"),
|
other => panic!("unsupported OS for logos-delivery transport: {other}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Two linking modes, because dev builds and *distributable* builds want
|
// Two linking modes, because dev builds and *distributable* builds want
|
||||||
// opposite things out of the library's install name / soname.
|
// opposite things out of the library's install name / soname.
|
||||||
if relocatable() {
|
if relocatable() || target_os == "ios" {
|
||||||
// Distribution: link the shipped library in place and leave its
|
// Distribution: link the shipped library in place and leave its
|
||||||
// relocatable name (@rpath on macOS, $ORIGIN soname on Linux) intact,
|
// relocatable name (@rpath on macOS, $ORIGIN soname on Linux) intact,
|
||||||
// so the consumer can copy it into its own bundle and resolve it from
|
// so the consumer can copy it into its own bundle and resolve it from
|
||||||
@ -51,7 +51,16 @@ fn main() {
|
|||||||
println!("cargo:rustc-link-search=native={out_dir}");
|
println!("cargo:rustc-link-search=native={out_dir}");
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-lib=dylib=logosdelivery");
|
if target_os == "ios" {
|
||||||
|
// iOS apps cannot ship loose dylibs the way an APK can, so the delivery
|
||||||
|
// node is linked as a static archive. rln has to be named explicitly:
|
||||||
|
// with no shared library there is no rpath to resolve it transitively.
|
||||||
|
println!("cargo:rustc-link-lib=static=logosdelivery");
|
||||||
|
println!("cargo:rustc-link-lib=static=rln");
|
||||||
|
println!("cargo:rustc-link-lib=c++");
|
||||||
|
} else {
|
||||||
|
println!("cargo:rustc-link-lib=dylib=logosdelivery");
|
||||||
|
}
|
||||||
println!("cargo:lib_dir={}", lib_dir.display());
|
println!("cargo:lib_dir={}", lib_dir.display());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user