summaryrefslogtreecommitdiffstats
path: root/security/manager/ssl/osclientcerts/src/bindings_macos.rs
blob: 14aff193b3465863ed0c05fb71c399160ef362d3 (plain)
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
/* -*- Mode: rust; rust-indent-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// This was originally generated by rust-bindgen at build time. Later in
// development it became clear that using bindgen for this library as part of
// mozilla-central would be difficult (if not impossible). So, this was
// converted to a static file and unused declarations were removed. Also,
// intermediate types added by rust-bindgen were removed for clarity.

pub type OSStatus = i32;
pub const errSecSuccess: OSStatus = 0;

pub type SecKeyAlgorithm = CFStringRef;

extern "C" {
    // Available starting macOS 10.3
    pub fn SecCertificateGetTypeID() -> CFTypeID;
    pub fn SecTrustCreateWithCertificates(
        certificates: SecCertificateRef,
        policies: SecPolicyRef,
        trust: *mut SecTrustRef,
    ) -> OSStatus;
    pub fn SecIdentityGetTypeID() -> CFTypeID;
    pub fn SecIdentityCopyCertificate(
        identityRef: SecIdentityRef,
        certificateRef: *mut SecCertificateRef,
    ) -> OSStatus;
    pub fn SecIdentityCopyPrivateKey(
        identityRef: SecIdentityRef,
        privateKeyRef: *mut SecKeyRef,
    ) -> OSStatus;
    pub fn SecKeyGetTypeID() -> CFTypeID;
    pub fn SecPolicyGetTypeID() -> CFTypeID;
    pub fn SecTrustGetTypeID() -> CFTypeID;

    // Available starting macOS 10.6
    pub fn SecCertificateCopyData(certificate: SecCertificateRef) -> CFDataRef;
    pub fn SecCertificateCopySubjectSummary(certificate: SecCertificateRef) -> CFStringRef;
    pub fn SecItemCopyMatching(query: CFDictionaryRef, result: *mut CFTypeRef) -> OSStatus;
    pub fn SecPolicyCreateSSL(server: bool, hostname: CFStringRef) -> SecPolicyRef;
    pub static kSecClass: CFStringRef;
    pub static kSecAttrKeyType: CFStringRef;
    pub static kSecAttrKeySizeInBits: CFStringRef;
    pub static kSecMatchLimit: CFStringRef;
    pub static kSecMatchLimitAll: CFStringRef;
    pub static kSecReturnRef: CFStringRef;

    // Available starting macOS 10.7
    pub fn SecTrustGetCertificateAtIndex(trust: SecTrustRef, ix: CFIndex) -> SecCertificateRef;
    pub fn SecTrustGetCertificateCount(trust: SecTrustRef) -> CFIndex;
    pub static kSecClassIdentity: CFStringRef;
    pub static kSecAttrKeyTypeRSA: CFStringRef;

    // Available starting macOS 10.9
    pub fn SecTrustSetNetworkFetchAllowed(trust: SecTrustRef, allowFetch: Boolean) -> OSStatus;
}