2 // Copyright 2015 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>
15 #include <TargetConditionals.h>
17 #include <Security/SecItemPriv.h>
20 #if !TARGET_OS_SIMULATOR
26 keybag_handle_t handle;
31 result = aks_create_bag("foo", 3, kAppleKeyStoreAsymmetricBackupBag, &handle);
33 errx(1, "aks_create_bag: %08x", result);
35 result = aks_save_bag(handle, &data, &length);
37 errx(1, "aks_save_bag");
39 return [NSData dataWithBytes:data length:length];
41 #endif /* TARGET_OS_SIMULATOR */
43 int main (int argc, const char * argv[])
46 NSData *bag = NULL, *password = NULL;
48 #if !TARGET_OS_SIMULATOR
50 password = [NSData dataWithBytes:"foo" length:3];
53 NSLog(@"backup bag: %@", bag);
55 NSData *backup = (__bridge NSData *)_SecKeychainCopyBackup((__bridge CFDataRef)bag, (__bridge CFDataRef)password);
57 NSLog(@"backup data: %@", backup);
58 errx(1, "got backup");