Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ tempfile = "3.26"
tokio = { version = "1.52", default-features = false }
tracing = "0.1"
tracing-subscriber = "0.3"
zbus = { version = "5.14.0", default-features = false }
zbus_macros = { version = "5.11", features = ["gvariant"] }
zbus = { version = "5.19", default-features = false }
zgvariant = { version = "1.0", features = ["serde_bytes"] }
zbus_macros = { version = "5.19", features = ["gvariant"] }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to explicitly declare this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is needed, which is kinda annoying since we do not really use zbus_macros here.

zeroize = { version = "1", features = ["zeroize_derive"] }
zvariant = { version = "5.8", default-features = false, features = ["gvariant", "serde_bytes"] }
zvariant = { version = "5.14", default-features = false, features = ["gvariant", "serde_bytes"] }
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ tokio = { workspace = true, features = [
"io-util",
], optional = true, default-features = false }
tracing = { workspace = true, optional = true }
zgvariant.workspace = true
zbus.workspace = true
zbus_macros.workspace = true
zvariant.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion client/src/file/api/encrypted_item.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use serde::{Deserialize, Serialize};
use zbus::zvariant::Type;
use zeroize::{Zeroize, ZeroizeOnDrop};
use zgvariant::Type;

use super::{Error, UnlockedItem};
use crate::{AsAttributes, Key, Mac, crypto};
Expand Down
8 changes: 4 additions & 4 deletions client/src/file/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use futures_lite::AsyncWriteExt;
use serde::{Deserialize, Serialize};
#[cfg(feature = "tokio")]
use tokio::{fs, io, io::AsyncWriteExt};
use zbus::zvariant::{Endian, Type, serialized::Context};
use zgvariant::{Type, serialized::Context};

/// Used for newly created [`Keyring`]s
const DEFAULT_ITERATION_COUNT: u32 = 100000;
Expand Down Expand Up @@ -65,7 +65,7 @@ pub(crate) fn data_dir() -> Option<PathBuf> {
}

pub(crate) static GVARIANT_ENCODING: LazyLock<Context> =
LazyLock::new(|| Context::new_gvariant(Endian::Little, 0));
LazyLock::new(|| Context::new(zgvariant::LE, 0));

/// Logical contents of a keyring file
#[derive(Deserialize, Serialize, Type, Debug, Zeroize, ZeroizeOnDrop)]
Expand Down Expand Up @@ -257,7 +257,7 @@ impl Keyring {

blob.push(MAJOR_VERSION);
blob.push(MINOR_VERSION);
blob.append(&mut zvariant::to_bytes(*GVARIANT_ENCODING, &self)?.to_vec());
blob.append(&mut zgvariant::to_bytes(*GVARIANT_ENCODING, &self)?.to_vec());

Ok(blob)
}
Expand Down Expand Up @@ -373,7 +373,7 @@ impl TryFrom<&[u8]> for Keyring {
}

if let Some(data) = value.get((FILE_HEADER_LEN + 2)..) {
let keyring: Self = zvariant::serialized::Data::new(data, *GVARIANT_ENCODING)
let keyring: Self = zgvariant::serialized::Data::new(data, *GVARIANT_ENCODING)
.deserialize()?
.0;

Expand Down
6 changes: 3 additions & 3 deletions client/src/file/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub enum Error {
/// No Parent directory.
NoParentDir(String),
/// Bytes don't have the expected GVariant format.
GVariantDeserialization(zvariant::Error),
GVariantDeserialization(zgvariant::Error),
/// Mismatch between array length and length explicitly stored in keyring
SaltSizeMismatch(usize, u32),
/// Key for some reason too weak to trust it for writing
Expand Down Expand Up @@ -51,8 +51,8 @@ pub enum Error {
Schema(crate::SchemaError),
}

impl From<zvariant::Error> for Error {
fn from(value: zvariant::Error) -> Self {
impl From<zgvariant::Error> for Error {
fn from(value: zgvariant::Error) -> Self {
Self::GVariantDeserialization(value)
}
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/file/unlocked_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{AsAttributes, CONTENT_TYPE_ATTRIBUTE, Key, Mac, Secret, crypto, secr

/// An item stored in the file backend.
#[derive(
Deserialize, Serialize, zvariant::Type, Clone, Debug, Zeroize, ZeroizeOnDrop, PartialEq,
Deserialize, Serialize, zgvariant::Type, Clone, Debug, Zeroize, ZeroizeOnDrop, PartialEq,
)]
pub struct UnlockedItem {
#[zeroize(skip)]
Expand Down Expand Up @@ -182,7 +182,7 @@ impl UnlockedItem {
}

fn encrypt_plaintext(&self) -> Result<EncryptedItem, Error> {
let blob = zvariant::to_bytes(*GVARIANT_ENCODING, &self)?.to_vec();
let blob = zgvariant::to_bytes(*GVARIANT_ENCODING, &self)?.to_vec();
Ok(EncryptedItem {
hashed_attributes: self
.attributes
Expand All @@ -194,7 +194,7 @@ impl UnlockedItem {
}

fn encrypt_encrypted(&self, key: &Key, iv: &[u8]) -> Result<EncryptedItem, Error> {
let decrypted = Zeroizing::new(zvariant::to_bytes(*GVARIANT_ENCODING, &self)?.to_vec());
let decrypted = Zeroizing::new(zgvariant::to_bytes(*GVARIANT_ENCODING, &self)?.to_vec());

let mut blob = crypto::encrypt(&*decrypted, key, iv)?;

Expand All @@ -219,7 +219,7 @@ impl TryFrom<&[u8]> for UnlockedItem {
type Error = Error;

fn try_from(value: &[u8]) -> Result<Self, Error> {
let mut item: UnlockedItem = zvariant::serialized::Data::new(value, *GVARIANT_ENCODING)
let mut item: UnlockedItem = zgvariant::serialized::Data::new(value, *GVARIANT_ENCODING)
.deserialize()?
.0;

Expand Down
2 changes: 1 addition & 1 deletion client/src/mac.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::{Deserialize, Serialize};
#[cfg(feature = "native_crypto")]
use subtle::ConstantTimeEq;
use zbus::zvariant::Type;
use zeroize::{Zeroize, ZeroizeOnDrop};
use zgvariant::Type;

// There is no constructor to avoid performing sanity checks, e.g. length.
/// A message authentication code. It provides constant-time comparison when
Expand Down
Loading