summaryrefslogtreecommitdiffstats
path: root/security/manager/ssl/osclientcerts/src/bindings_macos.rs
blob: 7294bbb5553708c600142d0f4c3e73996d4c053d (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* -*- 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 const errSecItemNotFound: OSStatus = -25300;

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;

    // Available starting macOS 10.12
    pub fn SecKeyCreateSignature(
        key: SecKeyRef,
        algorithm: SecKeyAlgorithm,
        data: CFDataRef,
        err: *mut CFErrorRef,
    ) -> CFDataRef;
    pub fn SecKeyCopyAttributes(key: SecKeyRef) -> CFDictionaryRef;
    pub fn SecKeyCopyExternalRepresentation(key: SecKeyRef, err: *mut CFErrorRef) -> CFDataRef;
    pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA1: CFStringRef;
    pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA256: CFStringRef;
    pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA384: CFStringRef;
    pub static kSecKeyAlgorithmECDSASignatureDigestX962SHA512: CFStringRef;
    pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15Raw: CFStringRef;
    pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256: CFStringRef;
    pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384: CFStringRef;
    pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512: CFStringRef;
    pub static kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1: CFStringRef;
    pub static kSecAttrKeyTypeECSECPrimeRandom: CFStringRef;
}