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

Remove overloaded public methods from X509IdentityProvider #236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion mls-rs-crypto-awslc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ aws-lc-fips-sys = { version = "=0.13.0", optional = true }
mls-rs-core = { path = "../mls-rs-core", version = "0.20.0" }
mls-rs-crypto-hpke = { path = "../mls-rs-crypto-hpke", version = "0.12.0" }
mls-rs-crypto-traits = { path = "../mls-rs-crypto-traits", version = "0.12.0" }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", version = "0.13.0" }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", version = "0.14.0" }
thiserror = "1.0.40"
zeroize = { version = "1", features = ["zeroize_derive"] }
maybe-async = "0.2.10"
Expand Down
2 changes: 1 addition & 1 deletion mls-rs-crypto-openssl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default = ["x509"]
[dependencies]
openssl = { version = "0.10.40" }
mls-rs-core = { path = "../mls-rs-core", version = "0.20.0" }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", optional = true, version = "0.13.0" }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", optional = true, version = "0.14.0" }
mls-rs-crypto-hpke = { path = "../mls-rs-crypto-hpke", version = "0.12.0" }
mls-rs-crypto-traits = { path = "../mls-rs-crypto-traits", version = "0.12.0" }
thiserror = "1.0.40"
Expand Down
2 changes: 1 addition & 1 deletion mls-rs-crypto-rustcrypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ ed25519-dalek = { version = "2", default-features = false, features = ["alloc",
sec1 = { version = "0.7", default-features = false, features = ["alloc"] }

# X509 feature
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", optional = true, version = "0.13.0" }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", optional = true, version = "0.14.0" }
x509-cert = { version = "0.2", optional = true, features = ["std"] }
spki = { version = "0.7", optional = true, features = ["std", "alloc"] }
const-oid = { version = "0.9", optional = true, features = ["std"] }
Expand Down
4 changes: 2 additions & 2 deletions mls-rs-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ private_message = ["mls-rs/private_message"]
secret_tree_access = ["mls-rs/secret_tree_access"]

[dependencies]
mls-rs = { path = "../mls-rs", version = "0.43.0", features = ["ffi"] }
mls-rs = { path = "../mls-rs", version = "0.44.0", features = ["ffi"] }
mls-rs-crypto-openssl = { path = "../mls-rs-crypto-openssl", version = "0.12.0", optional = true }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", version = "0.13.0", optional = true }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", version = "0.14.0", optional = true }
mls-rs-provider-sqlite = { path = "../mls-rs-provider-sqlite", version = "0.14.0", default-features = false, optional = true }
safer-ffi = { version = "0.1.7", default-features = false }
safer-ffi-gen = { version = "0.9.2", default-features = false }
2 changes: 1 addition & 1 deletion mls-rs-identity-x509/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mls-rs-identity-x509"
version = "0.13.0"
version = "0.14.0"
edition = "2021"
description = "X509 Identity utilities for mls-rs"
homepage = "https://github.com/awslabs/mls-rs"
Expand Down
92 changes: 38 additions & 54 deletions mls-rs-identity-x509/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use mls_rs_core::{
crypto::SignaturePublicKey,
error::IntoAnyError,
extension::ExtensionList,
identity::{CredentialType, IdentityProvider, MemberValidationContext},
identity::{CredentialType, IdentityProvider, MemberValidationContext, SigningIdentity},
time::MlsTime,
};

Expand Down Expand Up @@ -80,10 +80,10 @@ where

/// Determine if a certificate is valid based on the behavior of the
/// underlying validator provided.
pub fn validate(
fn validate(
&self,
signing_identity: &mls_rs_core::identity::SigningIdentity,
timestamp: Option<mls_rs_core::time::MlsTime>,
signing_identity: &SigningIdentity,
timestamp: Option<MlsTime>,
) -> Result<(), X509IdentityError> {
let chain = credential_to_chain(&signing_identity.credential)?;

Expand All @@ -98,12 +98,34 @@ where

Ok(())
}
}

