Remove comments that went too obvious after refactoring the parts they were commenting
This commit is contained in:
parent
85d0ee7e31
commit
382492e915
1 changed files with 0 additions and 19 deletions
|
@ -26,18 +26,11 @@ pub fn encrypt(
|
|||
data: impl AsRef<[u8]>,
|
||||
data_context: &[impl AsRef<[u8]>],
|
||||
) -> Result<String> {
|
||||
// Derive the key
|
||||
let ikm = ikml.get_latest_ikm()?;
|
||||
let key = derive_key(ikm, key_context);
|
||||
|
||||
// Generate the AAD
|
||||
let aad = generate_aad(key_context, data_context);
|
||||
|
||||
// Encrypt
|
||||
let encryption_function = ikm.scheme.get_encryption();
|
||||
let encrypted_data = encryption_function(&key, data.as_ref(), &aad)?;
|
||||
|
||||
// Encode
|
||||
Ok(storage::encode(ikm.id, &encrypted_data))
|
||||
}
|
||||
|
||||
|
@ -77,17 +70,10 @@ pub fn decrypt(
|
|||
stored_data: &str,
|
||||
data_context: &[impl AsRef<[u8]>],
|
||||
) -> Result<Vec<u8>> {
|
||||
// Retreive the IKM and the encrypted data
|
||||
let (ikm_id, encrypted_data) = storage::decode(stored_data)?;
|
||||
let ikm = ikml.get_ikm_by_id(ikm_id)?;
|
||||
|
||||
// Derive the key
|
||||
let key = derive_key(ikm, key_context);
|
||||
|
||||
// Generate the AAD
|
||||
let aad = generate_aad(key_context, data_context);
|
||||
|
||||
// Decrypt
|
||||
let decryption_function = ikm.scheme.get_decryption();
|
||||
decryption_function(&key, &encrypted_data, &aad)
|
||||
}
|
||||
|
@ -97,17 +83,12 @@ pub(crate) fn xchacha20poly1305_decrypt(
|
|||
encrypted_data: &EncryptedData,
|
||||
aad: &str,
|
||||
) -> Result<Vec<u8>> {
|
||||
// Adapt the key and the nonce
|
||||
let key = Key::from_slice(key);
|
||||
let nonce = XNonce::from_slice(&encrypted_data.nonce);
|
||||
|
||||
// Prepare the payload
|
||||
let payload = Payload {
|
||||
msg: &encrypted_data.ciphertext,
|
||||
aad: aad.as_bytes(),
|
||||
};
|
||||
|
||||
// Decrypt the payload
|
||||
let cipher = XChaCha20Poly1305::new(key);
|
||||
Ok(cipher.decrypt(nonce, payload)?)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue