Rename the CipherBox as Coffio
This commit is contained in:
parent
71647c31c5
commit
5dec70af92
3 changed files with 14 additions and 14 deletions
|
@ -5,11 +5,11 @@ use crate::kdf::derive_key;
|
||||||
use crate::{storage, IkmId, InputKeyMaterialList};
|
use crate::{storage, IkmId, InputKeyMaterialList};
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
pub struct CipherBox<'a> {
|
pub struct Coffio<'a> {
|
||||||
ikm_list: &'a InputKeyMaterialList,
|
ikm_list: &'a InputKeyMaterialList,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CipherBox<'a> {
|
impl<'a> Coffio<'a> {
|
||||||
pub fn new(ikm_list: &'a InputKeyMaterialList) -> Self {
|
pub fn new(ikm_list: &'a InputKeyMaterialList) -> Self {
|
||||||
Self { ikm_list }
|
Self { ikm_list }
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
||||||
let key_ctx = get_static_empty_key_ctx();
|
let key_ctx = get_static_empty_key_ctx();
|
||||||
let data_ctx = DataContext::from([]);
|
let data_ctx = DataContext::from([]);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
||||||
|
@ -134,7 +134,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_aes128gcm_sha256();
|
let lst = get_ikm_lst_aes128gcm_sha256();
|
||||||
let key_ctx = get_static_empty_key_ctx();
|
let key_ctx = get_static_empty_key_ctx();
|
||||||
let data_ctx = DataContext::from([]);
|
let data_ctx = DataContext::from([]);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
||||||
|
@ -155,7 +155,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
||||||
let key_ctx = get_static_key_ctx();
|
let key_ctx = get_static_key_ctx();
|
||||||
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
||||||
|
@ -176,7 +176,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_aes128gcm_sha256();
|
let lst = get_ikm_lst_aes128gcm_sha256();
|
||||||
let key_ctx = get_static_key_ctx();
|
let key_ctx = get_static_key_ctx();
|
||||||
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
||||||
|
@ -197,7 +197,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
||||||
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
||||||
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
||||||
|
@ -218,7 +218,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_aes128gcm_sha256();
|
let lst = get_ikm_lst_aes128gcm_sha256();
|
||||||
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
||||||
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Encrypt
|
// Encrypt
|
||||||
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
let res = cb.encrypt(&key_ctx, &data_ctx, TEST_DATA);
|
||||||
|
@ -249,7 +249,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
||||||
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
||||||
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
// Test if the reference ciphertext used for the tests is actually valid
|
// Test if the reference ciphertext used for the tests is actually valid
|
||||||
let res = cb.decrypt(&key_ctx, &data_ctx, TEST_CIPHERTEXT);
|
let res = cb.decrypt(&key_ctx, &data_ctx, TEST_CIPHERTEXT);
|
||||||
|
@ -267,7 +267,7 @@ mod tests {
|
||||||
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
let lst = get_ikm_lst_chacha20poly1305_blake3();
|
||||||
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
let key_ctx = KeyContext::from(TEST_KEY_CTX);
|
||||||
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
let data_ctx = DataContext::from(TEST_DATA_CTX);
|
||||||
let cb = CipherBox::new(&lst);
|
let cb = Coffio::new(&lst);
|
||||||
|
|
||||||
let res = cb.decrypt(&key_ctx, &data_ctx, TEST_CIPHERTEXT);
|
let res = cb.decrypt(&key_ctx, &data_ctx, TEST_CIPHERTEXT);
|
||||||
assert!(res.is_ok(), "invalid reference ciphertext");
|
assert!(res.is_ok(), "invalid reference ciphertext");
|
|
@ -1,7 +1,7 @@
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
mod canonicalization;
|
mod canonicalization;
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
mod cipher_box;
|
mod coffio;
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
mod context;
|
mod context;
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
|
@ -18,7 +18,7 @@ mod scheme;
|
||||||
mod storage;
|
mod storage;
|
||||||
|
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
pub use cipher_box::CipherBox;
|
pub use coffio::Coffio;
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
pub use context::{DataContext, KeyContext};
|
pub use context::{DataContext, KeyContext};
|
||||||
#[cfg(any(feature = "encryption", feature = "ikm-management"))]
|
#[cfg(any(feature = "encryption", feature = "ikm-management"))]
|
||||||
|
|
|
@ -36,10 +36,10 @@ pub(crate) type SchemeSerializeType = u32;
|
||||||
/// In the following scheme description, the following terms are used:
|
/// In the following scheme description, the following terms are used:
|
||||||
/// - `Max data size` describes the maximal size of data that can safely be encrypted using a
|
/// - `Max data size` describes the maximal size of data that can safely be encrypted using a
|
||||||
/// single key and nonce, which means you should never pass a `data` parameter to
|
/// single key and nonce, which means you should never pass a `data` parameter to
|
||||||
/// [encrypt][crate::CipherBox::encrypt] that has a higher size. Coffio will not enforce this
|
/// [encrypt][crate::Coffio::encrypt] that has a higher size. Coffio will not enforce this
|
||||||
/// limit, it is your responsibility to do so.
|
/// limit, it is your responsibility to do so.
|
||||||
/// - `Max invocations` describes the maximal number of times you can safely call
|
/// - `Max invocations` describes the maximal number of times you can safely call
|
||||||
/// [encrypt][crate::CipherBox::encrypt] with a single key, which means you should either rotate
|
/// [encrypt][crate::Coffio::encrypt] with a single key, which means you should either rotate
|
||||||
/// your IKM or use an appropriate key periodicity before reaching this number. Coffio will neither
|
/// your IKM or use an appropriate key periodicity before reaching this number. Coffio will neither
|
||||||
/// enforce this limit nor count the number of invocations, it is your responsibility to do so.
|
/// enforce this limit nor count the number of invocations, it is your responsibility to do so.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
|
Loading…
Reference in a new issue