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
869 changes: 501 additions & 368 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords = ["password-manager", "pass"]
version = "0.7.0-alpha"
authors = ["Joakim Lundborg <[email protected]>", "Alexander Kjäll <[email protected]>"]
license = "GPL-3.0-only"
edition = '2021'
edition = '2024'

[dependencies]
arboard = "3"
Expand Down
2 changes: 1 addition & 1 deletion benches/library_benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fs::File, path::PathBuf};

use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use flate2::read::GzDecoder;
use ripasso::{crypto::CryptoImpl, pass};
use tar::Archive;
Expand Down
2 changes: 1 addition & 1 deletion cursive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ categories = ["command-line-utilities"]
version = "0.7.0-alpha"
authors = ["Joakim Lundborg <[email protected]>", "Alexander Kjäll <[email protected]>"]
license = "GPL-3.0-only"
edition = '2021'
edition = '2024'
build = "build.rs"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion cursive/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use std::sync::{Arc, Mutex};

use arboard::Clipboard;
use cursive::{
Cursive,
event::Key,
views::{Checkbox, Dialog, EditView, OnEventView, RadioButton, TextView},
Cursive,
};
use lazy_static::lazy_static;
use pass::Result;
Expand Down
4 changes: 2 additions & 2 deletions cursive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use std::{
};

