Skip to content

Commit

Permalink
Merge pull request #15 from xmtp/nm/expose-hpke-encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas authored Jan 18, 2024
2 parents ce07d17 + 86a8849 commit a12c743
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions openmls/src/ciphersuite/hpke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use super::LABEL_PREFIX;

/// HPKE labeled encryption errors.
#[derive(Error, Debug, PartialEq, Clone)]
pub(crate) enum Error {
pub enum Error {
/// Error while serializing content. This should only happen if a bounds check was missing.
#[error(
"Error while serializing content. This should only happen if a bounds check was missing."
Expand All @@ -68,12 +68,14 @@ impl From<CryptoError> for Error {
}
}

/// Context for HPKE encryption
#[derive(Debug, Clone, TlsSerialize, TlsDeserialize, TlsDeserializeBytes, TlsSize)]
pub struct EncryptContext {
label: VLBytes,
context: VLBytes,
}

/// Context for HPKE encryption
impl EncryptContext {
/// Create a new [`EncryptContext`] from a string label and the content bytes.
pub fn new(label: &str, context: VLBytes) -> Self {
Expand All @@ -90,7 +92,7 @@ impl From<(&str, &[u8])> for EncryptContext {
}

/// Encrypt to an HPKE key with a label.
pub(crate) fn encrypt_with_label(
pub fn encrypt_with_label(
public_key: &[u8],
label: &str,
context: &[u8],
Expand Down Expand Up @@ -123,7 +125,7 @@ pub(crate) fn encrypt_with_label(
}

/// Decrypt with HPKE and label.
pub(crate) fn decrypt_with_label(
pub fn decrypt_with_label(
private_key: &[u8],
label: &str,
context: &[u8],
Expand Down
2 changes: 1 addition & 1 deletion openmls/src/ciphersuite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::hash::Hash;

mod aead;
mod codec;
pub(crate) mod hpke;
pub mod hpke;
mod kdf_label;
mod mac;
mod reuse_guard;
Expand Down

0 comments on commit a12c743

Please sign in to comment.