Recovery Phrase / Alternate Password#272
Conversation
|
I admit we need to refactor the code. Was just writing out the logic. Another issue I see in the code is that the recovery key is display everytime the application is mounted and user enters the password. Need to fix that as well. |
Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
|
@radumarias Do we include (salt + user password) as an input to bip39 crate to generate recovery phrase? |
@Hrushi20 is this fixed now? |
| use strum_macros::EnumIter; | ||
|
|
||
| pub fn generate_recovery_phrase(language: Language, password: &SecretString) -> Result<String> { | ||
| let recovery_phrase = bip39::Mnemonic::from_entropy_in(language.into(), &password.expose_secret().as_bytes())?; |
There was a problem hiding this comment.
as from docs https://docs.rs/bip39/2.1.0/bip39/struct.Mnemonic.html#method.from_entropy_in
Entropy must be a multiple of 32 bits (4 bytes) and 128-256 bits in length.
I assume you can't use the pass directly. You need to use KDF like https://github.com/xoriors/rencfs/blob/main/src/crypto.rs#L226 and a length of 256.
|
|
||
| // Can create a struct here. | ||
| pub fn mnemonic_to_password(mnemonic: &SecretString) -> Result<SecretString> { | ||
| let parsed_data = bip39::Mnemonic::parse_normalized(&mnemonic.expose_secret())?; |
|
|
||
| async fn run_change_password(cipher: Cipher, matches: &ArgMatches) -> Result<()> { | ||
| let data_dir: String = matches.get_one::<String>("data-dir").unwrap().to_string(); | ||
| let recovery_phrase = matches.get_one::<SecretString>("recovery-phrase"); |
There was a problem hiding this comment.
I know it's per specs, but it seems those were wrong. My bad.
It's not safe to pass credentials as args because those are visible in commands like ps aux. Instead, this should be a flag that indicates we read the recovery phrase from the keyboard (like we now read the password). If this is present, we will not read the password at all
Description
We need a way to recover the encryption key if the user loses the password. We use a recovery phrase generated when you define the password. In case the user forgets the password, he can use this to change it.
Fixes #249
Type of change
Please delete options that are not relevant.