Struct crypt_guard::KeyControl
source · pub struct KeyControl<T: KyberKeyFunctions> {
pub public_key: Vec<u8>,
pub secret_key: Vec<u8>,
pub ciphertext: Vec<u8>,
pub shared_secret: Vec<u8>,
/* private fields */
}
Expand description
A structure to manage cryptographic keys and operations for the Kyber algorithm. It encapsulates the public key, secret key, ciphertext, and shared secret.
Fields§
§public_key: Vec<u8>
§secret_key: Vec<u8>
§ciphertext: Vec<u8>
Implementations§
source§impl<T: KyberKeyFunctions> KeyControl<T>
impl<T: KyberKeyFunctions> KeyControl<T>
sourcepub fn set_ciphertext(&mut self, cipher: Vec<u8>) -> Result<(), CryptError>
pub fn set_ciphertext(&mut self, cipher: Vec<u8>) -> Result<(), CryptError>
Sets the ciphertext for the KeyControl
instance.
sourcepub fn set_public_key(&mut self, public: Vec<u8>) -> Result<(), CryptError>
pub fn set_public_key(&mut self, public: Vec<u8>) -> Result<(), CryptError>
Sets the public key for the KeyControl
instance.
sourcepub fn set_secret_key(&mut self, sec: Vec<u8>) -> Result<(), CryptError>
pub fn set_secret_key(&mut self, sec: Vec<u8>) -> Result<(), CryptError>
Sets the secret key for the KeyControl
instance.
sourcepub fn get_key(&self, key: KeyTypes) -> Result<Key, CryptError>
pub fn get_key(&self, key: KeyTypes) -> Result<Key, CryptError>
Retrieves a specified key based on KeyTypes
.
sourcepub fn save(&self, key: KeyTypes, base_path: PathBuf) -> Result<(), CryptError>
pub fn save(&self, key: KeyTypes, base_path: PathBuf) -> Result<(), CryptError>
Saves a specified key to a file at the given base path.
sourcepub fn load(&self, key: KeyTypes, path: &Path) -> Result<Vec<u8>, CryptError>
pub fn load(&self, key: KeyTypes, path: &Path) -> Result<Vec<u8>, CryptError>
Loads a specified key from a file.
sourcepub fn public_key(&self) -> Result<Vec<u8>, CryptError>
pub fn public_key(&self) -> Result<Vec<u8>, CryptError>
Getter methods for public_key, secret_key, ciphertext, and shared_secret.
pub fn secret_key(&self) -> Result<Vec<u8>, CryptError>
pub fn ciphertext(&self) -> Result<Vec<u8>, CryptError>
Auto Trait Implementations§
impl<T> Freeze for KeyControl<T>
impl<T> RefUnwindSafe for KeyControl<T>where
T: RefUnwindSafe,
impl<T> Send for KeyControl<T>where
T: Send,
impl<T> Sync for KeyControl<T>where
T: Sync,
impl<T> Unpin for KeyControl<T>where
T: Unpin,
impl<T> UnwindSafe for KeyControl<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more