From ab8162ba13993c614f6af4722ae4a4f78bd23943 Mon Sep 17 00:00:00 2001 From: OK Ryoko Date: Mon, 15 May 2023 06:19:19 -0400 Subject: [PATCH] define KeyCustomInit trait --- crypto-common/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crypto-common/src/lib.rs b/crypto-common/src/lib.rs index 53f0fa9cf..dece9be13 100644 --- a/crypto-common/src/lib.rs +++ b/crypto-common/src/lib.rs @@ -169,6 +169,17 @@ pub trait KeyInit: KeySizeUser + Sized { } } +/// Types which can be initialized from a key and customization string, each of arbitrary length +pub trait KeyCustomInit: Sized { + /// Create new value from an arbitrary-length key and empty customization string + fn new_from_slice(key: &[u8]) -> Self { + Self::new_with_customization(key, &[]) + } + + /// Create new value from a key and customization string, each of arbitrary length + fn new_with_customization(key: &[u8], customization: &[u8]) -> Self; +} + /// Types which can be initialized from key and initialization vector (nonce). pub trait KeyIvInit: KeySizeUser + IvSizeUser + Sized { /// Create new value from fixed length key and nonce.