-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Recovery Phrase / Alternate Password #272
base: main
Are you sure you want to change the base?
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 <[email protected]>
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think correct is to_entropy
@@ -223,11 +232,19 @@ async fn async_main() -> Result<()> { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.