Skip to content

Commit

Permalink
Merge pull request #36 from square/federman/kSecUseAuthenticationUI_iOS9
Browse files Browse the repository at this point in the history
Support use of kSecUseNoAuthenticationUI on iOS 8 and Xcode 7
  • Loading branch information
dfed committed Aug 25, 2015
2 parents 4cc2279 + 8af66e5 commit 6a5fa57
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Valet/VALSecureEnclaveValet.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,24 @@ - (BOOL)canAccessKeychain;
- (BOOL)containsObjectForKey:(nonnull NSString *)key;
{
#if VAL_IOS_8_OR_LATER

NSDictionary *options = nil;

#if VAL_IOS_9_OR_LATER
OSStatus status = [self containsObjectForKey:key options:@{ (__bridge id)kSecUseAuthenticationUI : (__bridge id)kSecUseAuthenticationUIFail }];
if (&kSecUseAuthenticationUI != NULL) {
options = @{ (__bridge id)kSecUseAuthenticationUI : (__bridge id)kSecUseAuthenticationUIFail };
} else {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// kSecUseNoAuthenticationUI is deprecated in the iOS 9 SDK, but we still need it on iOS 8.
options = @{ (__bridge id)kSecUseNoAuthenticationUI : @YES };
#pragma GCC diagnostic pop
}
#else
OSStatus status = [self containsObjectForKey:key options:@{ (__bridge id)kSecUseNoAuthenticationUI : @YES }];
options = @{ (__bridge id)kSecUseNoAuthenticationUI : @YES };
#endif

OSStatus status = [self containsObjectForKey:key options:options];

BOOL const keyAlreadyInKeychain = (status == errSecInteractionNotAllowed || status == errSecSuccess);
return keyAlreadyInKeychain;

Expand Down

0 comments on commit 6a5fa57

Please sign in to comment.