From e6f7167525fcbc141744c376fa4ad90cbb71c213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 17 Mar 2024 14:45:18 +0100 Subject: [PATCH] Move the EncryptedData struct to a dedicated module --- src/cipher_box.rs | 6 ------ src/encrypted_data.rs | 5 +++++ src/lib.rs | 2 ++ src/scheme.rs | 2 +- src/scheme/xchacha20poly1305.rs | 2 +- src/storage.rs | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 src/encrypted_data.rs diff --git a/src/cipher_box.rs b/src/cipher_box.rs index 34a3e02..cd3e50f 100644 --- a/src/cipher_box.rs +++ b/src/cipher_box.rs @@ -5,12 +5,6 @@ use crate::kdf::derive_key; use crate::{storage, IkmId, InputKeyMaterialList}; use std::time::{SystemTime, UNIX_EPOCH}; -#[derive(Debug)] -pub(crate) struct EncryptedData { - pub(crate) nonce: Vec, - pub(crate) ciphertext: Vec, -} - pub struct CipherBox<'a> { ikm_list: &'a InputKeyMaterialList, } diff --git a/src/encrypted_data.rs b/src/encrypted_data.rs new file mode 100644 index 0000000..02778a5 --- /dev/null +++ b/src/encrypted_data.rs @@ -0,0 +1,5 @@ +#[derive(Debug)] +pub(crate) struct EncryptedData { + pub(crate) nonce: Vec, + pub(crate) ciphertext: Vec, +} diff --git a/src/lib.rs b/src/lib.rs index de316ed..7183f7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,8 @@ mod canonicalization; mod cipher_box; #[cfg(feature = "encryption")] mod context; +#[cfg(feature = "encryption")] +mod encrypted_data; #[cfg(any(feature = "encryption", feature = "ikm-management"))] mod error; #[cfg(any(feature = "encryption", feature = "ikm-management"))] diff --git a/src/scheme.rs b/src/scheme.rs index a089481..73462ca 100644 --- a/src/scheme.rs +++ b/src/scheme.rs @@ -1,5 +1,5 @@ #[cfg(feature = "encryption")] -use crate::cipher_box::EncryptedData; +use crate::encrypted_data::EncryptedData; #[cfg(feature = "encryption")] use crate::error::Result; #[cfg(feature = "encryption")] diff --git a/src/scheme/xchacha20poly1305.rs b/src/scheme/xchacha20poly1305.rs index ad196f8..45329cc 100644 --- a/src/scheme/xchacha20poly1305.rs +++ b/src/scheme/xchacha20poly1305.rs @@ -1,4 +1,4 @@ -use crate::cipher_box::EncryptedData; +use crate::encrypted_data::EncryptedData; use crate::error::Result; use chacha20poly1305::aead::{Aead, KeyInit, Payload}; use chacha20poly1305::{Key, XChaCha20Poly1305, XNonce}; diff --git a/src/storage.rs b/src/storage.rs index d1f4ee8..291df40 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -1,5 +1,5 @@ #[cfg(feature = "encryption")] -use crate::cipher_box::EncryptedData; +use crate::encrypted_data::EncryptedData; use crate::error::{Error, Result}; #[cfg(feature = "encryption")] use crate::ikm::IkmId;