External Types
For interoperability, this crate also defines several types and algorithm identifiers.
AEADs
The following AEADs are defined.
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[repr(u16)]
/// AEAD types
pub enum AeadType {
/// AES GCM 128
Aes128Gcm = 0x0001,
/// AES GCM 256
Aes256Gcm = 0x0002,
An AEAD provides the following functions to get the according values for each algorithm.
tag_sizekey_sizenonce_size
Hashing
The following hash algorithms are defined.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
#[repr(u8)]
#[allow(non_camel_case_types)]
/// Hash types
pub enum HashType {
A hash algorithm provides the following functions to get the according values for each algorithm.
size
Signatures
The following signature schemes are defined.
TlsSerializeBytes,
TlsDeserialize,
TlsDeserializeBytes,
TlsSize,
)]
#[repr(u16)]
pub enum SignatureScheme {
/// ECDSA_SECP256R1_SHA256
ECDSA_SECP256R1_SHA256 = 0x0403,
/// ECDSA_SECP384R1_SHA384
ECDSA_SECP384R1_SHA384 = 0x0503,
/// ECDSA_SECP521R1_SHA512
HPKE Types
The HPKE implementation is part of the crypto provider as well. The crate, therefore, defines the necessary types too.
The HPKE algorithms are defined as follows.
SigningError,
InvalidPublicKey,
}
impl std::fmt::Display for CryptoError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for CryptoError {}
// === HPKE === //
/// Convenience tuple struct for an HPKE configuration.
#[derive(Debug)]
#[repr(u16)]
pub enum HpkeKemType {
/// DH KEM on P256
DhKemP256 = 0x0010,
/// DH KEM on P384
DhKemP384 = 0x0011,
/// DH KEM on P521
DhKemP521 = 0x0012,
/// DH KEM on x448
DhKem448 = 0x0021,
/// ML-KEM-768
#[cfg(feature = "draft-ietf-mls-pq-ciphersuites")]
MlKem768 = 0x0041,
/// ML-KEM-1024
#[cfg(feature = "draft-ietf-mls-pq-ciphersuites")]
MlKem1024 = 0x0042,
/// XWing combiner for ML-KEM and X25519
#[cfg(feature = "draft-ietf-mls-pq-ciphersuites")]
In addition, helper structs for HpkeCiphertext and HpkeKeyPair are defined.
/// HKDF SHA 512
HkdfSha512 = 0x0003,
}
#[repr(u16)]
pub enum HpkeAeadType {
/// AES GCM 128
AesGcm128 = 0x0001,