security_framework_sys/
certificate.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use core_foundation_sys::array::CFArrayRef;
use core_foundation_sys::base::{CFAllocatorRef, CFTypeID, OSStatus};
use core_foundation_sys::data::CFDataRef;
#[cfg(target_os = "macos")]
use core_foundation_sys::dictionary::CFDictionaryRef;
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
use core_foundation_sys::error::CFErrorRef;
use core_foundation_sys::string::CFStringRef;

use crate::base::SecCertificateRef;
use crate::base::SecKeyRef;
use crate::base::SecKeychainRef;

extern "C" {
    #[cfg(target_os = "macos")]
    pub static kSecPropertyKeyType: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyKeyLabel: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyKeyLocalizedLabel: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyKeyValue: CFStringRef;

    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeWarning: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeSuccess: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeSection: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeData: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeString: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeURL: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPropertyTypeDate: CFStringRef;

    // certificate policies
    pub static kSecPolicyAppleX509Basic: CFStringRef;
    pub static kSecPolicyAppleSSL: CFStringRef;
    pub static kSecPolicyAppleSMIME: CFStringRef;
    pub static kSecPolicyAppleEAP: CFStringRef;
    pub static kSecPolicyAppleIPsec: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPolicyApplePKINITClient: CFStringRef;
    #[cfg(target_os = "macos")]
    pub static kSecPolicyApplePKINITServer: CFStringRef;
    pub static kSecPolicyAppleCodeSigning: CFStringRef;
    pub static kSecPolicyMacAppStoreReceipt: CFStringRef;
    pub static kSecPolicyAppleIDValidation: CFStringRef;
    pub static kSecPolicyAppleTimeStamping: CFStringRef;
    pub static kSecPolicyAppleRevocation: CFStringRef;
    pub static kSecPolicyApplePassbookSigning: CFStringRef;
    pub static kSecPolicyApplePayIssuerEncryption: CFStringRef;

    pub fn SecCertificateGetTypeID() -> CFTypeID;
    pub fn SecCertificateCreateWithData(
        allocator: CFAllocatorRef,
        data: CFDataRef,
    ) -> SecCertificateRef;
    pub fn SecCertificateAddToKeychain(
        certificate: SecCertificateRef,
        keychain: SecKeychainRef,
    ) -> OSStatus;
    pub fn SecCertificateCopyData(certificate: SecCertificateRef) -> CFDataRef;
    pub fn SecCertificateCopySubjectSummary(certificate: SecCertificateRef) -> CFStringRef;
    pub fn SecCertificateCopyCommonName(
        certificate: SecCertificateRef,
        common_name: *mut CFStringRef,
    ) -> OSStatus;
    pub fn SecCertificateCopyEmailAddresses(
        certificate: SecCertificateRef,
        email_addresses: *mut CFArrayRef,
    ) -> OSStatus;
    #[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
    pub fn SecCertificateCopyNormalizedIssuerSequence(certificate: SecCertificateRef) -> CFDataRef;
    #[cfg(any(feature = "OSX_10_12", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
    pub fn SecCertificateCopyNormalizedSubjectSequence(certificate: SecCertificateRef)
        -> CFDataRef;
    #[cfg(target_os = "macos")]
    #[cfg_attr(target_arch = "aarch64", link_name = "SecCertificateCopyPublicKey$LEGACYMAC")]
    #[deprecated(note = "Deprecated by Apple. May not work any more. Use SecCertificateCopyKey")]
    pub fn SecCertificateCopyPublicKey(
        certificate: SecCertificateRef,
        key: *mut SecKeyRef,
    ) -> OSStatus;
    #[cfg(any(feature = "OSX_10_14", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
    pub fn SecCertificateCopyKey(certificate: SecCertificateRef) -> SecKeyRef;
    #[cfg(any(feature = "OSX_10_13", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))]
    pub fn SecCertificateCopySerialNumberData(
        certificate: SecCertificateRef,
        error: *mut CFErrorRef,
    ) -> CFDataRef;
    #[cfg(target_os = "macos")]
    pub fn SecCertificateCopyValues(
        certificate: SecCertificateRef,
        keys: CFArrayRef,
        error: *mut CFErrorRef,
    ) -> CFDictionaryRef;
}