Skip to main content

bitwarden_uniffi/tool/
ssh.rs

1use bitwarden_vault::SshKeyView;
2
3use crate::Result;
4
5#[derive(uniffi::Object)]
6pub struct SshClient();
7
8#[uniffi::export]
9impl SshClient {
10    pub fn generate_ssh_key(
11        &self,
12        key_algorithm: bitwarden_ssh::generator::KeyAlgorithm,
13    ) -> Result<SshKeyView> {
14        bitwarden_ssh::generator::generate_sshkey(key_algorithm)
15            .map(Into::into)
16            .map_err(Into::into)
17    }
18
19    pub fn import_ssh_key(
20        &self,
21        imported_key: String,
22        password: Option<String>,
23    ) -> Result<SshKeyView> {
24        bitwarden_ssh::import::import_key(imported_key, password)
25            .map(Into::into)
26            .map_err(Into::into)
27    }
28}