diff --git a/.gitignore b/.gitignore index affc478..cae93cd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ target/ venv/ __pycache__ .pytest_cache -.idea/** \ No newline at end of file +.idea/** +.DS_Store \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 43808f4..8dbd648 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -435,7 +435,7 @@ dependencies = [ "derive_builder", "dirs", "enum_dispatch", - "getrandom", + "getrandom 0.3.1", "hex", "hmac", "md-5", @@ -707,7 +707,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets 0.52.0", ] [[package]] @@ -980,7 +992,7 @@ dependencies = [ "hermit-abi", "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -1210,7 +1222,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -1250,7 +1262,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom", + "getrandom 0.2.15", "redox_syscall", "thiserror", ] @@ -1757,6 +1769,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wayland-client" version = "0.29.5" @@ -2061,6 +2082,15 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "x11-clipboard" version = "0.7.0" diff --git a/Cargo.toml b/Cargo.toml index 3970261..1206a6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ hmac = "0.12.1" sha1 = "0.10.6" sha2 = "0.10.8" chacha20poly1305 = "0.10.1" -getrandom = "0.2.15" +getrandom = "0.3.1" rust-argon2 = "2.1.0" scrypt = "0.11.0" aes-gcm = "0.10.3" diff --git a/src/crypto/cryptography.rs b/src/crypto/cryptography.rs index 8eabd6c..cf336e6 100644 --- a/src/crypto/cryptography.rs +++ b/src/crypto/cryptography.rs @@ -26,7 +26,7 @@ pub fn argon_derive_key(password_bytes: &[u8], salt: &[u8]) -> color_eyre::Resul pub fn gen_salt() -> color_eyre::Result<[u8; ARGON2ID_SALT_LENGTH]> { let mut salt: [u8; ARGON2ID_SALT_LENGTH] = [0; ARGON2ID_SALT_LENGTH]; - getrandom::getrandom(&mut salt).map_err(ErrReport::from)?; + getrandom::fill(&mut salt).map_err(|e| eyre!(e))?; Ok(salt) } @@ -41,7 +41,7 @@ pub fn encrypt_string_with_key( let mut nonce_bytes: [u8; XCHACHA20_POLY1305_NONCE_LENGTH] = [0; XCHACHA20_POLY1305_NONCE_LENGTH]; - getrandom::getrandom(&mut nonce_bytes).map_err(ErrReport::from)?; + getrandom::fill(&mut nonce_bytes).map_err(|e| eyre!(e))?; let nonce = XNonce::from_slice(&nonce_bytes); let cipher_text = aead diff --git a/src/interface/app.rs b/src/interface/app.rs index b68dda5..816f3e8 100644 --- a/src/interface/app.rs +++ b/src/interface/app.rs @@ -265,10 +265,12 @@ impl<'a> App<'a> { ) .highlight_symbol("-> "); - let selected_element = match self.table.state.selected() { - Some(index) => self.database.get_element(index), - None => None, - }; + let selected_element = self + .table + .state + .selected() + .and_then(|i| self.database.get_element(i)); + let mut text = if let Some(element) = selected_element { format!( "