Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
crypto: Improve error for missing passphrase
Alexis Sellier committed 2 years ago
commit 60cc0a8d01881c11b35263b3be91b63c98ffb4a1
parent de381cb378f45f8cce3dbf99d1b72c360dc095b2
1 file changed +4 -0
modified radicle-crypto/src/ssh/keystore.rs
@@ -23,6 +23,8 @@ pub enum Error {
    InvalidKeyType,
    #[error("keystore already initialized")]
    AlreadyInitialized,
+
    #[error("keystore is encrypted; a passphrase is required")]
+
    PassphraseMissing,
}

impl Error {
@@ -123,6 +125,8 @@ impl Keystore {
        let secret = ssh_key::PrivateKey::read_openssh_file(&path)?;
        let secret = if let Some(p) = passphrase {
            secret.decrypt(p)?
+
        } else if secret.is_encrypted() {
+
            return Err(Error::PassphraseMissing);
        } else {
            secret
        };