这篇教程C++ CFReleaseNull函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CFReleaseNull函数的典型用法代码示例。如果您正苦于以下问题:C++ CFReleaseNull函数的具体用法?C++ CFReleaseNull怎么用?C++ CFReleaseNull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CFReleaseNull函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: tls_create_trust_from_certsstatic int tls_create_trust_from_certs(const SSLCertificate *cert, SecTrustRef *trustRef){ int err; CFMutableArrayRef certArray = NULL; CFDataRef certData = NULL; SecCertificateRef cfCert = NULL; if(cert==NULL) { test_printf("No certs, do not create SecTrustRef/n"); *trustRef = NULL; return 0; } certArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); while(cert) { base64_dump(cert->derCert, "CERTIFICATE"); require_action((certData = CFDataCreate(kCFAllocatorDefault, cert->derCert.data, cert->derCert.length)), out, err = errSecAllocate); require_action((cfCert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)), out, err = errSecAllocate); CFArrayAppendValue(certArray, cfCert); CFReleaseNull(cfCert); CFReleaseNull(certData); cert=cert->next; } require_noerr((err=SecTrustCreateWithCertificates(certArray, NULL, trustRef)), out);out: CFReleaseSafe(certData); CFReleaseSafe(cfCert); CFReleaseSafe(certArray); return err;}
开发者ID:darlinghq,项目名称:darling-coretls,代码行数:33,
示例2: der_decode_arrayconst uint8_t* der_decode_array(CFAllocatorRef allocator, CFOptionFlags mutability, CFArrayRef* array, CFErrorRef *error, const uint8_t* der, const uint8_t *der_end){ if (NULL == der) return NULL; CFMutableArrayRef result = CFArrayCreateMutable(allocator, 0, &kCFTypeArrayCallBacks); const uint8_t *elements_end; const uint8_t *current_element = ccder_decode_sequence_tl(&elements_end, der, der_end); while (current_element != NULL && current_element < elements_end) { CFPropertyListRef element = NULL; current_element = der_decode_plist(allocator, mutability, &element, error, current_element, elements_end); if (current_element) { CFArrayAppendValue(result, element); CFReleaseNull(element); } } if (current_element) { *array = result; result = NULL; } CFReleaseNull(result); return current_element;}
开发者ID:Andy168,项目名称:iphone-dataprotection.keychainviewer,代码行数:29,
示例3: der_decode_key_valuestatic const uint8_t* der_decode_key_value(CFAllocatorRef allocator, CFOptionFlags mutability, CFPropertyListRef* key, CFPropertyListRef* value, CFErrorRef *error, const uint8_t* der, const uint8_t *der_end){ const uint8_t *payload_end = 0; const uint8_t *payload = ccder_decode_constructed_tl(CCDER_CONSTRUCTED_SEQUENCE, &payload_end, der, der_end); if (NULL == payload) { SecCFDERCreateError(kSecDERErrorUnknownEncoding, CFSTR("Unknown data encoding, expected CCDER_CONSTRUCTED_SEQUENCE"), NULL, error); return NULL; } CFTypeRef keyObject = NULL; CFTypeRef valueObject = NULL; payload = der_decode_plist(allocator, mutability, &keyObject, error, payload, payload_end); payload = der_decode_plist(allocator, mutability, &valueObject, error, payload, payload_end); if (payload != NULL) { *key = keyObject; *value = valueObject; } else { CFReleaseNull(keyObject); CFReleaseNull(valueObject); } return payload;}
开发者ID:Andy168,项目名称:iphone-dataprotection.keychainviewer,代码行数:28,
示例4: SOSRecoveryKeyBagDestroystatic void SOSRecoveryKeyBagDestroy(CFTypeRef aObj) { SOSRecoveryKeyBagRef rb = (SOSRecoveryKeyBagRef) aObj; CFReleaseNull(rb->accountDSID); CFReleaseNull(rb->generation); CFReleaseNull(rb->recoveryKeyBag);}
开发者ID:darlinghq,项目名称:darling-security,代码行数:7,
示例5: ensureKeychainExistsstatic void ensureKeychainExists(void) { CFDictionaryRef query = CFDictionaryCreate(0, &kSecClass, &kSecClassInternetPassword, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFTypeRef results = NULL; is_status(SecItemCopyMatching(query, &results), errSecItemNotFound, "expected nothing got %@", results); CFReleaseNull(query); CFReleaseNull(results);}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:7,
示例6: tls_get_peer_certs/* Convert cert in DER format into an CFArray of SecCertificateRef */CFArrayReftls_get_peer_certs(const SSLCertificate *certs){ const SSLCertificate *cert; CFMutableArrayRef certArray = NULL; CFDataRef certData = NULL; SecCertificateRef cfCert = NULL; certArray = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); require(certArray, out); cert = certs; while(cert) { require((certData = CFDataCreate(kCFAllocatorDefault, cert->derCert.data, cert->derCert.length)), out); require((cfCert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)), out); CFArrayAppendValue(certArray, cfCert); CFReleaseNull(cfCert); CFReleaseNull(certData); cert=cert->next; } return certArray;out: CFReleaseNull(cfCert); CFReleaseNull(certData); CFReleaseNull(certArray); return NULL;}
开发者ID:darlinghq,项目名称:darling-security,代码行数:30,
示例7: SecItemCopyAttributeDictionarystatic CFDictionaryRefSecItemCopyAttributeDictionary(CFTypeRef ref) { CFDictionaryRef refDictionary = NULL; CFTypeID typeID = CFGetTypeID(ref); if (typeID == SecKeyGetTypeID()) { refDictionary = SecKeyCopyAttributeDictionary((SecKeyRef)ref); } else if (typeID == SecCertificateGetTypeID()) { refDictionary = SecCertificateCopyAttributeDictionary((SecCertificateRef)ref); } else if (typeID == SecIdentityGetTypeID()) { assert(false); SecIdentityRef identity = (SecIdentityRef)ref; SecCertificateRef cert = NULL; SecKeyRef key = NULL; if (!SecIdentityCopyCertificate(identity, &cert) && !SecIdentityCopyPrivateKey(identity, &key)) { CFDataRef data = SecCertificateCopyData(cert); CFDictionaryRef key_dict = SecKeyCopyAttributeDictionary(key); if (key_dict && data) { refDictionary = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, key_dict); CFDictionarySetValue((CFMutableDictionaryRef)refDictionary, CFSTR(CERTIFICATE_DATA_COLUMN_LABEL), data); } CFReleaseNull(key_dict); CFReleaseNull(data); } CFReleaseNull(cert); CFReleaseNull(key); } else { refDictionary = NULL; } return refDictionary;}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:35,
示例8: testsstatic void tests(void){ SOSCircleRef circle = SOSCircleCreate(NULL, CFSTR("TEST DOMAIN"), NULL); ok(NULL != circle, "Circle creation"); ok(0 == SOSCircleCountPeers(circle), "Zero peers"); //SecKeyRef publicKey = NULL; SecKeyRef dev_a_key = NULL; SecKeyRef dev_b_key = NULL; CFErrorRef error = NULL; CFDataRef cfpassword = CFDataCreate(NULL, (uint8_t *) "FooFooFoo", 10); if(cfpassword == NULL) printf("WTF/n"); CFDataRef parameters = SOSUserKeyCreateGenerateParameters(&error); ok(parameters, "No parameters!"); ok(error == NULL, "Error: (%@)", error); CFReleaseNull(error); SecKeyRef user_privkey = SOSUserKeygen(cfpassword, parameters, &error); CFReleaseNull(parameters); SOSFullPeerInfoRef peer_a_full_info = SOSCreateFullPeerInfoFromName(CFSTR("Peer A"), &dev_a_key, NULL); SOSFullPeerInfoRef peer_b_full_info = SOSCreateFullPeerInfoFromName(CFSTR("Peer B"), &dev_b_key, NULL); ok(SOSCircleRequestAdmission(circle, user_privkey, peer_a_full_info, NULL)); ok(SOSCircleRequestAdmission(circle, user_privkey, peer_a_full_info, NULL)); ok(SOSCircleRequestAdmission(circle, user_privkey, peer_a_full_info, NULL)); ok(SOSCircleAcceptRequest(circle, user_privkey, peer_a_full_info, SOSFullPeerInfoGetPeerInfo(peer_a_full_info), NULL)); ok(!SOSCircleRequestAdmission(circle, user_privkey, peer_a_full_info, NULL)); ok(SOSCircleRequestAdmission(circle, user_privkey, peer_b_full_info, NULL)); ok(SOSCircleCountPeers(circle) == 1, "Peer count"); size_t size = SOSCircleGetDEREncodedSize(circle, &error); uint8_t buffer[size]; uint8_t* start = SOSCircleEncodeToDER(circle, &error, buffer, buffer + sizeof(buffer)); ok(start, "successful encoding"); ok(start == buffer, "Used whole buffer"); const uint8_t *der = buffer; SOSCircleRef inflated = SOSCircleCreateFromDER(NULL, &error, &der, buffer + sizeof(buffer)); ok(inflated, "inflated"); ok(CFEqualSafe(inflated, circle), "Compares"); ok(SOSCircleRemovePeer(circle, user_privkey, peer_a_full_info, SOSFullPeerInfoGetPeerInfo(peer_a_full_info), NULL)); ok(SOSCircleCountPeers(circle) == 0, "Peer count"); CFReleaseNull(dev_a_key); CFReleaseNull(cfpassword);}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:59,
示例9: asynchttp_freevoid asynchttp_free(asynchttp_t *http) { if (http) { CFReleaseNull(http->request); CFReleaseNull(http->response); CFReleaseNull(http->data); CFReleaseNull(http->stream); dispatch_release_null(http->timer); }}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:9,
示例10: persistentRefIsstatic void persistentRefIs(CFDataRef pref, CFDataRef data) { CFMutableDictionaryRef dict = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); CFTypeRef result = NULL; CFDictionaryAddValue(dict, kSecValuePersistentRef, pref); CFDictionaryAddValue(dict, kSecReturnData, kCFBooleanTrue); ok_status(SecItemCopyMatching(dict, &result), "lookup item data by persistent ref"); ok(CFEqual(data, result), "result %@ equals expected data %@", result, data); CFReleaseNull(result); CFReleaseNull(dict);}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:10,
示例11: SOSCoderDisposevoid SOSCoderDispose(SOSCoderRef coder){ if (coder) { CFReleaseNull(coder->sessRef); CFReleaseNull(coder->pendingResponse); CFReleaseNull(coder->peer_id); free(coder); } coder = NULL;}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:10,
示例12: AppendEncryptedSignaturestatic uint8_t* AppendEncryptedSignature(SecOTRSessionRef session, const cc_unit* s, bool usePrime, CFMutableDataRef appendTo){ CFMutableDataRef signature = CFDataCreateMutable(kCFAllocatorDefault, 0); CFMutableDataRef mbData = CFDataCreateMutable(kCFAllocatorDefault, 0); CFMutableDataRef mb = CFDataCreateMutable(kCFAllocatorDefault, 0); SecFDHKAppendPublicSerialization(session->_myKey, mbData); SecPDHKAppendSerialization(session->_theirKey, mbData); CFIndex publicKeyOffset = CFDataGetLength(mbData); SecOTRPublicIdentityRef myPublic = SecOTRPublicIdentityCopyFromPrivate(kCFAllocatorDefault, session->_me, NULL); AppendPublicKey(mbData, myPublic); CFReleaseNull(myPublic); AppendLong(mbData, session->_keyID); DeriveAndAppendSHA256HMAC(mb, kExponentiationUnits, s, usePrime ? kM1Prime : kM1, (size_t)CFDataGetLength(mbData), CFDataGetBytePtr(mbData)); CFDataDeleteBytes(mbData, CFRangeMake(0, publicKeyOffset)); CFMutableDataRef xb = mbData; mbData = NULL; SecOTRFIAppendSignature(session->_me, mb, signature, NULL); CFReleaseNull(mb); AppendCFDataAsDATA(xb, signature); CFReleaseNull(signature); CFIndex dataLength = CFDataGetLength(xb); CFIndex signatureStartIndex = CFDataGetLength(appendTo); /* 64 bits cast: We are appending the signature we just generated, which is never bigger than 2^32 bytes. */ assert(((unsigned long)dataLength)<=UINT32_MAX); /* debug check, correct as long as CFIndex is a signed long */ AppendLong(appendTo, (uint32_t)dataLength); uint8_t *destination = CFDataIncreaseLengthAndGetMutableBytes(appendTo, dataLength); uint8_t c[kOTRAuthKeyBytes]; DeriveOTR128BitPairFromS(kCs, kExponentiationUnits, s, sizeof(c), usePrime ? NULL : c, sizeof(c), usePrime ? c : NULL); AES_CTR_IV0_Transform(sizeof(c), c, (size_t)dataLength, CFDataGetBytePtr(xb), destination); bzero(c, sizeof(c)); CFReleaseNull(xb); return CFDataGetMutableBytePtr(appendTo) + signatureStartIndex;}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:55,
示例13: SOSAccountSetHSAPubKeyExpectedbool SOSAccountSetHSAPubKeyExpected(SOSAccountRef account, CFDataRef pubKeyBytes, CFErrorRef *error) { bool retval = false; SecKeyRef publicKey = SecKeyCreateFromPublicBytes(NULL, kSecECDSAAlgorithmID, CFDataGetBytePtr(pubKeyBytes), CFDataGetLength(pubKeyBytes)); CFStringRef peerID = SOSCopyIDOfKey(publicKey, error); require(sosAccountSetPreApprovedInfo(account, peerID, error), errOut); retval = true;errOut: CFReleaseNull(publicKey); CFReleaseNull(peerID); return retval;}
开发者ID:darlinghq,项目名称:darling-security,代码行数:11,
示例14: countPeersstatic int countPeers(SOSAccountRef account, bool active) { CFErrorRef error = NULL; CFArrayRef peers; if(active) peers = SOSAccountCopyActivePeers(account, &error); else peers = SOSAccountCopyPeers(account, &error); int retval = (int) CFArrayGetCount(peers); CFReleaseNull(error); CFReleaseNull(peers); return retval;}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:11,
示例15: tests/* Test basic add delete update copy matching stuff. */static void tests(SecKeyDescriptor *descriptor){ const uint8_t *keyData = (const uint8_t *)"abc"; CFIndex keyDataLength = 3; SecKeyEncoding encoding = kSecKeyEncodingRaw; ok(customKey = SecKeyCreate(kCFAllocatorDefault, descriptor, keyData, keyDataLength, encoding), "create custom key"); is(customKey, initedCustomKey, "CustomKeyInit got the right key"); SecPadding padding = kSecPaddingPKCS1; const uint8_t *src = (const uint8_t *)"defgh"; size_t srcLen = 5; uint8_t dst[5]; size_t dstLen = 5; ok_status(SecKeyDecrypt(customKey, padding, src, srcLen, dst, &dstLen), "SecKeyDecrypt"); ok_status(SecKeyEncrypt(customKey, padding, src, srcLen, dst, &dstLen), "SecKeyEncrypt"); ok_status(SecKeyRawSign(customKey, padding, src, srcLen, dst, &dstLen), "SecKeyRawSign"); ok_status(SecKeyRawVerify(customKey, padding, src, srcLen, dst, dstLen), "SecKeyRawVerify"); is(SecKeyGetSize(customKey, kSecKeyKeySizeInBits), (size_t)5*8, "SecKeyGetSize"); CFDictionaryRef attrDict = NULL; ok(attrDict = SecKeyCopyAttributeDictionary(customKey), "SecKeyCopyAttributeDictionary"); CFReleaseNull(attrDict); CFDataRef pubdata = NULL; ok(SecKeyCopyPublicBytes(customKey, &pubdata) != 0, "SecKeyCopyPublicBytes"); CFReleaseNull(pubdata); CFDataRef wrapped; wrapped = _SecKeyCopyWrapKey(customKey, kSecKeyWrapPublicKeyPGP, pubdata, NULL, NULL, NULL); ok(wrapped == NULL, "_SecKeyCopyWrapKey"); CFReleaseNull(wrapped); wrapped = _SecKeyCopyUnwrapKey(customKey, kSecKeyWrapPublicKeyPGP, pubdata, NULL, NULL, NULL); ok(wrapped == NULL, "_SecKeyCopyUnwrapKey"); CFReleaseNull(wrapped); //ok(SecKeyGeneratePair(customKey, ), "SecKeyGeneratePair"); ok(SecKeyGetTypeID() != 0, "SecKeyGetTypeID works"); if (customKey) { CFRelease(customKey); customKey = NULL; }}
开发者ID:darlinghq,项目名称:darling-security,代码行数:53,
示例16: acceptApplicantsstatic bool acceptApplicants(SOSAccountRef account, CFIndex count) { bool retval = false; CFErrorRef error = NULL; CFArrayRef applicants = SOSAccountCopyApplicants(account, &error); ok(applicants && CFArrayGetCount(applicants) == count, "See %ld applicants %@ (%@)", count, applicants, error); CFReleaseNull(error); require_quiet(CFArrayGetCount(applicants) == count, xit); ok((retval=SOSAccountAcceptApplicants(account, applicants, &error)), "Accept applicants into the fold"); CFReleaseNull(error); CFReleaseSafe(applicants);xit: return retval;}
开发者ID:darlinghq,项目名称:darling-security,代码行数:13,
示例17: SOSCoderCreateSOSCoderRef SOSCoderCreate(SOSPeerInfoRef peerInfo, SOSFullPeerInfoRef myPeerInfo, CFErrorRef *error) { CFAllocatorRef allocator = CFGetAllocator(peerInfo); SOSCoderRef coder = calloc(1, sizeof(struct __OpaqueSOSCoder)); CFErrorRef localError = NULL; SecOTRFullIdentityRef myRef = NULL; SecOTRPublicIdentityRef peerRef = NULL; SecKeyRef privateKey = NULL; SecKeyRef publicKey = NULL; if (myPeerInfo && peerInfo) { privateKey = SOSFullPeerInfoCopyDeviceKey(myPeerInfo, &localError); require_quiet(privateKey, errOut); myRef = SecOTRFullIdentityCreateFromSecKeyRef(allocator, privateKey, &localError); require_quiet(myRef, errOut); CFReleaseNull(privateKey); publicKey = SOSPeerInfoCopyPubKey(peerInfo); peerRef = SecOTRPublicIdentityCreateFromSecKeyRef(allocator, publicKey, &localError); require_quiet(peerRef, errOut); coder->sessRef = SecOTRSessionCreateFromID(allocator, myRef, peerRef); require(coder->sessRef, errOut); coder->waitingForDataPacket = false; coder->pendingResponse = NULL; CFReleaseNull(publicKey); CFReleaseNull(privateKey); CFReleaseNull(myRef); CFReleaseNull(peerRef); } else { secnotice("coder", "NULL Coder requested, no transport security"); } SOSCoderStart(coder, NULL); return coder;errOut: secerror("Coder create failed: %@/n", localError ? localError : (CFTypeRef)CFSTR("No local error in SOSCoderCreate")); secerror("Coder create failed: %@/n", error ? *error : (CFTypeRef)CFSTR("WTF NULL?")); CFReleaseNull(myRef); CFReleaseNull(peerRef); CFReleaseNull(publicKey); CFReleaseNull(privateKey); free(coder); return NULL;}
开发者ID:unofficial-opensource-apple,项目名称:Security,代码行数:55,
示例18: SOSRecoveryKeyBagCopyFormatDescriptionstatic CFStringRef SOSRecoveryKeyBagCopyFormatDescription(CFTypeRef aObj, CFDictionaryRef formatOptions) { SOSRecoveryKeyBagRef rb = (SOSRecoveryKeyBagRef) aObj; CFStringRef gcString = SOSGenerationCountCopyDescription(rb->generation); CFStringRef rkbID = SOSCopyIDOfDataBufferWithLength(rb->recoveryKeyBag, 8, NULL); CFMutableStringRef description = CFStringCreateMutable(kCFAllocatorDefault, 0); CFStringAppendFormat(description, NULL, CFSTR("<[email C++ CFReleaseSafe函数代码示例 C++ CFRelease函数代码示例
|