2 // Copyright 2016 Apple. All rights reserved.
6 * This is to fool os services to not provide the Keychain manager
7 * interface tht doens't work since we don't have unified headers
8 * between iOS and OS X. rdar://23405418/
10 #define __KEYCHAINCORE__ 1
12 #include <Foundation/Foundation.h>
13 #include <Security/Security.h>
14 #include <Security/SecItemPriv.h>
15 #include <TargetConditionals.h>
19 int main (int argc, const char * argv[])
23 NSDictionary *addItem = @{
24 (id)kSecClass : (id)kSecClassGenericPassword,
25 (id)kSecAttrLabel : @"vpn-test-label",
26 (id)kSecAttrAccount : @"vpn-test-account",
27 (id)kSecValueData : @"password",
28 (id)kSecUseSystemKeychain : @YES,
31 NSDictionary *querySystemItem = @{
32 (id)kSecClass : (id)kSecClassGenericPassword,
33 (id)kSecAttrLabel : @"vpn-test-label",
34 (id)kSecAttrAccount : @"vpn-test-account",
35 (id)kSecUseSystemKeychain : @YES,
38 NSDictionary *queryItem = @{
39 (id)kSecClass : (id)kSecClassGenericPassword,
40 (id)kSecAttrLabel : @"vpn-test-label",
41 (id)kSecAttrAccount : @"vpn-test-account",
44 (void)SecItemDelete((__bridge CFDictionaryRef)querySystemItem);
47 if (!SecItemAdd((__bridge CFDictionaryRef)addItem, NULL))
48 errx(1, "failed to add");
51 if (!SecItemCopyMatching((__bridge CFDictionaryRef)queryItem, NULL))
52 errx(1, "failed to find in user + system");
54 if (!SecItemCopyMatching((__bridge CFDictionaryRef)querySystemItem, NULL))
55 errx(1, "failed to find in system");
58 if (!SecItemDelete((__bridge CFDictionaryRef)querySystemItem))
59 errx(1, "failed to clean up");