openmls/extensions/
application_id_extension.rs

1use tls_codec::{TlsDeserialize, TlsDeserializeBytes, TlsSerialize, TlsSize, VLBytes};
2
3use super::{Deserialize, Serialize};
4
5/// # Application Identifiers
6///
7/// Within MLS, a KeyPackage is identified by its hash ([`KeyPackageRef`](`crate::ciphersuite::hash_ref::KeyPackageRef`)).
8/// The application id extension allows applications to add an explicit,
9/// application-defined identifier to a KeyPackage.
10#[derive(
11    PartialEq,
12    Eq,
13    Clone,
14    Debug,
15    Serialize,
16    Deserialize,
17    TlsSerialize,
18    TlsDeserialize,
19    TlsDeserializeBytes,
20    TlsSize,
21)]
22pub struct ApplicationIdExtension {
23    key_id: VLBytes,
24}
25
26impl ApplicationIdExtension {
27    /// Create a new key identifier extension from a byte slice.
28    pub fn new(id: &[u8]) -> Self {
29        Self { key_id: id.into() }
30    }
31
32    /// Get the value of the key id as byte slice.
33    pub fn as_slice(&self) -> &[u8] {
34        self.key_id.as_slice()
35    }
36}