pub fn verify(&self, backend: &impl OpenMlsCryptoProvider) -> Result<(), KeyPackageError> {
        //  First make sure that all mandatory extensions are present.
        let mut mandatory_extensions_found = MANDATORY_EXTENSIONS.to_vec();
        for extension in self.payload.extensions.iter() {
            if let Some(p) = mandatory_extensions_found
                .iter()
                .position(|&e| e == extension.extension_type())
            {
                let _ = mandatory_extensions_found.remove(p);
            }
            // Make sure the lifetime is valid.
            if extension.extension_type() == ExtensionType::Lifetime {
                match extension.as_lifetime_extension() {
                    Ok(e) => {
                        if !e.is_valid() {
                            log::error!("Invalid lifetime extension in key package.");
                            return Err(KeyPackageError::InvalidLifetimeExtension);
                        }
                    }
                    Err(e) => {
                        log::error!("as_lifetime_extension failed while verifying a key package.");
                        error!("Library error: {:?}", e);
                        return Err(KeyPackageError::LibraryError);
                    }
                }
            }
        }

        // Make sure we found all mandatory extensions.
        if !mandatory_extensions_found.is_empty() {
            log::error!("This key package is missing mandatory extensions.");
            return Err(KeyPackageError::MandatoryExtensionsMissing);
        }

        // Verify the signature on this key package.
        <Self as Verifiable>::verify_no_out(self, backend, &self.payload.credential).map_err(|_| {
            log::error!("Key package signature is invalid.");
            log::trace!("Payload: {:x?}", self.encoded);
            KeyPackageError::InvalidSignature
        })
    }
/// Verify that this key package is valid:
/// * verify that the signature on this key package is valid
/// * verify that all mandatory extensions are present
/// * make sure that the lifetime is valid
/// Returns `Ok(())` if all checks succeed and `KeyPackageError` otherwise
Verify that this key package is valid:
verify that the signature on this key package is valid
verify that all mandatory extensions are present
make sure that the lifetime is valid
Returns `Ok(())` if all checks succeed and `KeyPackageError` otherwise
Verify that this key package is valid : verify that the signature on this key package is valid verify that all mandatory extensions are present make sure that the lifetime is valid Returns ` Ok (( )) ` if all checks succeed and ` KeyPackageError ` otherwise
pub fn verify(&self, backend: &impl OpenMlsCryptoProvider) -> Result<(), KeyPackageError> {
        //  First make sure that all mandatory extensions are present.
        let mut mandatory_extensions_found = MANDATORY_EXTENSIONS.to_vec();
        for extension in self.payload.extensions.iter() {
            if let Some(p) = mandatory_extensions_found
                .iter()
                .position(|&e| e == extension.extension_type())
            {
                let _ = mandatory_extensions_found.remove(p);
            }
            // Make sure the lifetime is valid.
            if extension.extension_type() == ExtensionType::Lifetime {
                match extension.as_lifetime_extension() {
                    Ok(e) => {
                        if !e.is_valid() {
                            log::error!("Invalid lifetime extension in key package.");
                            return Err(KeyPackageError::InvalidLifetimeExtension);
                        }
                    }
                    Err(e) => {
                        log::error!("as_lifetime_extension failed while verifying a key package.");
                        error!("Library error: {:?}", e);
                        return Err(KeyPackageError::LibraryError);
                    }
                }
            }
        }
        // Make sure we found all mandatory extensions.
        if !mandatory_extensions_found.is_empty() {
            log::error!("This key package is missing mandatory extensions.");
            return Err(KeyPackageError::MandatoryExtensionsMissing);
        }
        // Verify the signature on this key package.
        <Self as Verifiable>::verify_no_out(self, backend, &self.payload.credential).map_err(|_| {
            log::error!("Key package signature is invalid.");
            log::trace!("Payload: {:x?}", self.encoded);
            KeyPackageError::InvalidSignature
        })
    }
pub fn verify ( & self , backend : & impl OpenMlsCryptoProvider ) -> Result < ( ) , KeyPackageError > { //  First make sure that all mandatory extensions are present. let mut mandatory_extensions_found = MANDATORY_EXTENSIONS . to_vec ( ) ; for extension in self . payload . extensions . iter ( ) { if let Some ( p ) = mandatory_extensions_found . iter ( ) . position ( | & e | e == extension . extension_type ( ) ) { let _ = mandatory_extensions_found . remove ( p ) ; } // Make sure the lifetime is valid. if extension . extension_type ( ) == ExtensionType :: Lifetime { match extension . as_lifetime_extension ( ) { Ok ( e ) => { if ! e . is_valid ( ) { log :: error ! ( " " ) ; return Err ( KeyPackageError :: InvalidLifetimeExtension ) ; } } Err ( e ) => { log :: error ! ( " " ) ; error ! ( " " e ) ; return Err ( KeyPackageError :: LibraryError ) ; } } } } // Make sure we found all mandatory extensions. if ! mandatory_extensions_found . is_empty ( ) { log :: error ! ( " " ) ; return Err ( KeyPackageError :: MandatoryExtensionsMissing ) ; } // Verify the signature on this key package. < Self as Verifiable > :: verify_no_out ( self , backend , & self . payload . credential ) . map_err ( | _ | { log :: error ! ( " " ) ; log :: trace ! ( " " self encoded ) ; KeyPackageError :: InvalidSignature } ) }
Verify that this key package is valid:
 verify that the signature on this key package is valid
 verify that all mandatory extensions are present
 make sure that the lifetime is valid
Returns `Ok(())` if all checks succeed and `KeyPackageError` otherwise
Verify that this key package is valid : verify that the signature on this key package is valid verify that all mandatory extensions are present make sure that the lifetime is valid Returns ` Ok (( )) ` if all checks succeed and ` KeyPackageError ` otherwise
&self
backend
&impl OpenMlsCryptoProvider
&self
backend
&impl OpenMlsCryptoProvider