Skip to content

Commit 5956011

Browse files
committed
SecKey: Add SecKeyCreateWithData()
1 parent 0712259 commit 5956011

File tree

2 files changed

+16
-0
lines changed
  • security-framework-sys/src
  • security-framework/src

2 files changed

+16
-0
lines changed

security-framework-sys/src/key.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ extern "C" {
2929
#[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
3030
pub fn SecKeyCreateRandomKey(parameters: CFDictionaryRef, error: *mut CFErrorRef) -> SecKeyRef;
3131

32+
#[cfg(any(feature = "OSX_10_13", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
33+
pub fn SecKeyCreateWithData(
34+
keyData: CFDataRef,
35+
attributes: CFDictionaryRef,
36+
error: *mut CFErrorRef,
37+
) -> SecKeyRef;
38+
3239
#[cfg(target_os = "macos")]
3340
pub fn SecKeyCreateFromData(
3441
parameters: CFDictionaryRef,

security-framework/src/key.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ impl KeyType {
118118
unsafe { Self(kSecAttrKeyTypeEC) }
119119
}
120120

121+
#[inline(always)]
122+
#[must_use]
123+
pub fn ec_sec_prime_random() -> Self {
124+
use security_framework_sys::item::kSecAttrKeyTypeECSECPrimeRandom;
125+
126+
unsafe { Self(kSecAttrKeyTypeECSECPrimeRandom) }
127+
}
128+
129+
121130
pub(crate) fn to_str(self) -> CFString {
122131
unsafe { CFString::wrap_under_get_rule(self.0) }
123132
}

0 commit comments

Comments
 (0)