Skip to content

Commit

Permalink
Add set_secret() and get_secret() for iOS impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpfs committed Jul 13, 2024
1 parent 808e8c7 commit 028e820
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ impl CredentialApi for IosCredential {
Ok(())
}

/// Create and write a credential with secret for this entry.
///
/// The new credential replaces any existing one in the store.
/// Since there is only one credential with a given _account_ and _user_
/// in any given keychain, there is no chance of ambiguity.
fn set_secret(&self, secret: &[u8]) -> Result<()> {
set_generic_password(&self.service, &self.account, secret).map_err(decode_error)?;
Ok(())
}

/// Look up the password for this entry, if any.
///
/// Returns a [NoEntry](ErrorCode::NoEntry) error if there is no
Expand All @@ -57,6 +67,14 @@ impl CredentialApi for IosCredential {
decode_password(password_bytes.to_vec())
}

/// Look up the secret for this entry, if any.
///
/// Returns a [NoEntry](ErrorCode::NoEntry) error if there is no
/// credential in the store.
fn get_secret(&self) -> Result<Vec<u8>> {
get_generic_password(&self.service, &self.account).map_err(decode_error)
}

/// Delete the underlying generic credential for this entry, if any.
///
/// Returns a [NoEntry](ErrorCode::NoEntry) error if there is no
Expand Down

0 comments on commit 028e820

Please sign in to comment.