Skip to content

Commit a212ebe

Browse files
A6GibKmbilelmoussaoui
authored andcommitted
client: Stop giving mac as Zeroizing
A mac does not contain sensitive data (no more than a hash at least), it does not need zeroizing on drop.
1 parent fa669e1 commit a212ebe

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

client/src/file/api/attribute_value.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use serde::{Deserialize, Serialize};
22
use zbus::zvariant::Type;
3-
use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing};
3+
use zeroize::{Zeroize, ZeroizeOnDrop};
44

55
use crate::{Key, crypto};
66

@@ -9,8 +9,8 @@ use crate::{Key, crypto};
99
pub struct AttributeValue(String);
1010

1111
impl AttributeValue {
12-
pub(crate) fn mac(&self, key: &Key) -> Result<Zeroizing<Vec<u8>>, crate::crypto::Error> {
13-
Ok(Zeroizing::new(crypto::compute_mac(self.0.as_bytes(), key)?))
12+
pub(crate) fn mac(&self, key: &Key) -> Result<Vec<u8>, crate::crypto::Error> {
13+
crypto::compute_mac(self.0.as_bytes(), key)
1414
}
1515
}
1616

client/src/file/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Item {
154154
let hashed_attributes = self
155155
.attributes
156156
.iter()
157-
.filter_map(|(k, v)| Some((k.to_owned(), v.mac(key).ok()?.as_slice().into())))
157+
.filter_map(|(k, v)| Some((k.to_owned(), v.mac(key).ok()?)))
158158
.collect();
159159

160160
Ok(EncryptedItem {

client/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ pub trait AsAttributes {
6363
fn hash<'a>(
6464
&'a self,
6565
key: &Key,
66-
) -> Vec<(
67-
&'a str,
68-
std::result::Result<zeroize::Zeroizing<Vec<u8>>, crate::crypto::Error>,
69-
)> {
66+
) -> Vec<(&'a str, std::result::Result<Vec<u8>, crate::crypto::Error>)> {
7067
self.as_attributes()
7168
.into_iter()
7269
.map(|(k, v)| (k, crate::file::AttributeValue::from(v).mac(key)))

0 commit comments

Comments
 (0)