this repo has no description
1/*
2 * Copyright (c) 2002-2008, 2010-2015, 2017 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 * Modification History
26 *
27 * October 31, 2000 Allan Nathanson <ajn@apple.com>
28 * - initial revision
29 */
30
31
32#include <sys/types.h>
33#include <sys/param.h>
34#include <sys/stat.h>
35#include <dlfcn.h>
36#include <mach-o/dyld_priv.h>
37
38#include <CoreFoundation/CFRuntime.h>
39#include "dy_framework.h"
40
41
42void *
43_SC_dlopen(const char *framework)
44{
45 void *image;
46 static dispatch_once_t once;
47 static const char *suffix = NULL;
48
49 dispatch_once(&once, ^{
50 if (!dyld_process_is_restricted()) {
51 suffix = getenv("DYLD_IMAGE_SUFFIX");
52 if ((suffix != NULL) &&
53 ((strlen(suffix) < 2) || (suffix[0] != '_'))) {
54 // if too short or no leading "_"
55 suffix = NULL;
56 }
57 }
58 });
59
60 if (suffix != NULL) {
61 struct stat statbuf;
62 char path[MAXPATHLEN];
63
64 strlcpy(path, framework, sizeof(path));
65 strlcat(path, suffix, sizeof(path));
66 if (0 <= stat(path, &statbuf)) {
67 image = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
68 return image;
69 }
70 }
71
72 image = dlopen(framework, RTLD_LAZY | RTLD_LOCAL);
73 return image;
74}
75
76
77#pragma mark -
78#pragma mark IOKit.framework APIs
79
80static void *
81__loadIOKit(void) {
82 static void *image = NULL;
83 static dispatch_once_t once;
84
85 dispatch_once(&once, ^{
86 image = _SC_dlopen("/System/Library/Frameworks/IOKit.framework/IOKit");
87 });
88
89 return image;
90}
91
92
93__private_extern__ CFMutableDictionaryRef
94_IOBSDNameMatching(mach_port_t masterPort, uint32_t options, const char *bsdName)
95{
96 #undef IOBSDNameMatching
97 static typeof (IOBSDNameMatching) *dyfunc = NULL;
98 if (!dyfunc) {
99 void *image = __loadIOKit();
100 if (image) dyfunc = dlsym(image, "IOBSDNameMatching");
101 }
102 return dyfunc ? dyfunc(masterPort, options, bsdName) : NULL;
103}
104
105
106__private_extern__ io_object_t
107_IOIteratorNext(io_iterator_t iterator)
108{
109 #undef IOIteratorNext
110 static typeof (IOIteratorNext) *dyfunc = NULL;
111 if (!dyfunc) {
112 void *image = __loadIOKit();
113 if (image) dyfunc = dlsym(image, "IOIteratorNext");
114 }
115 return dyfunc ? dyfunc(iterator) : 0;
116}
117
118
119__private_extern__ kern_return_t
120_IOMasterPort(mach_port_t bootstrapPort, mach_port_t *masterPort)
121{
122 #undef IOMasterPort
123 static typeof (IOMasterPort) *dyfunc = NULL;
124 if (!dyfunc) {
125 void *image = __loadIOKit();
126 if (image) dyfunc = dlsym(image, "IOMasterPort");
127 }
128 return dyfunc ? dyfunc(bootstrapPort, masterPort) : KERN_FAILURE;
129}
130
131
132__private_extern__ boolean_t
133_IOObjectConformsTo(io_object_t object, const io_name_t className)
134{
135 #undef IOObjectConformsTo
136 static typeof (IOObjectConformsTo) *dyfunc = NULL;
137 if (!dyfunc) {
138 void *image = __loadIOKit();
139 if (image) dyfunc = dlsym(image, "IOObjectConformsTo");
140 }
141 return dyfunc ? dyfunc(object, className) : FALSE;
142}
143
144
145__private_extern__ boolean_t
146_IOObjectGetClass(io_object_t object, io_name_t className)
147{
148 #undef IOObjectGetClass
149 static typeof (IOObjectGetClass) *dyfunc = NULL;
150 if (!dyfunc) {
151 void *image = __loadIOKit();
152 if (image) dyfunc = dlsym(image, "IOObjectGetClass");
153 }
154 return dyfunc ? dyfunc(object, className) : FALSE;
155}
156
157
158__private_extern__ kern_return_t
159_IOObjectRelease(io_object_t object)
160{
161 #undef IOObjectRelease
162 static typeof (IOObjectRelease) *dyfunc = NULL;
163 if (!dyfunc) {
164 void *image = __loadIOKit();
165 if (image) dyfunc = dlsym(image, "IOObjectRelease");
166 }
167 return dyfunc ? dyfunc(object) : KERN_FAILURE;
168}
169
170
171#if !TARGET_OS_IPHONE
172
173__private_extern__ IOReturn
174_IOPMConnectionAcknowledgeEvent(IOPMConnection myConnection, IOPMConnectionMessageToken token)
175{
176 #undef IOPMConnectionAcknowledgeEvent
177 static typeof (IOPMConnectionAcknowledgeEvent) *dyfunc = NULL;
178 if (!dyfunc) {
179 void *image = __loadIOKit();
180 if (image) dyfunc = dlsym(image, "IOPMConnectionAcknowledgeEvent");
181 }
182 return dyfunc ? dyfunc(myConnection, token) : kIOReturnError;
183}
184
185
186__private_extern__ IOReturn
187_IOPMConnectionCreate(CFStringRef myName, IOPMCapabilityBits interests, IOPMConnection *newConnection)
188{
189 #undef IOPMConnectionCreate
190 static typeof (IOPMConnectionCreate) *dyfunc = NULL;
191 if (!dyfunc) {
192 void *image = __loadIOKit();
193 if (image) dyfunc = dlsym(image, "IOPMConnectionCreate");
194 }
195 return dyfunc ? dyfunc(myName, interests, newConnection) : kIOReturnError;
196}
197
198
199__private_extern__ IOPMCapabilityBits
200_IOPMConnectionGetSystemCapabilities(void)
201{
202 #undef IOPMConnectionGetSystemCapabilities
203 static typeof (IOPMConnectionGetSystemCapabilities) *dyfunc = NULL;
204 if (!dyfunc) {
205 void *image = __loadIOKit();
206 if (image) dyfunc = dlsym(image, "IOPMConnectionGetSystemCapabilities");
207 }
208 return dyfunc ? dyfunc() : kIOPMSleepWakeInterest;
209}
210
211
212__private_extern__ IOReturn
213_IOPMConnectionRelease(IOPMConnection myConnection)
214{
215 #undef IOPMConnectionRelease
216 static typeof (IOPMConnectionRelease) *dyfunc = NULL;
217 if (!dyfunc) {
218 void *image = __loadIOKit();
219 if (image) dyfunc = dlsym(image, "IOPMConnectionRelease");
220 }
221 return dyfunc ? dyfunc(myConnection) : kIOReturnError;
222}
223
224
225__private_extern__ void
226_IOPMConnectionSetDispatchQueue(IOPMConnection myConnection, dispatch_queue_t myQueue)
227{
228 #undef IOPMConnectionSetDispatchQueue
229 static typeof (IOPMConnectionSetDispatchQueue) *dyfunc = NULL;
230 if (!dyfunc) {
231 void *image = __loadIOKit();
232 if (image) dyfunc = dlsym(image, "IOPMConnectionSetDispatchQueue");
233 }
234 if (dyfunc) {
235 dyfunc(myConnection, myQueue);
236 }
237 return;
238}
239
240
241__private_extern__ IOReturn
242_IOPMConnectionSetNotification(IOPMConnection myConnection, void *param, IOPMEventHandlerType handler)
243{
244 #undef IOPMConnectionSetNotification
245 static typeof (IOPMConnectionSetNotification) *dyfunc = NULL;
246 if (!dyfunc) {
247 void *image = __loadIOKit();
248 if (image) dyfunc = dlsym(image, "IOPMConnectionSetNotification");
249 }
250 return dyfunc ? dyfunc(myConnection, param, handler) : kIOReturnError;
251}
252
253#endif // !TARGET_OS_IPHONE
254
255
256__private_extern__ CFTypeRef
257_IORegistryEntryCreateCFProperty(io_registry_entry_t entry, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options)
258{
259 #undef IORegistryEntryCreateCFProperty
260 static typeof (IORegistryEntryCreateCFProperty) *dyfunc = NULL;
261 if (!dyfunc) {
262 void *image = __loadIOKit();
263 if (image) dyfunc = dlsym(image, "IORegistryEntryCreateCFProperty");
264 }
265 return dyfunc ? dyfunc(entry, key, allocator, options) : NULL;
266}
267
268
269__private_extern__ kern_return_t
270_IORegistryEntryCreateCFProperties(io_registry_entry_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, IOOptionBits options)
271{
272 #undef IORegistryEntryCreateCFProperties
273 static typeof (IORegistryEntryCreateCFProperties) *dyfunc = NULL;
274 if (!dyfunc) {
275 void *image = __loadIOKit();
276 if (image) dyfunc = dlsym(image, "IORegistryEntryCreateCFProperties");
277 }
278 return dyfunc ? dyfunc(entry, properties, allocator, options) : KERN_FAILURE;
279}
280
281
282__private_extern__ kern_return_t
283_IORegistryEntryCreateIterator(mach_port_t masterPort, const io_name_t plane, IOOptionBits options, io_iterator_t *iterator)
284{
285 #undef IORegistryEntryCreateIterator
286 static typeof (IORegistryEntryCreateIterator) *dyfunc = NULL;
287 if (!dyfunc) {
288 void *image = __loadIOKit();
289 if (image) dyfunc = dlsym(image, "IORegistryEntryCreateIterator");
290 }
291 return dyfunc ? dyfunc(masterPort, plane, options, iterator) : KERN_FAILURE;
292}
293
294
295__private_extern__ kern_return_t
296_IORegistryEntryGetLocationInPlane(io_registry_entry_t entry, const io_name_t plane, io_name_t location)
297{
298#undef IORegistryEntryGetLocationInPlane
299 static typeof (IORegistryEntryGetLocationInPlane) *dyfunc = NULL;
300 if (!dyfunc) {
301 void *image = __loadIOKit();
302 if (image) dyfunc = dlsym(image, "IORegistryEntryGetLocationInPlane");
303 }
304 return dyfunc ? dyfunc(entry, plane, location) : KERN_FAILURE;
305}
306
307
308__private_extern__ kern_return_t
309_IORegistryEntryGetName(io_registry_entry_t entry, io_name_t name)
310{
311 #undef IORegistryEntryGetName
312 static typeof (IORegistryEntryGetName) *dyfunc = NULL;
313 if (!dyfunc) {
314 void *image = __loadIOKit();
315 if (image) dyfunc = dlsym(image, "IORegistryEntryGetName");
316 }
317 return dyfunc ? dyfunc(entry, name) : KERN_FAILURE;
318}
319
320
321__private_extern__ kern_return_t
322_IORegistryEntryGetNameInPlane(io_registry_entry_t entry, const io_name_t plane, io_name_t name)
323{
324 #undef IORegistryEntryGetNameInPlane
325 static typeof (IORegistryEntryGetNameInPlane) *dyfunc = NULL;
326 if (!dyfunc) {
327 void *image = __loadIOKit();
328 if (image) dyfunc = dlsym(image, "IORegistryEntryGetNameInPlane");
329 }
330 return dyfunc ? dyfunc(entry, plane, name) : KERN_FAILURE;
331}
332
333
334__private_extern__ kern_return_t
335_IORegistryEntryGetParentEntry(io_registry_entry_t entry, const io_name_t plane, io_registry_entry_t *parent)
336{
337 #undef IORegistryEntryGetParentEntry
338 static typeof (IORegistryEntryGetParentEntry) *dyfunc = NULL;
339 if (!dyfunc) {
340 void *image = __loadIOKit();
341 if (image) dyfunc = dlsym(image, "IORegistryEntryGetParentEntry");
342 }
343 return dyfunc ? dyfunc(entry, plane, parent) : KERN_FAILURE;
344}
345
346
347__private_extern__ kern_return_t
348_IORegistryEntryGetPath(io_registry_entry_t entry, const io_name_t plane, io_string_t path)
349{
350 #undef IORegistryEntryGetPath
351 static typeof (IORegistryEntryGetPath) *dyfunc = NULL;
352 if (!dyfunc) {
353 void *image = __loadIOKit();
354 if (image) dyfunc = dlsym(image, "IORegistryEntryGetPath");
355 }
356 return dyfunc ? dyfunc(entry, plane, path) : KERN_FAILURE;
357}
358
359
360__private_extern__ kern_return_t
361_IORegistryEntryGetRegistryEntryID(io_registry_entry_t entry, uint64_t *entryID)
362{
363 #undef IORegistryEntryGetRegistryEntryID
364 static typeof (IORegistryEntryGetRegistryEntryID) *dyfunc = NULL;
365 if (!dyfunc) {
366 void *image = __loadIOKit();
367 if (image) dyfunc = dlsym(image, "IORegistryEntryGetRegistryEntryID");
368 }
369 return dyfunc ? dyfunc(entry, entryID) : KERN_FAILURE;
370}
371
372
373__private_extern__ CFTypeRef
374_IORegistryEntrySearchCFProperty(io_registry_entry_t entry, const io_name_t plane, CFStringRef key, CFAllocatorRef allocator, IOOptionBits options)
375{
376 #undef IORegistryEntrySearchCFProperty
377 static typeof (IORegistryEntrySearchCFProperty) *dyfunc = NULL;
378 if (!dyfunc) {
379 void *image = __loadIOKit();
380 if (image) dyfunc = dlsym(image, "IORegistryEntrySearchCFProperty");
381 }
382 return dyfunc ? dyfunc(entry, plane, key, allocator, options) : NULL;
383}
384
385
386__private_extern__ kern_return_t
387_IOServiceGetMatchingServices(mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t *existing)
388{
389 #undef IOServiceGetMatchingServices
390 static typeof (IOServiceGetMatchingServices) *dyfunc = NULL;
391 if (!dyfunc) {
392 void *image = __loadIOKit();
393 if (image) dyfunc = dlsym(image, "IOServiceGetMatchingServices");
394 }
395 return dyfunc ? dyfunc(masterPort, matching, existing) : KERN_FAILURE;
396}
397
398
399__private_extern__ CFMutableDictionaryRef
400_IOServiceMatching(const char *name)
401{
402 #undef IOServiceMatching
403 static typeof (IOServiceMatching) *dyfunc = NULL;
404 if (!dyfunc) {
405 void *image = __loadIOKit();
406 if (image) dyfunc = dlsym(image, "IOServiceMatching");
407 }
408 return dyfunc ? dyfunc(name) : NULL;
409}
410
411#pragma mark -
412#pragma mark Security.framework APIs
413
414static void *
415__loadSecurity(void) {
416 static void *image = NULL;
417 static dispatch_once_t once;
418
419 dispatch_once(&once, ^{
420 image = _SC_dlopen("/System/Library/Frameworks/Security.framework/Security");
421 });
422
423 return image;
424}
425
426#define SECURITY_FRAMEWORK_EXTERN(t, s) \
427 __private_extern__ t \
428 _ ## s(void) \
429 { \
430 static t *dysym = NULL; \
431 if (!dysym) { \
432 void *image = __loadSecurity(); \
433 if (image) dysym = dlsym(image, #s ); \
434 } \
435 return (dysym != NULL) ? *dysym : NULL; \
436 }
437
438#if !TARGET_OS_IPHONE
439SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecAttrService)
440SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecClass)
441SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecClassGenericPassword)
442SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecMatchLimit)
443SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecMatchLimitAll)
444SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecMatchSearchList)
445SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecReturnRef)
446SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecGuestAttributePid)
447SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecCodeInfoIdentifier)
448SECURITY_FRAMEWORK_EXTERN(CFTypeRef, kSecCodeInfoUnique)
449
450__private_extern__ OSStatus
451_AuthorizationMakeExternalForm(AuthorizationRef authorization, AuthorizationExternalForm *extForm)
452{
453 #undef AuthorizationMakeExternalForm
454 static typeof (AuthorizationMakeExternalForm) *dyfunc = NULL;
455 if (!dyfunc) {
456 void *image = __loadSecurity();
457 if (image) dyfunc = dlsym(image, "AuthorizationMakeExternalForm");
458 }
459 return dyfunc ? dyfunc(authorization, extForm) : -1;
460}
461
462__private_extern__ OSStatus
463_SecAccessCreate(CFStringRef descriptor, CFArrayRef trustedlist, SecAccessRef *accessRef)
464{
465 #undef SecAccessCreate
466 static typeof (SecAccessCreate) *dyfunc = NULL;
467 if (!dyfunc) {
468 void *image = __loadSecurity();
469 if (image) dyfunc = dlsym(image, "SecAccessCreate");
470 }
471 return dyfunc ? dyfunc(descriptor, trustedlist, accessRef) : -1;
472}
473
474#if (__MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
475__private_extern__ OSStatus
476_SecAccessCreateFromOwnerAndACL(const CSSM_ACL_OWNER_PROTOTYPE *owner, uint32 aclCount, const CSSM_ACL_ENTRY_INFO *acls, SecAccessRef *accessRef)
477{
478 #undef SecAccessCreateFromOwnerAndACL
479 static typeof (SecAccessCreateFromOwnerAndACL) *dyfunc = NULL;
480 if (!dyfunc) {
481 void *image = __loadSecurity();
482 if (image) dyfunc = dlsym(image, "SecAccessCreateFromOwnerAndACL");
483 }
484 return dyfunc ? dyfunc(owner, aclCount, acls, accessRef) : -1;
485}
486#else // (__MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
487__private_extern__ SecAccessRef
488_SecAccessCreateWithOwnerAndACL(uid_t userId, gid_t groupId, SecAccessOwnerType ownerType, CFArrayRef acls, CFErrorRef *error)
489{
490#undef SecAccessCreateWithOwnerAndACL
491 static typeof (SecAccessCreateWithOwnerAndACL) *dyfunc = NULL;
492 if (!dyfunc) {
493 void *image = __loadSecurity();
494 if (image) dyfunc = dlsym(image, "SecAccessCreateWithOwnerAndACL");
495 }
496 return dyfunc ? dyfunc(userId, groupId, ownerType, acls, error) : NULL;
497}
498#endif // (__MAC_OS_X_VERSION_MIN_REQUIRED < 1070)
499
500__private_extern__ OSStatus
501_SecItemCopyMatching(CFDictionaryRef query, CFTypeRef *result)
502{
503#undef SecItemCopyMatching
504 static typeof (SecItemCopyMatching) *dyfunc = NULL;
505 if (!dyfunc) {
506 void *image = __loadSecurity();
507 if (image) dyfunc = dlsym(image, "SecItemCopyMatching");
508 }
509 return dyfunc ? dyfunc(query, result) : -1;
510}
511
512__private_extern__ OSStatus
513_SecKeychainCopyDomainDefault(SecPreferencesDomain domain, SecKeychainRef *keychain)
514{
515 #undef SecKeychainCopyDomainDefault
516 static typeof (SecKeychainCopyDomainDefault) *dyfunc = NULL;
517 if (!dyfunc) {
518 void *image = __loadSecurity();
519 if (image) dyfunc = dlsym(image, "SecKeychainCopyDomainDefault");
520 }
521 return dyfunc ? dyfunc(domain, keychain) : -1;
522}
523
524__private_extern__ OSStatus
525_SecKeychainOpen(const char *pathName, SecKeychainRef *keychain)
526{
527 #undef SecKeychainOpen
528 static typeof (SecKeychainOpen) *dyfunc = NULL;
529 if (!dyfunc) {
530 void *image = __loadSecurity();
531 if (image) dyfunc = dlsym(image, "SecKeychainOpen");
532 }
533 return dyfunc ? dyfunc(pathName, keychain) : -1;
534}
535
536__private_extern__ OSStatus
537_SecKeychainSetDomainDefault(SecPreferencesDomain domain, SecKeychainRef keychain)
538{
539 #undef SecKeychainSetDomainDefault
540 static typeof (SecKeychainSetDomainDefault) *dyfunc = NULL;
541 if (!dyfunc) {
542 void *image = __loadSecurity();
543 if (image) dyfunc = dlsym(image, "SecKeychainSetDomainDefault");
544 }
545 return dyfunc ? dyfunc(domain, keychain) : -1;
546}
547
548__private_extern__ OSStatus
549_SecKeychainItemCopyContent(SecKeychainItemRef itemRef, SecItemClass *itemClass, SecKeychainAttributeList *attrList, UInt32 *length, void **outData)
550{
551 #undef SecKeychainItemCopyContent
552 static typeof (SecKeychainItemCopyContent) *dyfunc = NULL;
553 if (!dyfunc) {
554 void *image = __loadSecurity();
555 if (image) dyfunc = dlsym(image, "SecKeychainItemCopyContent");
556 }
557 return dyfunc ? dyfunc(itemRef, itemClass, attrList, length, outData) : -1;
558}
559
560__private_extern__ OSStatus
561_SecKeychainItemCreateFromContent(SecItemClass itemClass, SecKeychainAttributeList *attrList, UInt32 length, const void *data, SecKeychainRef keychainRef, SecAccessRef initialAccess, SecKeychainItemRef *itemRef)
562{
563 #undef SecKeychainItemCreateFromContent
564 static typeof (SecKeychainItemCreateFromContent) *dyfunc = NULL;
565 if (!dyfunc) {
566 void *image = __loadSecurity();
567 if (image) dyfunc = dlsym(image, "SecKeychainItemCreateFromContent");
568 }
569 return dyfunc ? dyfunc(itemClass, attrList, length, data, keychainRef, initialAccess, itemRef) : -1;
570}
571
572__private_extern__ OSStatus
573_SecKeychainItemDelete(SecKeychainItemRef itemRef)
574{
575 #undef SecKeychainItemDelete
576 static typeof (SecKeychainItemDelete) *dyfunc = NULL;
577 if (!dyfunc) {
578 void *image = __loadSecurity();
579 if (image) dyfunc = dlsym(image, "SecKeychainItemDelete");
580 }
581 return dyfunc ? dyfunc(itemRef) : -1;
582}
583
584__private_extern__ OSStatus
585_SecKeychainItemFreeContent(SecKeychainAttributeList *attrList, void *data)
586{
587 #undef SecKeychainItemFreeContent
588 static typeof (SecKeychainItemFreeContent) *dyfunc = NULL;
589 if (!dyfunc) {
590 void *image = __loadSecurity();
591 if (image) dyfunc = dlsym(image, "SecKeychainItemFreeContent");
592 }
593 return dyfunc ? dyfunc(attrList, data) : -1;
594}
595
596__private_extern__ OSStatus
597_SecKeychainItemModifyContent(SecKeychainItemRef itemRef, const SecKeychainAttributeList *attrList, UInt32 length, const void *data)
598{
599 #undef SecKeychainItemModifyContent
600 static typeof (SecKeychainItemModifyContent) *dyfunc = NULL;
601 if (!dyfunc) {
602 void *image = __loadSecurity();
603 if (image) dyfunc = dlsym(image, "SecKeychainItemModifyContent");
604 }
605 return dyfunc ? dyfunc(itemRef, attrList, length, data) : -1;
606}
607
608
609__private_extern__ OSStatus
610_SecTrustedApplicationCreateFromPath(const char *path, SecTrustedApplicationRef *app)
611{
612 #undef SecTrustedApplicationCreateFromPath
613 static typeof (SecTrustedApplicationCreateFromPath) *dyfunc = NULL;
614 if (!dyfunc) {
615 void *image = __loadSecurity();
616 if (image) dyfunc = dlsym(image, "SecTrustedApplicationCreateFromPath");
617 }
618 return dyfunc ? dyfunc(path, app) : -1;
619}
620
621#else // TARGET_OS_IPHONE
622
623SECURITY_FRAMEWORK_EXTERN(CFStringRef, kSecPropertyKeyValue)
624SECURITY_FRAMEWORK_EXTERN(CFStringRef, kSecPropertyKeyLabel)
625
626__private_extern__ CFArrayRef
627_SecCertificateCopyProperties(SecCertificateRef certRef)
628{
629 #undef SecCertificateCopyProperties
630 static typeof (SecCertificateCopyProperties) *dyfunc = NULL;
631 if (!dyfunc) {
632 void *image = __loadSecurity();
633 if (image) dyfunc = dlsym(image, "SecCertificateCopyProperties");
634 }
635 return dyfunc ? dyfunc(certRef) : NULL;
636}
637
638#endif // TARGET_OS_IPHONE
639
640__private_extern__ SecCertificateRef
641_SecCertificateCreateWithData(CFAllocatorRef allocator, CFDataRef data)
642{
643 #undef SecCertificateCreateWithData
644 static typeof (SecCertificateCreateWithData) *dyfunc = NULL;
645 if (!dyfunc) {
646 void *image = __loadSecurity();
647 if (image) dyfunc = dlsym(image, "SecCertificateCreateWithData");
648 }
649 return dyfunc ? dyfunc(allocator, data) : NULL;
650}
651
652
653
654