Skip to content

V6 support #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 12 additions & 14 deletions cursive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ use cursive::{
RadioGroup, ResizedView, ScrollView, SelectView, TextArea, TextView,
},
};
use hex::FromHex;
use pass::Result;
use ripasso::{
crypto::CryptoImpl,
Expand All @@ -48,12 +47,12 @@ use unic_langid::LanguageIdentifier;
mod helpers;
mod wizard;

use lazy_static::lazy_static;
use zeroize::Zeroize;

use crate::helpers::{
get_value_from_input, is_checkbox_checked, is_radio_button_selected, recipients_widths,
};
use lazy_static::lazy_static;
use ripasso::crypto::Fingerprint;
use zeroize::Zeroize;

/// The 'pointer' to the current PasswordStore is of this convoluted type.
type PasswordStoreType = Arc<Mutex<Arc<Mutex<PasswordStore>>>>;
Expand Down Expand Up @@ -1383,13 +1382,9 @@ fn get_stores(config: &config::Config, home: &Option<PathBuf>) -> Result<Vec<Pas
}?;

let own_fingerprint = store.get("own_fingerprint");
let own_fingerprint = match own_fingerprint {
None => None,
Some(k) => match k.clone().into_string() {
Err(_) => None,
Ok(key) => <[u8; 20]>::from_hex(key).ok(),
},
};
let own_fingerprint = own_fingerprint
.map(|k| k.clone().into_string().map(|key| key.as_str().try_into())?)
.transpose()?;

final_stores.push(PasswordStore::new(
store_name,
Expand Down Expand Up @@ -1507,7 +1502,7 @@ fn save_edit_config(
false => CryptoImpl::GpgMe,
};

let own_fingerprint = <[u8; 20]>::from_hex(own_fingerprint).ok();
let own_fingerprint: Fingerprint = own_fingerprint.as_str().try_into()?;

let new_store = PasswordStore::new(
e_n,
Expand All @@ -1516,7 +1511,7 @@ fn save_edit_config(
home,
&None,
&pgp_impl,
&own_fingerprint,
&Some(own_fingerprint),
);
if let Err(err) = new_store {
helpers::errorbox(ui, &err);
Expand Down Expand Up @@ -1689,7 +1684,10 @@ fn edit_store_in_config(
fingerprint_fields.add_child(
EditView::new()
.content(hex::encode_upper(
store.get_crypto().own_fingerprint().unwrap_or([0; 20]),
store
.get_crypto()
.own_fingerprint()
.unwrap_or(Fingerprint::V4([0; 20])),
))
.with_name("edit_own_fingerprint_input")
.fixed_size((50_usize, 1_usize)),
Expand Down
6 changes: 3 additions & 3 deletions cursive/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cursive::{
views::{Checkbox, EditView, LinearLayout, RadioButton, RadioGroup},
};
use hex::FromHex;
use ripasso::crypto::CryptoImpl;
use ripasso::crypto::{CryptoImpl, Fingerprint};
use ripasso::pass::{Comment, KeyRingStatus, OwnerTrustLevel, Recipient};

#[test]
Expand Down Expand Up @@ -100,9 +100,9 @@ pub fn recipient_alex() -> Recipient {
post_comment: None,
},
key_id: "1D108E6C07CBC406".to_owned(),
fingerprint: Some(
fingerprint: Some(Fingerprint::V4(
<[u8; 20]>::from_hex("7E068070D5EF794B00C8A9D91D108E6C07CBC406").unwrap(),
),
)),
key_ring_status: KeyRingStatus::InKeyRing,
trust_level: OwnerTrustLevel::Ultimate,
not_usable: false,
Expand Down
5 changes: 3 additions & 2 deletions cursive/src/tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{fs::File, io::Write};

use chrono::Local;
use hex::FromHex;
use ripasso::pass::{PasswordEntry, RepositoryStatus};
use tempfile::tempdir;

Expand Down Expand Up @@ -168,9 +169,9 @@ fn render_recipient_label_ultimate() {
post_comment: None,
},
key_id: "1D108E6C07CBC406".to_owned(),
fingerprint: Some(
fingerprint: Some(Fingerprint::V4(
<[u8; 20]>::from_hex("7E068070D5EF794B00C8A9D91D108E6C07CBC406").unwrap(),
),
)),
key_ring_status: pass::KeyRingStatus::InKeyRing,
trust_level: OwnerTrustLevel::Ultimate,
not_usable: false,
Expand Down
15 changes: 5 additions & 10 deletions gtk/src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ use std::{
sync::{Arc, Mutex},
};

use crate::{collection_object::CollectionObject, password_object::PasswordObject};
use adw::{ActionRow, NavigationDirection, prelude::*, subclass::prelude::*};
use glib::{Object, clone};
use gtk::{
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};

use crate::{collection_object::CollectionObject, password_object::PasswordObject};

glib::wrapper! {
pub struct Window(ObjectSubclass<imp::Window>)
@extends adw::ApplicationWindow, gtk::ApplicationWindow, gtk::Window, gtk::Widget,
Expand Down Expand Up @@ -580,13 +578,10 @@ fn get_stores(
}?;

let own_fingerprint = store.get("own_fingerprint");
let own_fingerprint = match own_fingerprint {
None => None,
Some(k) => match k.clone().into_string() {
Err(_) => None,
Ok(key) => <[u8; 20]>::from_hex(key).ok(),
},
};
let own_fingerprint = own_fingerprint
.map(|k| k.clone().into_string().map(|fp| fp.as_str().try_into()))
.transpose()?
.transpose()?;

final_stores.push(PasswordStore::new(
store_name,
Expand Down
Loading
Loading