diff --git a/openmls/src/extensions/codec.rs b/openmls/src/extensions/codec.rs index 1ba2ad498c..00408aa994 100644 --- a/openmls/src/extensions/codec.rs +++ b/openmls/src/extensions/codec.rs @@ -38,7 +38,6 @@ impl Size for Extension { Extension::ExternalSenders(e) => e.tls_serialized_len(), Extension::LastResort(e) => e.tls_serialized_len(), Extension::ImmutableMetadata(e) => e.tls_serialized_len(), - Extension::Metadata(e) => e.tls_serialized_len(), Extension::Unknown(_, e) => e.0.len(), }; @@ -72,7 +71,6 @@ impl Serialize for Extension { Extension::ExternalSenders(e) => e.tls_serialize(&mut extension_data), Extension::LastResort(e) => e.tls_serialize(&mut extension_data), Extension::ImmutableMetadata(e) => e.tls_serialize(&mut extension_data), - Extension::Metadata(e) => e.tls_serialize(&mut extension_data), Extension::Unknown(_, e) => extension_data .write_all(e.0.as_slice()) .map(|_| e.0.len()) @@ -125,9 +123,6 @@ impl Deserialize for Extension { ExtensionType::ImmutableMetadata => { Extension::ImmutableMetadata(Metadata::tls_deserialize(&mut extension_data)?) } - ExtensionType::Metadata => { - Extension::Metadata(Metadata::tls_deserialize(&mut extension_data)?) - } ExtensionType::Unknown(unknown) => { Extension::Unknown(unknown, UnknownExtension(extension_data.to_vec())) } diff --git a/openmls/src/extensions/mod.rs b/openmls/src/extensions/mod.rs index 292142001b..6bdd31f952 100644 --- a/openmls/src/extensions/mod.rs +++ b/openmls/src/extensions/mod.rs @@ -104,9 +104,6 @@ pub enum ExtensionType { /// This can only be set on creation of the group. ImmutableMetadata, - /// Metadata extension for policies and other metadata. GroupContext Extension. - Metadata, - /// A currently unknown extension type. Unknown(u16), } @@ -159,7 +156,6 @@ impl From for ExtensionType { 5 => ExtensionType::ExternalSenders, 10 => ExtensionType::LastResort, 0xf000 => ExtensionType::ImmutableMetadata, - 0xf001 => ExtensionType::Metadata, unknown => ExtensionType::Unknown(unknown), } } @@ -175,7 +171,6 @@ impl From for u16 { ExtensionType::ExternalSenders => 5, ExtensionType::LastResort => 10, ExtensionType::ImmutableMetadata => 0xf000, - ExtensionType::Metadata => 0xf001, ExtensionType::Unknown(unknown) => unknown, } } @@ -193,7 +188,6 @@ impl ExtensionType { | ExtensionType::ExternalSenders | ExtensionType::LastResort | ExtensionType::ImmutableMetadata - | ExtensionType::Metadata ) } } @@ -235,9 +229,6 @@ pub enum Extension { /// An [`ImmutableMetadata`] extension ImmutableMetadata(Metadata), - // A [`Metadata`] extension - Metadata(Metadata), - /// A currently unknown extension. Unknown(u16, UnknownExtension), } @@ -437,15 +428,6 @@ impl Extensions { _ => None, }) } - - /// Get a reference to the mutable [`Metadata`] if there is any. - pub fn metadata(&self) -> Option<&Metadata> { - self.find_by_type(ExtensionType::Metadata) - .and_then(|e| match e { - Extension::Metadata(e) => Some(e), - _ => None, - }) - } } impl Extension { @@ -536,7 +518,6 @@ impl Extension { Extension::ExternalSenders(_) => ExtensionType::ExternalSenders, Extension::LastResort(_) => ExtensionType::LastResort, Extension::ImmutableMetadata(_) => ExtensionType::ImmutableMetadata, - Extension::Metadata(_) => ExtensionType::Metadata, Extension::Unknown(kind, _) => ExtensionType::Unknown(*kind), } } diff --git a/openmls/src/extensions/test_extensions.rs b/openmls/src/extensions/test_extensions.rs index 0488d88e1d..50eeeda8d2 100644 --- a/openmls/src/extensions/test_extensions.rs +++ b/openmls/src/extensions/test_extensions.rs @@ -262,7 +262,7 @@ fn test_metadata(ciphersuite: Ciphersuite, provider: &impl OpenMlsProvider) { // example metadata (opaque data -- test hex string is "1cedc0ffee") let metadata = vec![0x1c, 0xed, 0xc0, 0xff, 0xee]; - let ext = Extension::Metadata(Metadata::new(metadata.clone())); + let ext = Extension::Unknown(0xf001, UnknownExtension(metadata.clone())); let extensions = Extensions::from_vec(vec![ext]).expect("could not build extensions struct"); let config = MlsGroupCreateConfig::builder() @@ -284,10 +284,14 @@ fn test_metadata(ciphersuite: Ciphersuite, provider: &impl OpenMlsProvider) { let got_metadata = alice_group .export_group_context() .extensions() - .metadata() + .find_by_type(ExtensionType::Unknown(0xf001)) .expect("failed to read group metadata"); - assert_eq!(got_metadata.metadata(), &metadata); + if let Extension::Unknown(0xf001, UnknownExtension(got_metadata)) = got_metadata { + assert_eq!(got_metadata, &metadata); + } else { + panic!("metadata extension has wrong extension enum variant") + } } #[apply(ciphersuites_and_providers)]