From 282d0caa792765fcc40f2229d30db7fc651c18a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Fri, 6 Oct 2023 17:17:08 +0200 Subject: [PATCH] Fix changed encrypt_aes function, correctly this time --- crates/bitwarden/benches/chunked_decryption.rs | 4 ++-- crates/bitwarden/src/crypto/chunked_decryptor.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bitwarden/benches/chunked_decryption.rs b/crates/bitwarden/benches/chunked_decryption.rs index b5b4e3e47..4dbab368b 100644 --- a/crates/bitwarden/benches/chunked_decryption.rs +++ b/crates/bitwarden/benches/chunked_decryption.rs @@ -1,6 +1,6 @@ use std::io::Write; -use bitwarden::crypto::{encrypt_aes256, ChunkedDecryptor, SymmetricCryptoKey}; +use bitwarden::crypto::{encrypt_aes256_hmac, ChunkedDecryptor, SymmetricCryptoKey}; use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; use rand::RngCore; @@ -32,7 +32,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { initial_buf.resize(size, 0); rand::thread_rng().fill_bytes(&mut initial_buf[..size]); let key: SymmetricCryptoKey = SymmetricCryptoKey::generate("test"); - let enc_str = encrypt_aes256(&initial_buf, key.key).unwrap(); + let enc_str = encrypt_aes256_hmac(&initial_buf, key.mac_key.unwrap(), key.key).unwrap(); let enc_buf = enc_str.to_buffer().unwrap(); group.bench_with_input( diff --git a/crates/bitwarden/src/crypto/chunked_decryptor.rs b/crates/bitwarden/src/crypto/chunked_decryptor.rs index c59d28419..2d6ed96e5 100644 --- a/crates/bitwarden/src/crypto/chunked_decryptor.rs +++ b/crates/bitwarden/src/crypto/chunked_decryptor.rs @@ -314,7 +314,7 @@ mod tests { use rand::RngCore; - use crate::crypto::{encrypt_aes256, SymmetricCryptoKey}; + use crate::crypto::{encrypt_aes256_hmac, SymmetricCryptoKey}; use super::ChunkedDecryptor; @@ -326,7 +326,7 @@ mod tests { initial_buf.resize(size, 0); rand::thread_rng().fill_bytes(&mut initial_buf[..size]); let key: SymmetricCryptoKey = SymmetricCryptoKey::generate("test"); - let encrypted_buf = encrypt_aes256(&initial_buf, key.key) + let encrypted_buf = encrypt_aes256_hmac(&initial_buf, key.mac_key.unwrap(), key.key) .unwrap() .to_buffer() .unwrap();