2 * Copyright (c) 2015 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #define __KEYCHAINCORE__ 1
26 #include <Foundation/Foundation.h>
27 #include <CoreFoundation/CoreFoundation.h>
28 #include <Security/Security.h>
29 #include <Security/SecItemPriv.h>
30 #include <utilities/array_size.h>
31 #include <utilities/SecCFRelease.h>
35 #include "Security_regressions.h"
37 // If we're running no server this test isn't valid
38 #if defined(NO_SERVER) && NO_SERVER
39 #define DO_TESTS false
45 static NSString* const kBlueToothServiceName = @"BluetoothGlobal";
47 /* Test presence of properly migrated items into system keychain. */
48 static void tests(void)
51 NSDictionary *whoami = NULL;
53 whoami = CFBridgingRelease(_SecSecuritydCopyWhoAmI(NULL));
55 NSLog(@"whoami: %@", whoami);
58 * Check for multi user mode and its expected behavior (since its different)
61 bool multiUser = (whoami[@"musr"]) ? true : false;
64 * Check we can't find it in our keychain
67 skip("No Server mode, test not valid", 2, DO_TESTS)
69 (__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword,
70 (__bridge id)kSecAttrService : kBlueToothServiceName,
73 is(SecItemCopyMatching((CFTypeRef)query, NULL), multiUser ? errSecItemNotFound : noErr, "Bluetooth item - user keychain");
76 (__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword,
77 (__bridge id)kSecAttrService : kBlueToothServiceName,
78 (__bridge id)kSecUseSystemKeychain : @YES,
81 is(SecItemCopyMatching((CFTypeRef)query, NULL), noErr, "Bluetooth item - system keychain");
85 int si_17_item_system_bluetooth(int argc, char *const *argv)