Skip to content

Commit 2ea8fb6

Browse files
authored
Merge pull request #103 from square/dfed/touchID_macOS
Allow TouchID to be use on macOS
2 parents d74df19 + 841ac08 commit 2ea8fb6

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
language: objective-c
2-
osx_image: xcode8
2+
osx_image: xcode8.2
33
before_script:
44
- bundle install
55
script:
6-
- xcodebuild -project Valet.xcodeproj -scheme "Valet iOS" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 6s" -configuration Debug -PBXBuildsContinueAfterErrors=0 ACTIVE_ARCH_ONLY=0 build test
6+
- xcodebuild -project Valet.xcodeproj -scheme "Valet iOS" -sdk iphonesimulator -destination "platform=iOS Simulator,OS=10.1,name=iPhone 7" -configuration Debug -PBXBuildsContinueAfterErrors=0 ACTIVE_ARCH_ONLY=0 build test
77
- xcodebuild -project Valet.xcodeproj -scheme "Valet Mac" -sdk macosx10.12 -configuration Debug -destination "platform=OS X" -PBXBuildsContinueAfterErrors=0 build test
8-
- xcodebuild -project Valet.xcodeproj -scheme "Valet-iOS" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 6s" -configuration Debug -PBXBuildsContinueAfterErrors=0 ACTIVE_ARCH_ONLY=0 build
8+
- xcodebuild -project Valet.xcodeproj -scheme "Valet-iOS" -sdk iphonesimulator -destination "platform=iOS Simulator,OS=10.1,name=iPhone 7" -configuration Debug -PBXBuildsContinueAfterErrors=0 ACTIVE_ARCH_ONLY=0 build
99
- xcodebuild -project Valet.xcodeproj -scheme "Valet-Mac" -sdk macosx10.12 -configuration Debug -destination "platform=OS X" -PBXBuildsContinueAfterErrors=0 build
1010
- pod lib lint --verbose --fail-fast

Valet.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Valet'
3-
s.version = '2.2.3'
3+
s.version = '2.3.0'
44
s.license = 'Apache License, Version 2.0'
55
s.summary = 'Valet lets you securely store data in the iOS or OS X Keychain without knowing a thing about how the Keychain works. It\'s easy. We promise.'
66
s.homepage = 'https://github.com/square/Valet'

Valet/VALSecureEnclaveValet.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@
2727

2828
typedef NS_ENUM(NSUInteger, VALAccessControl) {
2929
/// Access to keychain elements requires user presence verification via Touch ID or device Passcode. Keychain elements are still accessible by Touch ID even if fingers are added or removed. Touch ID does not have to be available or enrolled.
30-
/// @version Available on iOS 8 or later, and Mac OS 10.11 or later.
30+
/// @version Available on iOS 8 or later, and macOS 10.11 or later.
3131
VALAccessControlUserPresence = 1,
3232

3333
/// Access to keychain elements requires user presence verification via any finger enrolled in Touch ID. Keychain elements are still accessible by Touch ID even if fingers are added or removed. Touch ID must be available and at least one finger must be enrolled.
34-
/// @version Available on iOS 9 or later.
34+
/// @version Available on iOS 9 or later, and macOS 10.12 or later.
3535
VALAccessControlTouchIDAnyFingerprint = 2,
3636

3737
/// Access to keychain elements requires user presence verification via fingers currently enrolled in Touch ID. Previously written keychain elements become inaccessible when fingers are added or removed. Touch ID must be available and at least one finger must be enrolled.
38-
/// @version Available on iOS 9 or later.
38+
/// @version Available on iOS 9 or later, and macOS 10.12 or later.
3939
VALAccessControlTouchIDCurrentFingerprintSet = 3,
4040

4141
/// Access to keychain elements requires user presence verification via device Passcode.
42-
/// @version Available on iOS 9 or later, and Mac OS 10.11 or later.
42+
/// @version Available on iOS 9 or later, and macOS 10.11 or later.
4343
VALAccessControlDevicePasscode = 4,
4444
};
4545

4646

47-
/// Reads and writes keychain elements that are stored on the Secure Enclave (available on iOS 8.0 and later and Mac OS 10.11 and later) using accessibility attribute VALAccessibilityWhenPasscodeSetThisDeviceOnly. Accessing or modifying these keychain elements will require the user to confirm their presence via Touch ID or passcode entry. If no passcode is set on the device, the below methods will fail. Data is removed from the Secure Enclave when the user removes a passcode from the device. Use the userPrompt methods to display custom text to the user in Apple's Touch ID and passcode entry UI.
48-
/// @version Available on iOS 8 or later, and Mac OS 10.11 or later.
47+
/// Reads and writes keychain elements that are stored on the Secure Enclave (available on iOS 8.0 and later and macOS 10.11 and later) using accessibility attribute VALAccessibilityWhenPasscodeSetThisDeviceOnly. Accessing or modifying these keychain elements will require the user to confirm their presence via Touch ID or passcode entry. If no passcode is set on the device, the below methods will fail. Data is removed from the Secure Enclave when the user removes a passcode from the device. Use the userPrompt methods to display custom text to the user in Apple's Touch ID and passcode entry UI.
48+
/// @version Available on iOS 8 or later, and macOS 10.11 or later.
4949
@interface VALSecureEnclaveValet : VALValet
5050

5151
/// @return YES if Secure Enclave storage is supported on the current iOS version (8.0 and later).

Valet/VALSecureEnclaveValet.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
/// Compiler flag for building against an SDK where VALAccessControlTouchIDAnyFingerprint and VALAccessControlTouchIDCurrentFingerprintSet are available.
28-
#define VAL_ACCESS_CONTROL_TOUCH_ID_SDK_AVAILABLE (TARGET_OS_IPHONE && __IPHONE_9_0)
28+
#define VAL_ACCESS_CONTROL_TOUCH_ID_SDK_AVAILABLE ((TARGET_OS_IPHONE && __IPHONE_9_0) || (TARGET_OS_MAC && __MAC_10_12))
2929

3030
/// Compiler flag for building against an SDK where VALAccessControlDevicePasscode is available.
3131
#define VAL_ACCESS_CONTROL_DEVICE_PASSCODE_SDK_AVAILABLE ((TARGET_OS_IPHONE && __IPHONE_9_0) || (TARGET_OS_MAC && __MAC_10_11))
@@ -80,6 +80,18 @@ + (BOOL)_macOSElCapitanOrLater;
8080
#endif
8181
}
8282

83+
+ (BOOL)_macOSSierraOrLater;
84+
{
85+
#if TARGET_OS_MAC && __MAC_10_12
86+
#pragma clang diagnostic push
87+
#pragma clang diagnostic ignored "-Wtautological-compare"
88+
return (&kSecAttrTokenIDSecureEnclave != NULL);
89+
#pragma clang diagnostic pop
90+
#else
91+
return NO;
92+
#endif
93+
}
94+
8395
+ (BOOL)_iOS8OrLater;
8496
{
8597
#if TARGET_OS_IPHONE
@@ -112,7 +124,7 @@ + (BOOL)_currentOSSupportedForAccessControl:(VALAccessControl)accessControl;
112124

113125
case VALAccessControlTouchIDAnyFingerprint:
114126
case VALAccessControlTouchIDCurrentFingerprintSet:
115-
return [self _iOS9OrLater];
127+
return [self _iOS9OrLater] || [self _macOSSierraOrLater];
116128

117129
case VALAccessControlDevicePasscode:
118130
return ([self _iOS9OrLater] || [self _macOSElCapitanOrLater]);
@@ -252,7 +264,7 @@ - (BOOL)containsObjectForKey:(nonnull NSString *)key;
252264
{
253265
NSDictionary *options = nil;
254266

255-
// iOS 9 and Mac OS 10.11 use kSecUseAuthenticationUI, not kSecUseNoAuthenticationUI.
267+
// iOS 9 and macOS 10.11 use kSecUseAuthenticationUI, not kSecUseNoAuthenticationUI.
256268
#if ((TARGET_OS_IPHONE && __IPHONE_9_0) || (TARGET_OS_MAC && __MAC_10_11))
257269
if ([[self class] _iOS9OrLater] || [[self class] _macOSElCapitanOrLater]) {
258270
options = @{ (__bridge id)kSecUseAuthenticationUI : (__bridge id)kSecUseAuthenticationUIFail };

ValetTests/ValetTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ - (void)test_stringForKey_canReadDataWrittenToValetAllocatedOnDifferentThread;
371371
#if !TARGET_OS_IPHONE
372372
- (void)test_setStringForKey_neutralizesMacOSAccessControlListVuln;
373373
{
374-
// This test verifies that we are neutralizing the zero-day Mac OS X Access Control List vulnerability published here: https://drive.google.com/file/d/0BxxXk1d3yyuZOFlsdkNMSGswSGs/view
374+
// This test verifies that we are neutralizing the zero-day macOS Access Control List vulnerability published here: https://drive.google.com/file/d/0BxxXk1d3yyuZOFlsdkNMSGswSGs/view
375375

376376
NSOperatingSystemVersion version = [NSProcessInfo processInfo].operatingSystemVersion;
377377
BOOL macOS1010OrLater = (version.majorVersion == 10 && version.minorVersion >= 10);

0 commit comments

Comments
 (0)