2 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef SecProtocolTypes_h
25 #define SecProtocolTypes_h
27 #include <Security/SecProtocolObject.h>
28 #include <Security/SecTrust.h>
29 #include <Security/SecCertificate.h>
30 #include <Security/SecIdentity.h>
32 #ifndef SEC_OBJECT_IMPL
34 * These are os_object compatible and ARC-able wrappers around existing CoreFoundation
35 * Security types, including: SecTrustRef, SecIdentityRef, and SecCertificateRef. They allow
36 * clients to use these types in os_object-type APIs and data structures. The underlying
37 * CoreFoundation types may be extracted and used by clients as needed.
39 SEC_OBJECT_DECL(sec_trust
);
40 SEC_OBJECT_DECL(sec_identity
);
41 SEC_OBJECT_DECL(sec_certificate
);
42 #endif // !SEC_OBJECT_IMPL
44 SEC_ASSUME_NONNULL_BEGIN
47 * @function sec_trust_create
50 * Create an ARC-able `sec_trust_t` instance from a `SecTrustRef`.
53 * A `SecTrustRef` instance.
55 * @return a `sec_trust_t` instance.
57 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
58 SEC_RETURNS_RETAINED _Nullable sec_trust_t
59 sec_trust_create(SecTrustRef __nonnull trust
);
62 * @function sec_trust_copy_ref
65 * Copy a retained reference to the underlying `SecTrustRef` instance.
68 * A `sec_trust_t` instance.
70 * @return The underlying `SecTrustRef` instance.
72 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
74 sec_trust_copy_ref(sec_trust_t __nonnull trust
);
77 * @function sec_identity_create
80 * Create an ARC-able `sec_identity_t` instance from a `SecIdentityRef`.
83 * A `SecIdentityRef` instance.
85 * @return a `sec_identity_t` instance.
87 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
88 SEC_RETURNS_RETAINED _Nullable sec_identity_t
89 sec_identity_create(SecIdentityRef __nonnull identity
);
92 * @function sec_identity_create_with_certificates
95 * Create an ARC-able `sec_identity_t` instance from a `SecIdentityRef` and
96 * array of SecCertificateRef instances.
99 * A `SecIdentityRef` instance.
101 * @param certificates
102 * An array of `SecCertificateRef` instances.
104 * @return a `sec_identity_t` instance.
106 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
107 SEC_RETURNS_RETAINED _Nullable sec_identity_t
108 sec_identity_create_with_certificates(SecIdentityRef __nonnull identity
, CFArrayRef __nonnull certificates
);
111 * @function sec_identity_copy_ref
114 * Copy a retained reference to the underlying `SecIdentityRef` instance.
117 * A `sec_identity_t` instance.
119 * @return The underlying `SecIdentityRef` instance.
121 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
123 sec_identity_copy_ref(sec_identity_t __nonnull identity
);
126 * @function sec_identity_copy_certificates_ref
129 * Copy a retained reference to the underlying `CFArrayRef` container of `SecCertificateRef` types.
132 * A `sec_identity_t` instance.
134 * @return The underlying `CFArrayRef` container with `SecCertificateRef` instances.
136 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
138 sec_identity_copy_certificates_ref(sec_identity_t __nonnull identity
);
141 * @function sec_certificate_create
144 * Create an ARC-able `sec_certificate_t` instance from a `SecCertificateRef`.
147 * A `SecCertificateRef` instance.
149 * @return a `sec_certificate_t` instance.
151 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
152 SEC_RETURNS_RETAINED _Nullable sec_certificate_t
153 sec_certificate_create(SecCertificateRef __nonnull certificate
);
156 * @function sec_certificate_copy_ref
159 * Copy a retained reference to the underlying `SecCertificateRef` instance.
162 * A `sec_certificate_t` instance.
164 * @return The underlying `SecCertificateRef` instance.
166 API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
168 sec_certificate_copy_ref(sec_certificate_t __nonnull certificate
);
170 SEC_ASSUME_NONNULL_END
172 #endif // SecProtocolTypes_h