Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose encryption methods #15

Merged
merged 6 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading