2 #include <CoreFoundation/CoreFoundation.h>
3 #include <Security/Security.h>
8 /* ==========================================================================
9 This test is to ensure we do not regress the fix for radar
10 <rdar://problem/9583502> Security CF runtime objects do not implement CF's Hash function
11 ========================================================================== */
13 static void tests(void)
15 CFDictionaryRef query
= CFDictionaryCreate(NULL
, (const void **)&kSecClass
, (const void **)&kSecClassCertificate
, 1, &kCFTypeDictionaryKeyCallBacks
, &kCFTypeDictionaryValueCallBacks
);
16 ok_status(NULL
!= query
, "Dictionary Creation"); // 1
18 CFTypeRef result
= NULL
;
19 OSStatus err
= SecItemCopyMatching(query
, &result
);
20 ok_status(noErr
== err
&& NULL
!= result
, "SecItemCopyMatching"); // 2
25 SecCertificateRef cert
= (SecCertificateRef
)result
;
28 CFDataRef cert_data
= SecCertificateCopyData(cert
);
29 ok_status(NULL
!= cert_data
, "SecCertificateCopyData"); // 3
31 SecCertificateRef certs
[5];
34 for (int iCnt
= 1; iCnt
< 5; iCnt
++)
37 cert
= SecCertificateCreateWithData(NULL
, cert_data
);
38 ok_status(NULL
!= cert_data
, "SecCertificateCreateWithData"); // 4 5 6 7
42 CFSetRef aSet
= CFSetCreate(NULL
, (const void **)certs
, 4, &kCFTypeSetCallBacks
);
43 ok_status(NULL
!= aSet
, "CFSetCreate"); // 8
46 CFIndex count
= CFSetGetCount(aSet
);
47 ok_status(count
== 1, "CFSetGetCount"); // 9
50 for (int iCnt
= 0; iCnt
< 5; iCnt
++)
62 int main(int argc
, char *const *argv
)
65 if (!tests_begin(argc
, argv
))
66 BAIL_OUT("tests_begin failed");