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