openmls/ciphersuite/
mod.rs

1//! # Ciphersuites for MLS
2//!
3//! This module defines the API for interacting with MLS ciphersuites. For
4//! implementation details, refer to `codec.rs` and `ciphersuites.rs`.
5
6use ::tls_codec::{TlsDeserialize, TlsDeserializeBytes, TlsSerialize, TlsSize, VLBytes};
7use openmls_traits::{
8    crypto::OpenMlsCrypto,
9    random::OpenMlsRand,
10    types::{AeadType, Ciphersuite, CryptoError, SignatureScheme},
11};
12use signable::SignedStruct;
13
14use std::hash::Hash;
15
16mod aead;
17mod codec;
18pub(crate) mod hpke;
19mod kdf_label;
20mod mac;
21mod reuse_guard;
22mod secret;
23
24// Public
25pub mod hash_ref;
26pub mod signable;
27pub mod signature;
28
29// Crate
30pub(crate) use aead::*;
31pub(crate) use mac::*;
32pub(crate) use reuse_guard::*;
33pub(crate) use secret::*;
34pub(crate) use signature::*;
35
36pub(crate) use serde::{Deserialize, Serialize};
37
38#[cfg(test)]
39mod tests_and_kats;
40
41const LABEL_PREFIX: &str = "MLS 1.0 ";
42
43/// A simple type for HPKE public keys using [`VLBytes`] for (de)serializing.
44pub type HpkePublicKey = VLBytes;
45pub use openmls_traits::types::HpkePrivateKey;
46
47/// Compare two byte slices in a way that's hopefully not optimised out by the
48/// compiler.
49#[inline(never)]
50fn equal_ct(a: &[u8], b: &[u8]) -> bool {
51    let mut diff = 0u8;
52    for (l, r) in a.iter().zip(b.iter()) {
53        diff |= l ^ r;
54    }
55    diff == 0
56}