#[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)]
#[cfg_attr(mls_build_async, maybe_async::must_be_async)]
impl<IE, V> IdentityProvider for X509IdentityProvider<IE, V>
where
IE: X509IdentityExtractor + Send + Sync,
V: X509CredentialValidator + Send + Sync,
{
type Error = X509IdentityError;

/// Determine if a certificate is valid based on the behavior of the
/// underlying validator provided.
async fn validate_member(
&self,
signing_identity: &SigningIdentity,
timestamp: Option<MlsTime>,
_context: MemberValidationContext<'_>,
) -> Result<(), X509IdentityError> {
self.validate(signing_identity, timestamp)
}

/// Produce a unique identity value to represent the entity controlling a
/// certificate credential within an MLS group.
pub fn identity(
async fn identity(
&self,
signing_id: &mls_rs_core::identity::SigningIdentity,
signing_id: &SigningIdentity,
_extensions: &ExtensionList,
) -> Result<Vec<u8>, X509IdentityError> {
self.identity_extractor
.identity(&credential_to_chain(&signing_id.credential)?)
Expand All @@ -113,10 +135,11 @@ where
/// Determine if `successor` is controlled by the same entity as
/// `predecessor` based on the behavior of the underlying identity
/// extractor provided.
pub fn valid_successor(
async fn valid_successor(
&self,
predecessor: &mls_rs_core::identity::SigningIdentity,
successor: &mls_rs_core::identity::SigningIdentity,
predecessor: &SigningIdentity,
successor: &SigningIdentity,
_extensions: &ExtensionList,
) -> Result<bool, X509IdentityError> {
self.identity_extractor
.valid_successor(
Expand All @@ -126,65 +149,26 @@ where
.map_err(|e| X509IdentityError::IdentityExtractorError(e.into_any_error()))
}

/// Supported credential types.
///
/// Only [`CredentialType::X509`] is supported.
pub fn supported_types(&self) -> Vec<mls_rs_core::identity::CredentialType> {
vec![CredentialType::X509]
}
}

#[cfg_attr(not(mls_build_async), maybe_async::must_be_sync)]
#[cfg_attr(mls_build_async, maybe_async::must_be_async)]
impl<IE, V> IdentityProvider for X509IdentityProvider<IE, V>
where
IE: X509IdentityExtractor + Send + Sync,
V: X509CredentialValidator + Send + Sync,
{
type Error = X509IdentityError;

async fn validate_member(
&self,
signing_identity: &mls_rs_core::identity::SigningIdentity,
timestamp: Option<MlsTime>,
_: MemberValidationContext<'_>,
) -> Result<(), Self::Error> {
self.validate(signing_identity, timestamp)
}

async fn validate_external_sender(
&self,
signing_identity: &mls_rs_core::identity::SigningIdentity,
signing_identity: &SigningIdentity,
timestamp: Option<MlsTime>,
_extensions: Option<&ExtensionList>,
) -> Result<(), Self::Error> {
self.validate(signing_identity, timestamp)
}

async fn identity(
&self,
signing_id: &mls_rs_core::identity::SigningIdentity,
_extensions: &ExtensionList,
) -> Result<Vec<u8>, Self::Error> {
self.identity(signing_id)
}

async fn valid_successor(
&self,
predecessor: &mls_rs_core::identity::SigningIdentity,
successor: &mls_rs_core::identity::SigningIdentity,
_extensions: &ExtensionList,
) -> Result<bool, Self::Error> {
self.valid_successor(predecessor, successor)
}

/// Supported credential types.
///
/// Only [`CredentialType::X509`] is supported.
fn supported_types(&self) -> Vec<CredentialType> {
self.supported_types()
vec![CredentialType::X509]
}
}

#[cfg(all(test, feature = "std"))]
mod tests {
use super::*;
use mls_rs_core::{crypto::SignaturePublicKey, identity::CredentialType, time::MlsTime};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion mls-rs-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name = "mls_rs_uniffi"
[dependencies]
async-trait = "0.1.77"
maybe-async = "0.2.10"
mls-rs = { version = "0.43.0", path = "../mls-rs" }
mls-rs = { version = "0.44.0", path = "../mls-rs" }
mls-rs-core = { version = "0.20.0", path = "../mls-rs-core" }
mls-rs-crypto-openssl = { version = "0.12.0", path = "../mls-rs-crypto-openssl" }
thiserror = "1.0.57"
Expand Down
4 changes: 2 additions & 2 deletions mls-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mls-rs"
version = "0.43.3"
version = "0.44.0"
edition = "2021"
description = "An implementation of Messaging Layer Security (RFC 9420)"
homepage = "https://github.com/awslabs/mls-rs"
Expand Down Expand Up @@ -53,7 +53,7 @@ fuzz_util = ["test_util", "default", "dep:once_cell", "dep:mls-rs-crypto-openssl

[dependencies]
mls-rs-core = { path = "../mls-rs-core", default-features = false, version = "0.20.0" }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", default-features = false, version = "0.13.0", optional = true }
mls-rs-identity-x509 = { path = "../mls-rs-identity-x509", default-features = false, version = "0.14.0", optional = true }
zeroize = { version = "1", default-features = false, features = ["alloc", "zeroize_derive"] }
mls-rs-codec = { version = "0.5", path = "../mls-rs-codec", default-features = false}
thiserror = { version = "1.0.40", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion mls-rs/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
cargo-fuzz = true

[dependencies]
mls-rs = { version = "0.43.0", path = "..", features = ["arbitrary", "fuzz_util"] }
mls-rs = { version = "0.44.0", path = "..", features = ["arbitrary", "fuzz_util"] }
futures = "0.3.25"
libfuzzer-sys = "0.4"
once_cell = "1.13.0"
Expand Down
2 changes: 1 addition & 1 deletion mls-rs/test_harness_integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
publish = false

[dependencies]
mls-rs = { version = "0.43.0", path = "..", default-features = false, features = ["std", "external_client"]}
mls-rs = { version = "0.44.0", path = "..", default-features = false, features = ["std", "external_client"]}
tonic = "0.10.2"
prost = "0.12.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
Expand Down
Loading