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

feat: Include certificate roots and certificate policy in GroupContext - WPB-1188 #346

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

augustocdias
Copy link
Contributor


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Include certificate roots and certificate policy in GroupContext and expose to API


References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@codecov-commenter
Copy link

codecov-commenter commented Jun 29, 2023

Codecov Report

Merging #346 (dcb154d) into develop (7c2d982) will decrease coverage by 1.53%.
The diff coverage is 6.43%.

@@             Coverage Diff             @@
##           develop     #346      +/-   ##
===========================================
- Coverage    72.98%   71.45%   -1.53%     
===========================================
  Files           68       70       +2     
  Lines        11348    11608     +260     
===========================================
+ Hits          8282     8295      +13     
- Misses        3066     3313     +247     
Impacted Files Coverage Δ
crypto/src/error.rs 0.00% <ø> (ø)
crypto/src/mls/conversation/decrypt.rs 69.52% <0.00%> (-0.22%) ⬇️
crypto/src/mls/conversation/handshake.rs 69.35% <ø> (ø)
crypto/src/mls/credential/mod.rs 87.96% <ø> (ø)
crypto/src/test_utils/mod.rs 99.00% <ø> (ø)
crypto/src/test_utils/x509.rs 0.00% <0.00%> (ø)
crypto/src/mls/credential/trust_anchor.rs 2.27% <2.27%> (ø)
crypto/src/mls/conversation/config.rs 76.36% <83.33%> (+1.36%) ⬆️
crypto/src/mls/conversation/mod.rs 83.67% <100.00%> (ø)
crypto/src/mls/external_commit.rs 85.67% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c2d982...dcb154d. Read the comment docs.

@OtaK OtaK added the enhancement New feature or request label Jul 6, 2023
@augustocdias augustocdias force-pushed the feat/wpb-1188 branch 2 times, most recently from eacaf14 to c2cf701 Compare July 10, 2023 08:14
@augustocdias augustocdias marked this pull request as ready for review July 10, 2023 08:14
Cargo.toml Outdated Show resolved Hide resolved
crypto-ffi/src/wasm.rs Outdated Show resolved Hide resolved
crypto-ffi/src/wasm.rs Outdated Show resolved Hide resolved
crypto/src/mls/credential/trust_anchor.rs Show resolved Hide resolved
crypto-ffi/bindings/js/CoreCrypto.ts Outdated Show resolved Hide resolved
crypto-ffi/bindings/js/CoreCrypto.ts Outdated Show resolved Hide resolved
@@ -953,6 +974,45 @@ export class CoreCrypto {
));
}

/**
* Updates the trust anchors for a conversation
Copy link
Contributor

Choose a reason for hiding this comment

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

Give a bit more context about the validation rules: e.g. fails if you try to remove/add the same anchor etc...
When should a client call this method ? => when a federation event occurs etc..

Ok(cfg)
}
}

impl From<PerDomainTrustAnchor> for core_crypto::prelude::PerDomainTrustAnchor {
fn from(wasm_cfg: PerDomainTrustAnchor) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename wasm_cfg


pub(crate) fn extract_domain_name(certificate: &Certificate) -> CryptoResult<String> {
for attr in certificate.tbs_certificate.subject.0.iter().flat_map(|n| n.0.iter()) {
// according to the RFC implementations must be prepared to receive the domain component
Copy link
Contributor

Choose a reason for hiding this comment

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

Which RFC ? This Object Identifier seems to be reserved for LDAPs.
I think you should remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.4

In addition, implementations of this specification MUST be prepared
to receive the domainComponent attribute, as defined in [RFC4519].
The Domain Name System (DNS) provides a hierarchical resource
labeling system.

.unwrap_or_else(|| Ok(Vec::new()))?;

// check if all to remove exists
if remove_domain_names
Copy link
Contributor

Choose a reason for hiding this comment

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

You could simplify this by comparing anchors length before & after retain on L212

Comment on lines 202 to 209
// check if any new chain is already in the group's context
if anchors.iter().any(|a| {
add_trust_anchors
.iter()
.any(|n| n.intermediate_certificate_chain == a.intermediate_certificate_chain)
}) {
return Err(CryptoError::DuplicateCertificateChain);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You could factorize this check with this one a few lines below:

        // check for duplicate anchors to be added
        if anchors
            .iter()
            .any(|a| add_trust_anchors.iter().any(|n| a.domain_name == n.domain_name))
        {
            return Err(CryptoError::DuplicateDomainName);
        }

That way you only iterate once the lists. Use a try_for_each()


/// see [MlsCentral::update_trust_anchors_from_conversation]
#[cfg_attr(test, crate::durable)]
pub(crate) async fn update_trust_anchors(
Copy link
Contributor

Choose a reason for hiding this comment

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

You should really extract the validation part of this method into a dedicated method. This way we can reuse it if/when we allow to do the same in a GCE proposal

@@ -432,6 +435,20 @@ impl MlsCentral {
pub async fn count_credentials_in_keystore(&self) -> usize {
self.mls_backend.key_store().count::<MlsCredential>().await.unwrap()
}

pub async fn add_per_domain_trust_anchor_unwchecked(
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

.collect()
}

pub async fn add_per_domain_trust_anchor_unwchecked(
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

crypto-ffi/src/CoreCrypto.udl Outdated Show resolved Hide resolved
crypto-ffi/src/generic.rs Show resolved Hide resolved
@augustocdias augustocdias force-pushed the feat/wpb-1188 branch 2 times, most recently from 0cdf8a1 to a98f804 Compare July 21, 2023 06:44
@augustocdias augustocdias requested a review from OtaK July 21, 2023 08:20
@augustocdias augustocdias force-pushed the feat/wpb-1188 branch 2 times, most recently from add3cc9 to 9b87dce Compare July 24, 2023 06:46
Copy link
Contributor

@OtaK OtaK left a comment

Choose a reason for hiding this comment

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

Small nit to fix but LGTM

@@ -179,6 +185,14 @@ enum CryptoError {
"ClearingPendingCommitError",
"SelfCommitIgnored",
"UnmergedPendingGroup",
"X509CertDerError",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: indenting is wrong here (3 spaces, should be 4)

…t - WPB-1188

Co-authored-by: Mathieu Amiot <[email protected]>

Co-authored-by: beltram <[email protected]>
@augustocdias augustocdias merged commit 2ef9892 into develop Jul 24, 2023
21 checks passed
@augustocdias augustocdias deleted the feat/wpb-1188 branch July 24, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants