diff --git a/Cargo.lock b/Cargo.lock index 7ee96d4..204a8e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,6 +164,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "keyutils 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", @@ -432,6 +433,15 @@ dependencies = [ "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rpassword" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rust-crypto" version = "0.2.36" @@ -629,6 +639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a" +"checksum rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f072d931f11a96546efd97642e1e75e807345aced86b947f9239102f262d0fcd" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" diff --git a/Cargo.toml b/Cargo.toml index 5af0c41..13007fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ serde_derive = "1.0.100" serde = "1.0.100" serde_json = "1.0.40" keyutils = "0.2.1" +rpassword = "4.0.1" [profile.release] diff --git a/src/cli.rs b/src/cli.rs index f18b042..ea0fbd2 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -88,9 +88,9 @@ pub fn add_key_to_luks(conf: &Config) -> Fido2LuksResult { luks::open(&conf.device.canonicalize()?) }; - let prev_key_info = ask_str( + let prev_key_info = rpassword::read_password_from_tty(Some( "Please enter your current password or path to a keyfile in order to add a new key: ", - )?; + ))?; let prev_key = match prev_key_info.as_ref() { "" => None, @@ -119,7 +119,6 @@ pub fn add_key_to_luks(conf: &Config) -> Fido2LuksResult { assemble_secret(&perform_challenge(&conf.credential_id, &salt)?, &salt) }; - dbg!("Adding key"); let slot = handle.add_keyslot(&secret, prev_key.as_ref().map(|b| b.as_slice()), None)?; Ok(slot) }