use cursive::{
Cursive, CursiveExt,
direction::Orientation,
event::{Event, Key},
menu::Tree,
Expand All @@ -31,7 +32,6 @@ use cursive::{
Checkbox, CircularFocus, Dialog, EditView, LinearLayout, NamedView, OnEventView,
RadioGroup, ResizedView, ScrollView, SelectView, TextArea, TextView,
},
Cursive, CursiveExt,
};
use hex::FromHex;
use pass::Result;
Expand All @@ -40,7 +40,7 @@ use ripasso::{
git::{pull, push},
pass,
pass::{
all_recipients_from_stores, OwnerTrustLevel, PasswordStore, Recipient, SignatureStatus,
OwnerTrustLevel, PasswordStore, Recipient, SignatureStatus, all_recipients_from_stores,
},
};
use unic_langid::LanguageIdentifier;
Expand Down
7 changes: 6 additions & 1 deletion cursive/src/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ fn render_recipient_label_ultimate() {

let result = render_recipient_label(&r, 20, 20);

assert_eq!(String::from(" \u{fe0f} 1D108E6C07CBC406 Alexander Kjäll <[email protected]> Ultimate Usable "), result);
assert_eq!(
String::from(
" \u{fe0f} 1D108E6C07CBC406 Alexander Kjäll <[email protected]> Ultimate Usable "
),
result
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion cursive/src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
use std::path::PathBuf;

use cursive::{
Cursive, CursiveExt,
direction::Orientation,
event::Key,
traits::*,
views::{Dialog, EditView, LinearLayout, OnEventView, SelectView, TextView},
Cursive, CursiveExt,
};
use ripasso::{crypto::CryptoImpl, git::init_git_repo, pass};

Expand Down
2 changes: 1 addition & 1 deletion gtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "ripasso-gtk"
version = "0.7.0-alpha"
authors = ["Joakim Lundborg <[email protected]>", "Alexander Kjäll <[email protected]>"]
edition = "2021"
edition = "2024"


[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/collection_object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ripasso::pass::{PasswordEntry, PasswordStore};

use crate::{
password_object::PasswordObject,
utils::{error_dialog, PasswordStoreBoxed},
utils::{PasswordStoreBoxed, error_dialog},
};

glib::wrapper! {
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/password_object/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use gtk::glib;
use once_cell::sync::Lazy;
use ripasso::pass::{PasswordEntry, PasswordStore};

use crate::utils::{error_dialog_standalone, PasswordStoreBoxed};
use crate::utils::{PasswordStoreBoxed, error_dialog_standalone};

// Object holding the state
#[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/password_object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use glib::Object;
use gtk::glib;
use ripasso::pass::{Error, PasswordEntry, PasswordStore};

use crate::utils::{error_dialog_standalone, PasswordStoreBoxed};
use crate::utils::{PasswordStoreBoxed, error_dialog_standalone};

glib::wrapper! {
pub struct PasswordObject(ObjectSubclass<imp::PasswordObject>);
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::{Arc, Mutex};

use adw::prelude::{DialogExt, GtkWindowExt, WidgetExt};
use gtk::{prelude::IsA, MessageDialog};
use gtk::{MessageDialog, prelude::IsA};
use ripasso::pass::{Error, PasswordStore};

#[derive(Clone, glib::SharedBoxed)]
Expand Down
8 changes: 4 additions & 4 deletions gtk/src/window/imp.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{cell::RefCell, path::PathBuf};

use adw::{subclass::prelude::*, Leaflet};
use glib::{subclass::InitializingObject, Propagation};
use adw::{Leaflet, subclass::prelude::*};
use glib::{Propagation, subclass::InitializingObject};
use gtk::{
gio, glib, glib::SignalHandlerId, Button, CompositeTemplate, Entry, FilterListModel, ListBox,
Stack,
Button, CompositeTemplate, Entry, FilterListModel, ListBox, Stack, gio, glib,
glib::SignalHandlerId,
};
use once_cell::sync::OnceCell;

Expand Down
8 changes: 4 additions & 4 deletions gtk/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use std::{
sync::{Arc, Mutex},
};

use adw::{prelude::*, subclass::prelude::*, ActionRow, NavigationDirection};
use glib::{clone, Object};
use adw::{ActionRow, NavigationDirection, prelude::*, subclass::prelude::*};
use glib::{Object, clone};
use gtk::{
gio, glib, glib::BindingFlags, pango, AboutDialog, CustomFilter, Dialog, DialogFlags, Entry,
FilterListModel, Label, ListBox, ListBoxRow, NoSelection, ResponseType, SelectionMode,
AboutDialog, CustomFilter, Dialog, DialogFlags, Entry, FilterListModel, Label, ListBox,
ListBoxRow, NoSelection, ResponseType, SelectionMode, gio, glib, glib::BindingFlags, pango,
};
use hex::FromHex;
use ripasso::{crypto::CryptoImpl, pass::PasswordStore};
Expand Down
8 changes: 4 additions & 4 deletions src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ use std::{

use hex::FromHex;
use sequoia_openpgp::{
Cert, KeyHandle,
crypto::SessionKey,
parse::{
Parse,
stream::{
DecryptionHelper, DecryptorBuilder, DetachedVerifierBuilder, MessageLayer,
MessageStructure, VerificationHelper,
},
Parse,
},
policy::Policy,
serialize::{
stream::{Armorer, Encryptor2, LiteralWriter, Message, Signer},
Serialize,
stream::{Armorer, Encryptor2, LiteralWriter, Message, Signer},
},
types::{RevocationStatus, SymmetricAlgorithm},
Cert, KeyHandle,
};
use zeroize::Zeroize;

Expand Down Expand Up @@ -682,7 +682,7 @@ impl Sequoia {
return Err(Error::GenericDyn(format!(
"Recipient with key id {} not found",
recipient.key_id
)))
)));
}
},
None => {
Expand Down
20 changes: 15 additions & 5 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use git2::{Oid, Repository};
use crate::{
crypto::{Crypto, FindSigningFingerprintStrategy, VerificationError},
error::{Error, Result},
pass::{to_result, PasswordEntry, PasswordStore, RepositoryStatus},
pass::{PasswordEntry, PasswordStore, RepositoryStatus, to_result},
signature::SignatureStatus,
};

Expand Down Expand Up @@ -405,13 +405,23 @@ pub fn verify_git_signature(
"signature not checked as PASSWORD_STORE_SIGNING_KEY is not configured",
));
}
match store.get_crypto().verify_sign(&signed_data_str.into_bytes(), &signature_str.into_bytes(), store.get_valid_gpg_signing_keys()) {
match store.get_crypto().verify_sign(
&signed_data_str.into_bytes(),
&signature_str.into_bytes(),
store.get_valid_gpg_signing_keys(),
) {
Ok(r) => Ok(r),
Err(VerificationError::InfrastructureError(message)) => Err(Error::GenericDyn(message)),
Err(VerificationError::SignatureFromWrongRecipient) => Err(Error::Generic("the commit wasn't signed by one of the keys specified in the environmental variable PASSWORD_STORE_SIGNING_KEY")),
Err(VerificationError::SignatureFromWrongRecipient) => Err(Error::Generic(
"the commit wasn't signed by one of the keys specified in the environmental variable PASSWORD_STORE_SIGNING_KEY",
)),
Err(VerificationError::BadSignature) => Err(Error::Generic("Bad signature for commit")),
Err(VerificationError::MissingSignatures) => Err(Error::Generic("Missing signature for commit")),
Err(VerificationError::TooManySignatures) => Err(Error::Generic("If a git commit contains more than one signature, something is fishy")),
Err(VerificationError::MissingSignatures) => {
Err(Error::Generic("Missing signature for commit"))
}
Err(VerificationError::TooManySignatures) => Err(Error::Generic(
"If a git commit contains more than one signature, something is fishy",
)),
}
}

Expand Down
83 changes: 56 additions & 27 deletions src/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use std::{
collections::HashMap,
fs,
fs::{create_dir_all, File},
fs::{File, create_dir_all},
io::prelude::*,
path::{Path, PathBuf},
str,
Expand All @@ -38,9 +38,9 @@ use crate::{
},
};
pub use crate::{
error::{to_result, Error, Result},
error::{Error, Result, to_result},
signature::{
parse_signing_keys, Comment, KeyRingStatus, OwnerTrustLevel, Recipient, SignatureStatus,
Comment, KeyRingStatus, OwnerTrustLevel, Recipient, SignatureStatus, parse_signing_keys,
},
};

Expand Down Expand Up @@ -258,27 +258,45 @@ impl PasswordStore {
gpg_id_sig_file.push(".gpg-id.sig");

let gpg_id = fs::read(gpg_id_file)?;
let gpg_id_sig =
match fs::read(gpg_id_sig_file) {
Ok(c) => c,
Err(_) => return Err(Error::Generic(
let gpg_id_sig = match fs::read(gpg_id_sig_file) {
Ok(c) => c,
Err(_) => {
return Err(Error::Generic(
"problem reading .gpg-id.sig, and strict signature checking was asked for",
)),
};
));
}
};

match self.crypto.verify_sign(&gpg_id, &gpg_id_sig, &self.valid_gpg_signing_keys) {
Ok(r) => {
match r {
SignatureStatus::Good => {},
SignatureStatus::AlmostGood => result = SignatureStatus::AlmostGood,
SignatureStatus::Bad => return Ok(SignatureStatus::Bad)
}
match self
.crypto
.verify_sign(&gpg_id, &gpg_id_sig, &self.valid_gpg_signing_keys)
{
Ok(r) => match r {
SignatureStatus::Good => {}
SignatureStatus::AlmostGood => result = SignatureStatus::AlmostGood,
SignatureStatus::Bad => return Ok(SignatureStatus::Bad),
},
Err(VerificationError::InfrastructureError(message)) => return Err(Error::GenericDyn(message)),
Err(VerificationError::SignatureFromWrongRecipient) => return Err(Error::Generic("the .gpg-id file wasn't signed by one of the keys specified in the environmental variable PASSWORD_STORE_SIGNING_KEY")),
Err(VerificationError::BadSignature) => return Err(Error::Generic("Bad signature for .gpg-id file")),
Err(VerificationError::MissingSignatures) => return Err(Error::Generic("Missing signature for .gpg-id file, and PASSWORD_STORE_SIGNING_KEY specified")),
Err(VerificationError::TooManySignatures) => return Err(Error::Generic("Signature for .gpg-id file contained more than one signature, something is fishy")),
Err(VerificationError::InfrastructureError(message)) => {
return Err(Error::GenericDyn(message));
}
Err(VerificationError::SignatureFromWrongRecipient) => {
return Err(Error::Generic(
"the .gpg-id file wasn't signed by one of the keys specified in the environmental variable PASSWORD_STORE_SIGNING_KEY",
));
}
Err(VerificationError::BadSignature) => {
return Err(Error::Generic("Bad signature for .gpg-id file"));
}
Err(VerificationError::MissingSignatures) => {
return Err(Error::Generic(
"Missing signature for .gpg-id file, and PASSWORD_STORE_SIGNING_KEY specified",
));
}
Err(VerificationError::TooManySignatures) => {
return Err(Error::Generic(
"Signature for .gpg-id file contained more than one signature, something is fishy",
));
}
}
}
Ok(result)
Expand All @@ -298,17 +316,28 @@ impl PasswordStore {
Err(_) => {
return Err(Error::Generic(
"problem reading .gpg-id.sig, and strict signature checking was asked for",
))
));
}
};

match self.crypto.verify_sign(&gpg_id, &gpg_id_sig, &self.valid_gpg_signing_keys) {
match self
.crypto
.verify_sign(&gpg_id, &gpg_id_sig, &self.valid_gpg_signing_keys)
{
Ok(r) => Ok(r),
Err(VerificationError::InfrastructureError(message)) => Err(Error::GenericDyn(message)),
Err(VerificationError::SignatureFromWrongRecipient) => Err(Error::Generic("the .gpg-id file wasn't signed by one of the keys specified in the environmental variable PASSWORD_STORE_SIGNING_KEY")),
Err(VerificationError::BadSignature) => Err(Error::Generic("Bad signature for .gpg-id file")),
Err(VerificationError::MissingSignatures) => Err(Error::Generic("Missing signature for .gpg-id file, and PASSWORD_STORE_SIGNING_KEY specified")),
Err(VerificationError::TooManySignatures) => Err(Error::Generic("Signature for .gpg-id file contained more than one signature, something is fishy")),
Err(VerificationError::SignatureFromWrongRecipient) => Err(Error::Generic(
"the .gpg-id file wasn't signed by one of the keys specified in the environmental variable PASSWORD_STORE_SIGNING_KEY",
)),
Err(VerificationError::BadSignature) => {
Err(Error::Generic("Bad signature for .gpg-id file"))
}
Err(VerificationError::MissingSignatures) => Err(Error::Generic(
"Missing signature for .gpg-id file, and PASSWORD_STORE_SIGNING_KEY specified",
)),
Err(VerificationError::TooManySignatures) => Err(Error::Generic(
"Signature for .gpg-id file contained more than one signature, something is fishy",
)),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/tests/crypto.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{collections::HashMap, sync::Arc};

use hex::FromHex;
use sequoia_openpgp::{cert::CertBuilder, parse::Parse, serialize::Serialize, Cert};
use sequoia_openpgp::{Cert, cert::CertBuilder, parse::Parse, serialize::Serialize};
use tempfile::tempdir;

use crate::{
crypto::{slice_to_20_bytes, Crypto, CryptoImpl, Sequoia},
crypto::{Crypto, CryptoImpl, Sequoia, slice_to_20_bytes},
signature::Recipient,
};

Expand Down
Loading
Loading