Skip to content
Merged
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
46 changes: 36 additions & 10 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ 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"] }
zeroize = { version = "1", features = ["zeroize_derive"] }
zvariant = { version = "5.8", default-features = false, features = ["gvariant", "serde_bytes"] }
3 changes: 1 addition & 2 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ 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
zeroize.workspace = true

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion client/src/dbus/algorithm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use zbus::zvariant;

#[derive(Debug, zvariant::Type, PartialEq, Eq, Copy, Clone)]
#[zvariant(signature = "s")]
Expand Down Expand Up @@ -43,7 +44,7 @@ impl<'de> Deserialize<'de> for Algorithm {

#[cfg(test)]
mod tests {
use zvariant::{Endian, serialized::Context, to_bytes};
use zbus::zvariant::{Endian, serialized::Context, to_bytes};

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions client/src/dbus/api/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::{
Deserialize,
ser::{Serialize, SerializeMap},
};
use zbus::zvariant::{Type, Value};
use zbus::zvariant::{self, Type, Value};

use crate::AsAttributes;

Expand Down Expand Up @@ -164,7 +164,7 @@ mod tests {

#[test]
fn deserialize_item_properties() {
use zvariant::Dict;
use zbus::zvariant::Dict;

// Create serialized data that represents item properties
let mut attrs_dict = Dict::new(String::SIGNATURE, String::SIGNATURE);
Expand Down
2 changes: 1 addition & 1 deletion client/src/dbus/api/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{collections::HashMap, fmt};

use ashpd::WindowIdentifier;
use futures_util::{Stream, StreamExt};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::zvariant::{self, ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};

use super::{
Collection, DBusSecret, DESTINATION, Item, PATH, Prompt, Properties, Session, Unlockable,
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
1 change: 1 addition & 0 deletions client/src/key.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use zbus::zvariant;
use zeroize::{Zeroize, ZeroizeOnDrop};

use crate::{crypto, file};
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
3 changes: 2 additions & 1 deletion client/src/secret.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::str::FromStr;

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

#[derive(Default, PartialEq, Eq, Copy, Clone, Debug, zvariant::Type)]
Expand Down Expand Up @@ -211,7 +212,7 @@ impl AsRef<[u8]> for Secret {

#[cfg(test)]
mod tests {
use zvariant::{Endian, serialized::Context, to_bytes};
use zbus::zvariant::{Endian, serialized::Context, to_bytes};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion pam/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tracing.workspace = true
tracing-journald = "0.3"
tracing-subscriber = { workspace = true, features = ["env-filter"] }
zeroize.workspace = true
zvariant.workspace = true
zgvariant.workspace = true

[dev-dependencies]
tempfile.workspace = true
Expand Down
18 changes: 9 additions & 9 deletions pam/src/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use zeroize::{Zeroize, ZeroizeOnDrop};
use zvariant::{Type, serialized::Context, to_bytes};
use zgvariant::{Type, serialized::Context, to_bytes};

#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, Type, PartialEq, Eq)]
#[repr(u8)]
Expand Down Expand Up @@ -40,15 +40,15 @@ impl PamMessage {
}
}

pub fn to_bytes(&self) -> Result<Vec<u8>, zvariant::Error> {
let ctxt = Context::new_dbus(zvariant::LE, 0);
pub fn to_bytes(&self) -> Result<Vec<u8>, zgvariant::Error> {
let ctxt = Context::new(zgvariant::LE, 0);
to_bytes(ctxt, self).map(|data| data.to_vec())
}

#[cfg(test)]
pub fn from_bytes(bytes: &[u8]) -> Result<Self, zvariant::Error> {
let ctxt = Context::new_dbus(zvariant::LE, 0);
let data = zvariant::serialized::Data::new(bytes, ctxt);
pub fn from_bytes(bytes: &[u8]) -> Result<Self, zgvariant::Error> {
let ctxt = Context::new(zgvariant::LE, 0);
let data = zgvariant::serialized::Data::new(bytes, ctxt);
data.deserialize().map(|(msg, _)| msg)
}
}
Expand All @@ -60,9 +60,9 @@ pub struct PamResponse {
}

impl PamResponse {
pub fn from_bytes(bytes: &[u8]) -> Result<Self, zvariant::Error> {
let ctxt = Context::new_dbus(zvariant::LE, 0);
let data = zvariant::serialized::Data::new(bytes, ctxt);
pub fn from_bytes(bytes: &[u8]) -> Result<Self, zgvariant::Error> {
let ctxt = Context::new(zgvariant::LE, 0);
let data = zgvariant::serialized::Data::new(bytes, ctxt);
data.deserialize().map(|(msg, _)| msg)
}
}
2 changes: 1 addition & 1 deletion pam/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Drop for SavedSignals {
pub enum SocketError {
Connect(io::Error),
Send(io::Error),
Serialize(zvariant::Error),
Serialize(zgvariant::Error),
Timeout,
InvalidSocket(String),
}
Expand Down
1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ tracing.workspace = true
tracing-subscriber.workspace = true
zbus = { workspace = true, features = ["p2p"] }
zeroize.workspace = true
zgvariant.workspace = true

[features]
test-util = ["dep:tempfile"]
Expand Down
Loading
Loading