这篇教程C++ CFDataCreateWithBytesNoCopy函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFDataCreateWithBytesNoCopy函数的典型用法代码示例。如果您正苦于以下问题:C++ CFDataCreateWithBytesNoCopy函数的具体用法?C++ CFDataCreateWithBytesNoCopy怎么用?C++ CFDataCreateWithBytesNoCopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFDataCreateWithBytesNoCopy函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: DHCPLeaseCopyDictionarystatic CFDictionaryRefDHCPLeaseCopyDictionary(DHCPLeaseRef lease_p){ CFDataRef data; CFDateRef date; CFMutableDictionaryRef dict; CFNumberRef num; CFStringRef str; dict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); /* set the IP address */ str = CFStringCreateWithFormat(NULL, NULL, CFSTR(IP_FORMAT), IP_LIST(&lease_p->our_ip)); CFDictionarySetValue(dict, kIPAddress, str); CFRelease(str); /* set the lease start date */ date = CFDateCreate(NULL, lease_p->lease_start); CFDictionarySetValue(dict, kLeaseStartDate, date); CFRelease(date); /* set the lease length */ num = CFNumberCreate(NULL, kCFNumberSInt32Type, &lease_p->lease_length); CFDictionarySetValue(dict, kLeaseLength, num); CFRelease(num); /* set the SSID */ if (lease_p->ssid != NULL) { CFDictionarySetValue(dict, kSSID, lease_p->ssid); } /* set the packet data */ data = CFDataCreateWithBytesNoCopy(NULL, lease_p->pkt, lease_p->pkt_length, kCFAllocatorNull); CFDictionarySetValue(dict, kPacketData, data); CFRelease(data); if (lease_p->router_ip.s_addr != 0) { /* set the router IP address */ str = CFStringCreateWithFormat(NULL, NULL, CFSTR(IP_FORMAT), IP_LIST(&lease_p->router_ip)); CFDictionarySetValue(dict, kRouterIPAddress, str); CFRelease(str); if (lease_p->router_hwaddr_length > 0) { /* set the router hardware address */ data = CFDataCreateWithBytesNoCopy(NULL, lease_p->router_hwaddr, lease_p->router_hwaddr_length, kCFAllocatorNull); CFDictionarySetValue(dict, kRouterHardwareAddress, data); CFRelease(data); } } return (dict);}
开发者ID:aosm,项目名称:bootp,代码行数:57,
示例2: testsstatic void tests(void){ CFDataRef attached_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, attached_signed_data_der, attached_signed_data_der_len, kCFAllocatorNull); CFDataRef detached_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, detached_signed_data_der, detached_signed_data_der_len, kCFAllocatorNull); CFDataRef attached_no_data_signed_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, attached_no_data_signed_data_der, attached_no_data_signed_data_der_len, kCFAllocatorNull); CFDataRef detached_data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, detached_content, detached_content_len, kCFAllocatorNull); CFDataRef no_data = CFDataCreate(kCFAllocatorDefault, NULL, 0); SecPolicyRef policy = SecPolicyCreateBasicX509(); SecTrustRef trust = NULL; ok_status(SecCMSVerifyCopyDataAndAttributes(attached_signed_data, NULL, policy, &trust, NULL, NULL), "verify attached data"); CFRelease(trust); ok_status(SecCMSVerifyCopyDataAndAttributes(detached_signed_data, detached_data, policy, &trust, NULL, NULL), "verify detached data"); CFRelease(trust); ok_status(SecCMSVerifyCopyDataAndAttributes(attached_no_data_signed_data, NULL, policy, &trust, NULL, NULL), "verify attached no data"); CFRelease(trust); ok_status(SecCMSVerifyCopyDataAndAttributes(attached_no_data_signed_data, no_data, policy, &trust, NULL, NULL), "verify attached no data"); CFRelease(trust); SecCertificateRef cert = NULL; SecKeyRef privKey = NULL; SecIdentityRef identity = NULL; isnt(cert = SecCertificateCreateWithBytes(NULL, signer_der, signer_der_len), NULL, "create certificate"); isnt(privKey = SecKeyCreateRSAPrivateKey(NULL, privkey_der, privkey_der_len, kSecKeyEncodingPkcs1), NULL, "create private key"); isnt(identity = SecIdentityCreate(NULL, cert, privKey), NULL, "create identity"); CFReleaseSafe(privKey); CFMutableDataRef cms_data = CFDataCreateMutable(kCFAllocatorDefault, 0); ok_status(SecCMSCreateSignedData(identity, detached_data, NULL, NULL, cms_data), "create attached data"); //write_data("/var/tmp/attached", cms_data); CFDataSetLength(cms_data, 0); CFDictionaryRef detached_cms_dict = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&kSecCMSSignDetached, (const void **)&kCFBooleanTrue, 1, NULL, NULL); ok_status(SecCMSCreateSignedData(identity, detached_data, detached_cms_dict, NULL, cms_data), "create attached data"); CFRelease(detached_cms_dict); //write_data("/var/tmp/detached", cms_data); CFDataSetLength(cms_data, 0); ok_status(SecCMSCreateSignedData(identity, NULL, NULL, NULL, cms_data), "create attached data"); //write_data("/var/tmp/empty_attached", cms_data); CFReleaseSafe(cms_data); CFReleaseSafe(cert); CFReleaseNull(identity); CFRelease(attached_signed_data); CFRelease(detached_signed_data); CFRelease(attached_no_data_signed_data); CFRelease(detached_data); CFRelease(no_data); CFRelease(policy);}
开发者ID:darlinghq,项目名称:darling-security,代码行数:51,
示例3: mount_developer_imagevoid mount_developer_image(AMDeviceRef device) { CFStringRef ds_path = copy_device_support_path(device); CFStringRef image_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg"), ds_path); CFStringRef sig_path = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/DeveloperDiskImage.dmg.signature"), ds_path); CFRelease(ds_path); FILE* sig = fopen(CFStringGetCStringPtr(sig_path, kCFStringEncodingMacRoman), "rb"); void *sig_buf = malloc(128); assert(fread(sig_buf, 1, 128, sig) == 128); fclose(sig); CFDataRef sig_data = CFDataCreateWithBytesNoCopy(NULL, sig_buf, 128, NULL); CFRelease(sig_path); CFTypeRef keys[] = { CFSTR("ImageSignature"), CFSTR("ImageType") }; CFTypeRef values[] = { sig_data, CFSTR("Developer") }; CFDictionaryRef options = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFRelease(sig_data); int result = AMDeviceMountImage(device, image_path, options, &mount_callback, 0); if (result == 0 || result == 0xe8000076 /* already mounted */) { printf("[ 95%%] Developer disk image mounted successfully/n"); } else { printf("[ !! ] Unable to mount developer disk image. (%x)/n", result); exit(1); } CFRelease(image_path); CFRelease(options);}
开发者ID:MaksimKovalyov,项目名称:fruitstrap,代码行数:29,
示例4: mach_reply_funcstatic void mach_reply_func(struct ReplyAddress * addr, char* msg, int size){ CFMessagePortRef replyPort = (CFMessagePortRef) addr->mSocket; CFDataRef data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8*)msg, size, kCFAllocatorNull); CFMessagePortSendRequest(replyPort, 0, data, 0, 0, NULL, NULL); CFRelease(data);}
开发者ID:GaryHomewood,项目名称:supercollider-android-bootstrap,代码行数:7,
示例5: SecEncodeTransformCreateTagLib::ByteVector TagLib::EncodeBase64(const TagLib::ByteVector& input){ ByteVector result; CFErrorRef error; SFB::SecTransform encoder = SecEncodeTransformCreate(kSecBase64Encoding, &error); if(nullptr == encoder) { LOGGER_WARNING("org.sbooth.AudioEngine", "SecEncodeTransformCreate failed: " << error); return TagLib::ByteVector::null; } SFB::CFData sourceData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8 *)input.data(), (CFIndex)input.size(), kCFAllocatorNull); if(!sourceData) return TagLib::ByteVector::null; if(!SecTransformSetAttribute(encoder, kSecTransformInputAttributeName, sourceData, &error)) { LOGGER_WARNING("org.sbooth.AudioEngine", "SecTransformSetAttribute failed: " << error); return TagLib::ByteVector::null; } SFB::CFData encodedData = (CFDataRef)SecTransformExecute(encoder, &error); if(!encodedData) { LOGGER_WARNING("org.sbooth.AudioEngine", "SecTransformExecute failed: " << error); return TagLib::ByteVector::null; } result.setData((const char *)CFDataGetBytePtr((CFDataRef)encodedData), (TagLib::uint)CFDataGetLength((CFDataRef)encodedData)); return result;}
开发者ID:zbleftover,项目名称:SFBAudioEngine,代码行数:30,
示例6: CFDataCreateWithBytesNoCopyvoid GL::Image::load(const unsigned char *buf, size_t bufSize){ CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (const UInt8*)buf, (CFIndex)bufSize, kCFAllocatorNull); if (data != NULL) { CGImageSourceRef imageSource = CGImageSourceCreateWithData(data, NULL); if (imageSource != NULL) { CGImageRef img = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); if (img != NULL) { width_ = (int)CGImageGetWidth(img); height_ = (int)CGImageGetHeight(img); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); if (colorSpace != NULL) { char *texData = (char*)calloc(width_ * height_ * 4, sizeof(char)); CGContextRef ctx = CGBitmapContextCreate(texData, width_, height_, 8, width_ * 4, colorSpace, kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedFirst); if (ctx != NULL) { CGContextDrawImage(ctx, CGRectMake(0.0, 0.0, width_, height_), img); CGContextRelease(ctx); loadTextureData_(texData); } free(texData); CGColorSpaceRelease(colorSpace); } CGImageRelease(img); } CFRelease(imageSource); } CFRelease(data); }}
开发者ID:MaddTheSane,项目名称:Glypha,代码行数:29,
示例7: Clearbool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ){ Clear(); if ((pBuf == NULL) || (nSize == 0)) return false; Handle picHandle = NewHandle( nSize ); memcpy( *picHandle, pBuf, nSize ); m_pictHandle = picHandle; CGImageRef cgImageRef = 0; CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull); CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL ); if ( source ) { cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); CFRelease( source ); } CFRelease( data ); if ( cgImageRef ) { m_bitmap.Create( cgImageRef ); CGImageRelease(cgImageRef); cgImageRef = NULL; } return m_bitmap.IsOk();}
开发者ID:chromylei,项目名称:third_party,代码行数:30,
示例8: _SecIdentityCopyPreferenceMatchingNamestaticOSStatus _SecIdentityCopyPreferenceMatchingName( CFStringRef name, CSSM_KEYUSE keyUsage, CFArrayRef validIssuers, SecIdentityRef *identity){ // this is NOT exported, and called only from SecIdentityCopyPreference (below), so no BEGIN/END macros here; // caller must handle exceptions StorageManager::KeychainList keychains; globals().storageManager.getSearchList(keychains); KCCursor cursor(keychains, kSecGenericPasswordItemClass, NULL); char idUTF8[MAXPATHLEN]; Required(name); if (!CFStringGetCString(name, idUTF8, sizeof(idUTF8)-1, kCFStringEncodingUTF8)) idUTF8[0] = (char)'/0'; CssmData service(const_cast<char *>(idUTF8), strlen(idUTF8)); FourCharCode itemType = 'iprf'; cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecServiceItemAttr), service); cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecTypeItemAttr), itemType); if (keyUsage) cursor->add(CSSM_DB_EQUAL, Schema::attributeInfo(kSecScriptCodeItemAttr), (sint32)keyUsage); Item prefItem; if (!cursor->next(prefItem)) return errSecItemNotFound; // get persistent certificate reference SecKeychainAttribute itemAttrs[] = { { kSecGenericItemAttr, 0, NULL } }; SecKeychainAttributeList itemAttrList = { sizeof(itemAttrs) / sizeof(itemAttrs[0]), itemAttrs }; prefItem->getContent(NULL, &itemAttrList, NULL, NULL); // find certificate, given persistent reference data CFDataRef pItemRef = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)itemAttrs[0].data, itemAttrs[0].length, kCFAllocatorNull); SecKeychainItemRef certItemRef = nil; OSStatus status = SecKeychainItemCopyFromPersistentReference(pItemRef, &certItemRef); //%%% need to make this a method of ItemImpl prefItem->freeContent(&itemAttrList, NULL); if (pItemRef) CFRelease(pItemRef); if (status) return status; // filter on valid issuers, if provided if (validIssuers) { //%%%TBI } // create identity reference, given certificate Item certItem = ItemImpl::required(SecKeychainItemRef(certItemRef)); SecPointer<Certificate> certificate(static_cast<Certificate *>(certItem.get())); SecPointer<Identity> identity_ptr(new Identity(keychains, certificate)); if (certItemRef) CFRelease(certItemRef); Required(identity) = identity_ptr->handle(); return status;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:60,
示例9: my_CFPropertyListCreateFromFilePRIVATE_EXTERN CFPropertyListRef my_CFPropertyListCreateFromFile(const char * filename){ void * buf; size_t bufsize; CFDataRef data = NULL; CFPropertyListRef plist = NULL; buf = read_file(filename, &bufsize); if (buf == NULL) { return (NULL); } data = CFDataCreateWithBytesNoCopy(NULL, buf, bufsize, kCFAllocatorNull); if (data == NULL) { goto done; } plist = CFPropertyListCreateWithData(NULL, data, kCFPropertyListImmutable, NULL, NULL); done: if (data) CFRelease(data); if (buf) free(buf); return (plist);}
开发者ID:aosm,项目名称:bootp,代码行数:28,
示例10: Clearbool wxBitmapDataObject::SetData( size_t nSize, const void *pBuf ){ Clear(); if ((pBuf == NULL) || (nSize == 0)) return false; Handle picHandle = NewHandle( nSize ); memcpy( *picHandle, pBuf, nSize ); m_pictHandle = picHandle; CGImageRef cgImageRef = 0; CFDataRef data = CFDataCreateWithBytesNoCopy( kCFAllocatorDefault, (const UInt8*) pBuf, nSize, kCFAllocatorNull); CGImageSourceRef source = CGImageSourceCreateWithData( data, NULL ); if ( source ) { cgImageRef = CGImageSourceCreateImageAtIndex(source, 0, NULL); CFRelease( source ); } CFRelease( data ); if ( cgImageRef ) { m_bitmap.Create( CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) ); CGRect r = CGRectMake( 0 , 0 , CGImageGetWidth(cgImageRef) , CGImageGetHeight(cgImageRef) ); // since our context is upside down we dont use CGContextDrawImage wxMacDrawCGImage( (CGContextRef) m_bitmap.GetHBITMAP() , &r, cgImageRef ) ; CGImageRelease(cgImageRef); cgImageRef = NULL; } return m_bitmap.IsOk();}
开发者ID:lukesingh24,项目名称:wxWidgets,代码行数:33,
示例11: encodeSessionHistoryEntryDatastatic RetainPtr<CFDataRef> encodeSessionHistoryEntryData(const FrameState& frameState){ static CFAllocatorRef fastMallocDeallocator; static std::once_flag onceFlag; std::call_once(onceFlag, [] { CFAllocatorContext context = { 0, // version nullptr, // info nullptr, // retain nullptr, // release nullptr, // copyDescription nullptr, // allocate nullptr, // reallocate [](void *ptr, void *info) { WTF::fastFree(ptr); }, nullptr, // preferredSize }; fastMallocDeallocator = CFAllocatorCreate(kCFAllocatorDefault, &context); }); size_t bufferSize; auto buffer = encodeSessionHistoryEntryData(frameState, bufferSize); return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer.leakPtr(), bufferSize, fastMallocDeallocator));}
开发者ID:eocanha,项目名称:webkit,代码行数:27,
示例12: device_infoCFDictionaryRef device_info(int socket, CFDictionaryRef request){ uint8_t dkey[40]={0}; uint8_t emf[36]={0}; struct HFSInfos hfsinfos={0}; CFMutableDictionaryRef out = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); get_device_infos(out); getHFSInfos(&hfsinfos); /* printf("NAND block size : %x/n", hfsinfos.blockSize); printf("Data volume UUID : %llx/n", CFSwapInt64BigToHost(hfsinfos.volumeUUID)); printf("Data volume offset : %x/n", hfsinfos.dataVolumeOffset); */ uint8_t* key835 = IOAES_key835(); uint8_t* key89B = IOAES_key89B(); if (!AppleEffaceableStorage__getBytes(lockers, 960)) { CFDataRef lockersData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, lockers, 960, kCFAllocatorNull); CFDictionaryAddValue(out, CFSTR("lockers"), lockersData); CFRelease(lockersData); if (!AppleEffaceableStorage__getLockerFromBytes(LOCKER_DKEY, lockers, 960, dkey, 40)) { aes_key_wrap_ctx ctx; aes_key_wrap_set_key(&ctx, key835, 16); if(aes_key_unwrap(&ctx, dkey, dkey, 32/8)) printf("FAIL unwrapping DKey with key 0x835/n"); } if (!AppleEffaceableStorage__getLockerFromBytes(LOCKER_EMF, lockers, 960, emf, 36)) { doAES(&emf[4], &emf[4], 32, kIOAESAcceleratorCustomMask, key89B, NULL, kIOAESAcceleratorDecrypt, 128); } else if (!AppleEffaceableStorage__getLockerFromBytes(LOCKER_LWVM, lockers, 960, lwvm, 0x50)) { doAES(lwvm, lwvm, 0x50, kIOAESAcceleratorCustomMask, key89B, NULL, kIOAESAcceleratorDecrypt, 128); memcpy(&emf[4], &lwvm[32+16], 32); } } CFNumberRef n = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &hfsinfos.dataVolumeOffset); CFDictionaryAddValue(out, CFSTR("dataVolumeOffset"), n); CFRelease(n); addHexaString(out, CFSTR("dataVolumeUUID"), (uint8_t*) &hfsinfos.volumeUUID, 8); addHexaString(out, CFSTR("key835"), key835, 16); addHexaString(out, CFSTR("key89B"), key89B, 16); addHexaString(out, CFSTR("EMF"), &emf[4], 32); addHexaString(out, CFSTR("DKey"), dkey, 32); return out;}
开发者ID:HaHa80,项目名称:iOS-DataProtection,代码行数:60,
示例13: CFDataCreateWithBytesNoCopybool Image::setData(bool allDataReceived){ int length = m_data.size(); if (!length) return true;#ifdef kImageBytesCutoff // This is a hack to help with testing display of partially-loaded images. // To enable it, define kImageBytesCutoff to be a size smaller than that of the image files // being loaded. They'll never finish loading. if (length > kImageBytesCutoff) { length = kImageBytesCutoff; allDataReceived = false; }#endif #if __APPLE__ // Avoid the extra copy of bytes by just handing the byte array directly to a CFDataRef. CFDataRef data = CFDataCreateWithBytesNoCopy(0, reinterpret_cast<const UInt8*>(m_data.data()), length, kCFAllocatorNull); bool result = setNativeData(data, allDataReceived); CFRelease(data);#else bool result = setNativeData(&m_data, allDataReceived);#endif return result;}
开发者ID:oroisec,项目名称:ios,代码行数:27,
示例14: OT_ASSERT// staticbool OTKeyring::IOS_StoreSecret(const OTString& strUser, const OTPassword& thePassword, const std::string& str_display){ OT_ASSERT(strUser.Exists()); OT_ASSERT(thePassword.getMemorySize() > 0); CFStringRef service_name = CFSTR("opentxs"); CFStringRef account_name = CFStringCreateWithCString(nullptr, strUser.Get(), kCFStringEncodingUTF8); CFDataRef vData = CFDataCreateWithBytesNoCopy( nullptr, thePassword.getMemory_uint8(), thePassword.getMemorySize(), kCFAllocatorNull); const void* keys[] = {kSecClass, kSecAttrService, kSecAttrAccount, kSecValueData}; const void* values[] = {kSecClassGenericPassword, service_name, account_name, vData}; CFDictionaryRef item = CFDictionaryCreate(nullptr, keys, values, 4, nullptr, nullptr); OSStatus theError = SecItemAdd(item, nullptr); CFRelease(item); CFRelease(vData); CFRelease(account_name); if (theError != noErr) { otErr << "OTKeyring::IOS_StoreSecret: Error in SecItemAdd./n"; return false; } return true;}
开发者ID:Kodachi75,项目名称:opentxs,代码行数:35,
示例15: os_image_load_from_fileunsigned char* os_image_load_from_file(const char* filename, int* outWidth, int* outHeight, int* outChannels, int unused) { const int fileHandle = open(filename, O_RDONLY); struct stat statBuffer; fstat(fileHandle, &statBuffer); const size_t bytesInFile = (size_t)(statBuffer.st_size); uint8_t* fileData = (uint8_t*)(mmap(NULL, bytesInFile, PROT_READ, MAP_SHARED, fileHandle, 0)); if (fileData == MAP_FAILED) { fprintf(stderr, "Couldn't open file '%s' with mmap/n", filename); return NULL; } CFDataRef fileDataRef = CFDataCreateWithBytesNoCopy(NULL, fileData, bytesInFile, kCFAllocatorNull); CGDataProviderRef imageProvider = CGDataProviderCreateWithCFData(fileDataRef); const char* suffix = strrchr(filename, '.'); if (!suffix || suffix == filename) { suffix = ""; } CGImageRef image; if (strcasecmp(suffix, ".png") == 0) { image = CGImageCreateWithPNGDataProvider(imageProvider, NULL, true, kCGRenderingIntentDefault); } else if ((strcasecmp(suffix, ".jpg") == 0) || (strcasecmp(suffix, ".jpeg") == 0)) { image = CGImageCreateWithJPEGDataProvider(imageProvider, NULL, true, kCGRenderingIntentDefault); } else { munmap(fileData, bytesInFile); close(fileHandle); CFRelease(imageProvider); CFRelease(fileDataRef); fprintf(stderr, "Unknown suffix for file '%s'/n", filename); return NULL; } const int width = (int)CGImageGetWidth(image); const int height = (int)CGImageGetHeight(image); const int channels = 4; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); const int bytesPerRow = (width * channels); const int bytesInImage = (bytesPerRow * height); uint8_t* result = (uint8_t*)(malloc(bytesInImage)); const int bitsPerComponent = 8; CGContextRef context = CGBitmapContextCreate(result, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); CGContextDrawImage(context, CGRectMake(0, 0, width, height), image); CGContextRelease(context); CFRelease(image); munmap(fileData, bytesInFile); close(fileHandle); CFRelease(imageProvider); CFRelease(fileDataRef); *outWidth = width; *outHeight = height; *outChannels = channels; return result;}
开发者ID:anshulnsit,项目名称:MDig,代码行数:59,
示例16: tests/* Basic processing of input */static void tests(void){ CFArrayRef certs = NULL; CFDataRef message; // Premade message containing one certificate blob message = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, certsOnlyMsg, sizeof(certsOnlyMsg), kCFAllocatorNull); ok(certs = SecCMSCertificatesOnlyMessageCopyCertificates(message), "SecCMSCertificatesOnlyMessageCopyCertificates"); is(CFArrayGetCount(certs), 1, "certificate count is 1"); CFReleaseNull(message); // Premade message containing one certificate blob message = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, gkIPACCG2DevCertClass87, sizeof(gkIPACCG2DevCertClass87), kCFAllocatorNull); ok(certs = SecCMSCertificatesOnlyMessageCopyCertificates(message), "SecCMSCertificatesOnlyMessageCopyCertificates"); is(CFArrayGetCount(certs), 1, "certificate count is 1"); CFReleaseNull(message); SecCertificateRef another_cert = NULL; // Process a single raw certificate and make it a message isnt(another_cert = SecCertificateCreateWithBytes(NULL, _c1, sizeof(_c1)), NULL, "create certificate"); ok(message = SecCMSCreateCertificatesOnlyMessageIAP(another_cert), "create iAP specific cert only message (1cert)"); ok(certs = SecCMSCertificatesOnlyMessageCopyCertificates(message), "SecCMSCertificatesOnlyMessageCopyCertificates"); is(CFArrayGetCount(certs), 1, "certificate count is 1"); // Process two raw certificates (concatenated DER blobs) and make it a message isnt(another_cert = SecCertificateCreateWithBytes(NULL, TestDoubleCerts, sizeof(TestDoubleCerts)), NULL, "create certificate"); ok(message = SecCMSCreateCertificatesOnlyMessageIAP(another_cert), "create iAP specific cert only message (2certs)"); ok(certs = SecCMSCertificatesOnlyMessageCopyCertificates(message), "SecCMSCertificatesOnlyMessageCopyCertificates"); is(CFArrayGetCount(certs), 2, "certificate count is 2"); // Clean up CFReleaseNull(another_cert); CFReleaseNull(message); CFReleaseNull(certs);}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:47,
示例17: CFReadStreamCreateWithBytesNoCopyCF_EXPORT CFReadStreamRef CFReadStreamCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex length, CFAllocatorRef bytesDeallocator) { _CFReadDataStreamContext ctxt; CFReadStreamRef result; ctxt.data = CFDataCreateWithBytesNoCopy(alloc, bytes, length, bytesDeallocator); result = (CFReadStreamRef)_CFStreamCreateWithConstantCallbacks(alloc, &ctxt, (struct _CFStreamCallBacks *)(&readDataCallBacks), TRUE); CFRelease(ctxt.data); return result;}
开发者ID:Dyndrilliac,项目名称:WinObjC,代码行数:8,
示例18: eapolclientitemid_set_identity/** ** MiG server routines **/PRIVATE_EXTERN kern_return_teapolclientitemid_set_identity(mach_port_t server, OOBData_t auth_data, mach_msg_type_number_t auth_data_length, xmlData_t itemID_data, mach_msg_type_number_t itemID_data_length, OOBData_t id_handle, mach_msg_type_number_t id_handle_length, int * result){ EAPOLClientConfigurationRef cfg = NULL; SecIdentityRef identity = NULL; EAPOLClientItemIDRef itemID = NULL; int ret = 0; if (authorization_is_valid(auth_data, auth_data_length) == FALSE) { ret = EPERM; goto done; } ret = init_itemID_and_cfg(itemID_data, itemID_data_length, &itemID, &cfg); if (ret != 0) { goto done; } if (id_handle != NULL) { CFDataRef data; OSStatus status; data = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)id_handle, id_handle_length, kCFAllocatorNull); if (data == NULL) { ret = EINVAL; goto done; } status = EAPSecIdentityHandleCreateSecIdentity(data, &identity); CFRelease(data); if (status != noErr) { ret = ENOENT; goto done; } } if (EAPOLClientItemIDSetIdentity(itemID, kEAPOLClientDomainSystem, identity) == FALSE) { ret = ENXIO; } done: my_vm_deallocate((vm_address_t)auth_data, auth_data_length); my_vm_deallocate((vm_address_t)itemID_data, itemID_data_length); my_vm_deallocate((vm_address_t)id_handle, id_handle_length); my_CFRelease(&cfg); my_CFRelease(&itemID); my_CFRelease(&identity); *result = ret; return (KERN_SUCCESS);}
开发者ID:carriercomm,项目名称:osx-2,代码行数:61,
示例19: data/* Since some parts of the ACSharedArtImageSource are actual PDFs in their full format, we cannot use CGImage on certain data (mainly the 1st entry of PDF data). Instead call this method to retrieve a CFDataRef to the bytes pointed to with the exact length specified by the source. You are responsible for releasing this reference when you are done. */CFDataRef ACSharedArtImageSourceCreateDataAtIndex(ACSharedArtImageSourceRef isrc, size_t index){ if (index >= ACSharedArtImageSourceGetEntryCount(isrc)) return NULL; struct __ACSharedArtImageHeaderDataInfo dataInfoAtIndex = isrc->header->data_info[index]; return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,(const UInt8 *) (ACSharedArtGetBytePtr(isrc->owner) + dataInfoAtIndex.relativeOffset + isrc->owner->header->dataOffset),dataInfoAtIndex.length,kCFAllocatorNull);}
开发者ID:jlazarow,项目名称:artcore,代码行数:13,
示例20: verify_X509_cert_chainbool verify_X509_cert_chain(const std::vector<std::string> &certChain, const std::string &hostName){ // Build up CFArrayRef with all the certificates. // All this code is basically just to get into the correct structures for the Apple APIs. // Copies are avoided whenever possible. std::vector<cf_ref<SecCertificateRef>> certs; for(const auto & certBuf : certChain) { cf_ref<CFDataRef> certDataRef = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const unsigned char*>(certBuf.c_str()), certBuf.size(), kCFAllocatorNull); if(certDataRef.get() == nullptr) { return false; } cf_ref<SecCertificateRef> certObj = SecCertificateCreateWithData(nullptr, certDataRef.get()); if(certObj.get() == nullptr) { return false; } certs.push_back(std::move(certObj)); } cf_ref<CFArrayRef> certsArray = CFArrayCreate(kCFAllocatorDefault, const_cast<const void **>(reinterpret_cast<void **>(&certs[0])), certs.size(), nullptr); if(certsArray.get() == nullptr) { return false; } // Create trust management object with certificates and SSL policy. // Note: SecTrustCreateWithCertificates expects the certificate to be // verified is the first element. cf_ref<CFStringRef> cfHostName = CFStringCreateWithCStringNoCopy(kCFAllocatorDefault, hostName.c_str(), kCFStringEncodingASCII, kCFAllocatorNull); if(cfHostName.get() == nullptr) { return false; } cf_ref<SecPolicyRef> policy = SecPolicyCreateSSL(true /* client side */, cfHostName.get()); cf_ref<SecTrustRef> trust; OSStatus status = SecTrustCreateWithCertificates(certsArray.get(), policy.get(), &trust.get()); if(status == noErr) { // Perform actual certificate verification. SecTrustResultType trustResult; status = SecTrustEvaluate(trust.get(), &trustResult); if(status == noErr && (trustResult == kSecTrustResultUnspecified || trustResult == kSecTrustResultProceed)) { return true; } } return false;}
开发者ID:2uropa,项目名称:cpprestsdk,代码行数:57,
示例21: XAAttributeLoadFileDescriptorBoolean XAAttributeLoadFileDescriptor(XAAttributeRef attributeRef, int fd, char *key){ Boolean bRet = 0x00; UInt8 *bytes = 0x00; size_t size = 0x00; UInt32 position = 0x00; int options = 0x00; size = fgetxattr(fd, key, (void *)bytes, size, position, options); if(size > 0x00) { bytes = calloc(size, sizeof(*bytes)); size = fgetxattr(fd, key, (void *)bytes, size, position, options); if(size > 0x00) { CFAllocatorRef alloc = CFGetAllocator(attributeRef); CFStringRef sTemp = 0x00; CFStringRef dTemp = 0x00; CFDataRef dNice = 0x00; dNice = CFDataCreateWithBytesNoCopy(alloc, bytes, size, kCFAllocatorMalloc); sTemp = CFStringCreateWithCString(alloc, key, kCFStringEncodingUTF8); if(XAPrintableData(bytes, size)) { dTemp = CFStringCreateWithBytes(alloc, bytes, size, kCFStringEncodingUTF8, 0x00); }else { dTemp = CFCopyDescription(dNice); } XAAttributeSetData(attributeRef, dNice); CFRelease(dNice); XAAttributeSetName(attributeRef, sTemp); CFRelease(sTemp); XAAttributeSetString(attributeRef, dTemp); CFRelease(dTemp); bRet = 0x01; } } return(bRet);}
开发者ID:andreberg,项目名称:blacktree-elements,代码行数:55,
示例22: LOG_ERRORRetainPtr<CFDataRef> ShareableResource::Handle::tryWrapInCFData() const{ RefPtr<ShareableResource> resource = ShareableResource::create(*this); if (!resource) { LOG_ERROR("Failed to recreate ShareableResource from handle."); return 0; } RetainPtr<CFAllocatorRef> deallocator = adoptCF(createShareableResourceDeallocator(resource.get())); return adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(resource->data()), static_cast<CFIndex>(resource->size()), deallocator.get()));}
开发者ID:fanghongjia,项目名称:JavaScriptCore,代码行数:11,
示例23: iSCSIDaemonLogin/*! Logs into a target using a specific portal or all portals in the database. * If an argument is supplied for portal, login occurs over the specified * portal. Otherwise, the daemon will attempt to login over all portals. * @param handle a handle to a daemon connection. * @param authorization an authorization for the right kiSCSIAuthModifyLogin * @param target specifies the target and connection parameters to use. * @param portal specifies the portal to use (use NULL for all portals). * @param statusCode iSCSI response code indicating operation status. * @return an error code indicating whether the operation was successful. */errno_t iSCSIDaemonLogin(iSCSIDaemonHandle handle, AuthorizationRef authorization, iSCSITargetRef target, iSCSIPortalRef portal, enum iSCSILoginStatusCode * statusCode){ if(handle < 0 || !target || !authorization || !statusCode) return EINVAL; CFDataRef targetData = iSCSITargetCreateData(target); CFDataRef portalData = NULL; iSCSIDMsgLoginCmd cmd = iSCSIDMsgLoginCmdInit; cmd.authLength = kAuthorizationExternalFormLength; cmd.targetLength = (UInt32)CFDataGetLength(targetData); cmd.portalLength = 0; if(portal) { portalData = iSCSIPortalCreateData(portal); cmd.portalLength = (UInt32)CFDataGetLength(portalData); } AuthorizationExternalForm authExtForm; AuthorizationMakeExternalForm(authorization,&authExtForm); CFDataRef authData = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, (UInt8*)&authExtForm.bytes, kAuthorizationExternalFormLength, kCFAllocatorDefault); errno_t error = iSCSIDaemonSendMsg(handle,(iSCSIDMsgGeneric *)&cmd, authData,targetData,portalData,NULL); if(portal) CFRelease(portalData); CFRelease(targetData); if(error) return error; iSCSIDMsgLoginRsp rsp; if(recv(handle,&rsp,sizeof(rsp),0) != sizeof(rsp)) return EIO; if(rsp.funcCode != kiSCSIDLogin) return EIO; // At this point we have a valid response, process it *statusCode = rsp.statusCode; return rsp.errorCode;}
开发者ID:jeditekunum,项目名称:iSCSIInitiator,代码行数:62,
示例24: bruteforceWithAppleKeyStorechar* bruteforceWithAppleKeyStore(CFDataRef kbkeys, int (*callback)(void*,int), void* ctx){ uint64_t keybag_id = 0; int i; char* passcode = (char*) malloc(5); memset(passcode, 0, 5); AppleKeyStoreKeyBagInit(); int r = AppleKeyStoreKeyBagCreateWithData(kbkeys, &keybag_id); if (r) { printf("AppleKeyStoreKeyBagCreateWithData ret=%x/n", r); free(passcode); return NULL; } //printf("keybag id=%x/n", (uint32_t) keybag_id); AppleKeyStoreKeyBagSetSystem(keybag_id); CFDataRef data = CFDataCreateWithBytesNoCopy(0, (const UInt8*) passcode, 4, kCFAllocatorNull); io_connect_t conn = IOKit_getConnect("AppleKeyStore"); if (!AppleKeyStoreUnlockDevice(conn, data)) { CFRelease(data); return passcode; } for(i=0; i < 10000; i++) { sprintf(passcode, "%04d", i); if (callback != NULL && !(i % 10)) { if (callback(ctx, i) == -1) { printf("Bruteforce abort/n"); break; } } if (!AppleKeyStoreUnlockDevice(conn, data)) { CFRelease(data); return passcode; } } free(passcode); CFRelease(data); return NULL;}
开发者ID:0bj3ct1veC,项目名称:iphone-dataprotection,代码行数:51,
示例25: mySSLPrivKeyRSA_signstaticint mySSLPrivKeyRSA_sign(void *key, tls_hash_algorithm hash, const uint8_t *plaintext, size_t plaintextLen, uint8_t *sig, size_t *sigLen){ SecKeyRef keyRef = key; SecKeyAlgorithm algo; switch (hash) { case tls_hash_algorithm_None: return SecKeyRawSign(keyRef, kSecPaddingPKCS1, plaintext, plaintextLen, sig, sigLen); case tls_hash_algorithm_SHA1: algo = kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA1; break; case tls_hash_algorithm_SHA256: algo = kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA256; break; case tls_hash_algorithm_SHA384: algo = kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA384; break; case tls_hash_algorithm_SHA512: algo = kSecKeyAlgorithmRSASignatureDigestPKCS1v15SHA512; break; default: /* Unsupported hash - Internal error */ return errSSLInternal; } int err = errSSLInternal; CFDataRef signature = NULL; CFDataRef data = NULL; data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, plaintext, plaintextLen, kCFAllocatorNull); require(data, errOut); signature = SecKeyCreateSignature(keyRef, algo, data , NULL); require(signature, errOut); CFIndex len = CFDataGetLength(signature); const uint8_t *p = CFDataGetBytePtr(signature); require(p, errOut); require(len>=*sigLen, errOut); memcpy(sig, p, len); *sigLen = len; err = noErr;errOut: CFReleaseSafe(data); CFReleaseSafe(signature); return err;}
开发者ID:darlinghq,项目名称:darling-coretls,代码行数:49,
示例26: refPassRefPtr<SharedBuffer> ShareableResource::wrapInSharedBuffer(){ ref(); // Balanced by deref when SharedBuffer is deallocated.#if USE(CF) RetainPtr<CFAllocatorRef> deallocator = adoptCF(createShareableResourceDeallocator(this)); RetainPtr<CFDataRef> cfData = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(data()), static_cast<CFIndex>(size()), deallocator.get())); return SharedBuffer::wrapCFData(cfData.get());#elif USE(SOUP) return SharedBuffer::wrapSoupBuffer(soup_buffer_new_with_owner(data(), size(), this, [](void* data) { static_cast<ShareableResource*>(data)->deref(); }));#else ASSERT_NOT_REACHED(); return nullptr;#endif}
开发者ID:mu326668629,项目名称:webkit,代码行数:15,
示例27: NZCGImageCreateUsingWebPDataCGImageRef NZCGImageCreateUsingWebPData(CFDataRef webPData){ uint8 *y = NULL, *u = NULL, *v = NULL; int32_t width, height; if (CFDataGetLength(webPData) > INT_MAX) // highly unlikely to happen; just checking anyway return NULL; // Step 1: Decode the data. if (WebPDecode(CFDataGetBytePtr(webPData), (int)CFDataGetLength(webPData), &y, &u, &v, &width, &height) == webp_success) { const int32_t depth = 32; const int wordsPerLine = (width*depth+31)/32; size_t pixelBytesLength = 4*height*wordsPerLine; // Google's documentation is incorrect here; the length has to be quadrupled or we'll have an overrun uint32 *pixelBytes = malloc(pixelBytesLength); CFDataRef pixelData; CGDataProviderRef dataProvider; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGImageRef theImage; // Step 2: Convert the YUV data into RGB. YUV420toRGBA(y, u, v, wordsPerLine, width, height, pixelBytes); // Step 3: Convert the RGB data into a CGImageRef. pixelData = CFDataCreateWithBytesNoCopy(NULL, (const UInt8 *)pixelBytes, pixelBytesLength, NULL); dataProvider = CGDataProviderCreateWithCFData(pixelData); theImage = CGImageCreate(width, height, 8, // each component is one byte or 8 bits large 32, // our data has four components wordsPerLine*4, // there are 32 bits or 4 bytes in a word colorSpace, kCGBitmapByteOrder32Host, // our data is in host-endian format dataProvider, NULL, // we don't care about decode arrays true, // sure, why not interpolate? kCGRenderingIntentDefault); // Finally, clean up memory. CGColorSpaceRelease(colorSpace); CGDataProviderRelease(dataProvider); CFRelease(pixelData); free(y); return theImage; } fprintf(stderr, "NZCGWebPFunctions: The data provided is not in WebP format./n"); return NULL;}
开发者ID:Web5design,项目名称:weppy,代码行数:48,
示例28: mainintmain(int argc, char * argv[]){ const void * data; int data_len; CFDataRef cfdata; const char * type; CFDataRef xml_data; if (argc < 3) { usage(argv[0]); } type = argv[1]; argv += 2; argc -= 2; if (strcmp(type, "ip") == 0) { data = data_from_ip(argc, argv, &data_len); } else if (strcmp(type, "uint8") == 0) { data = data_from_uint8(argc, argv, &data_len); } else if (strcmp(type, "uint16") == 0) { data = data_from_uint16(argc, argv, &data_len); } else if (strcmp(type, "uint32") == 0) { data = data_from_uint32(argc, argv, &data_len); } else if (strcmp(type, "string") == 0) { data = argv[0]; data_len = strlen(data); } else { fprintf(stderr, "unrecognized type '%s'/n", type); exit(2); } if (data == NULL) { exit(2); } cfdata = CFDataCreateWithBytesNoCopy(NULL, data, data_len, kCFAllocatorNull); xml_data = CFPropertyListCreateXMLData(NULL, cfdata); CFRelease(cfdata); fwrite(CFDataGetBytePtr(xml_data), CFDataGetLength(xml_data), 1, stdout); CFRelease(xml_data); exit(0); return (0);}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:48,
注:本文中的CFDataCreateWithBytesNoCopy函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CFDataGetBytePtr函数代码示例 C++ CFDataCreate函数代码示例 |