Skip to content

Commit

Permalink
SecKey: Add SecKeyCreateWithData()
Browse files Browse the repository at this point in the history
  • Loading branch information
crashdump committed Dec 13, 2024
1 parent 0712259 commit 5956011
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions security-framework-sys/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ extern "C" {
#[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
pub fn SecKeyCreateRandomKey(parameters: CFDictionaryRef, error: *mut CFErrorRef) -> SecKeyRef;

#[cfg(any(feature = "OSX_10_13", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
pub fn SecKeyCreateWithData(
keyData: CFDataRef,
attributes: CFDictionaryRef,
error: *mut CFErrorRef,
) -> SecKeyRef;

#[cfg(target_os = "macos")]
pub fn SecKeyCreateFromData(
parameters: CFDictionaryRef,
Expand Down
9 changes: 9 additions & 0 deletions security-framework/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ impl KeyType {
unsafe { Self(kSecAttrKeyTypeEC) }
}

#[inline(always)]
#[must_use]
pub fn ec_sec_prime_random() -> Self {
use security_framework_sys::item::kSecAttrKeyTypeECSECPrimeRandom;

unsafe { Self(kSecAttrKeyTypeECSECPrimeRandom) }
}


pub(crate) fn to_str(self) -> CFString {
unsafe { CFString::wrap_under_get_rule(self.0) }
}
Expand Down

0 comments on commit 5956011

Please sign in to comment.