split 1 of 772644f, debugging ci

This commit is contained in:
17ms 2023-05-01 13:52:54 +03:00
parent 573a2a44a1
commit 0bc1ec8a9a
2 changed files with 8 additions and 5 deletions

View File

@ -62,7 +62,10 @@ pub fn aes_encrypt(
rng: &mut OsRng, rng: &mut OsRng,
) -> Result<Vec<u8>, Box<dyn Error + Send + Sync>> { ) -> Result<Vec<u8>, Box<dyn Error + Send + Sync>> {
let nonce = generate_nonce(rng); let nonce = generate_nonce(rng);
let encrypted = cipher.encrypt(&nonce, data.as_ref()).unwrap(); // TODO: handle errors let encrypted = match cipher.encrypt(&nonce, data.as_ref()) {
Ok(data) => data,
Err(_) => return Err("AES encryption failed".into()),
};
let mut data = nonce.to_vec(); let mut data = nonce.to_vec();
data.extend_from_slice(&encrypted); data.extend_from_slice(&encrypted);
@ -74,9 +77,10 @@ pub fn aes_decrypt(
cipher: &mut AesGcm<Aes256, U12>, cipher: &mut AesGcm<Aes256, U12>,
) -> Result<Vec<u8>, Box<dyn Error + Send + Sync>> { ) -> Result<Vec<u8>, Box<dyn Error + Send + Sync>> {
let (nonce_bytes, data) = data.split_at(AES_NONCE_SIZE); let (nonce_bytes, data) = data.split_at(AES_NONCE_SIZE);
let decrypted = cipher let decrypted = match cipher.decrypt(Nonce::from_slice(nonce_bytes), data.as_ref()) {
.decrypt(Nonce::from_slice(nonce_bytes), data.as_ref()) Ok(data) => data,
.unwrap(); // TODO: handle errors Err(_) => return Err("AES decryption failed".into()),
};
Ok(decrypted) Ok(decrypted)
} }

View File

@ -1 +0,0 @@
// placeholder