bitwarden_uniffi/tool/
ssh.rs1use bitwarden_vault::SshKeyView;
2
3use crate::{
4 error::{BitwardenError, Error},
5 Result,
6};
7
8#[derive(uniffi::Object)]
9pub struct SshClient();
10
11#[uniffi::export]
12impl SshClient {
13 pub fn generate_ssh_key(
14 &self,
15 key_algorithm: bitwarden_ssh::generator::KeyAlgorithm,
16 ) -> Result<SshKeyView> {
17 bitwarden_ssh::generator::generate_sshkey(key_algorithm)
18 .map_err(|e| BitwardenError::E(Error::SshGeneration(e)))
19 }
20
21 pub fn import_ssh_key(
22 &self,
23 imported_key: String,
24 password: Option<String>,
25 ) -> Result<SshKeyView> {
26 bitwarden_ssh::import::import_key(imported_key, password)
27 .map_err(|e| BitwardenError::E(Error::SshImport(e)))
28 }
29}