فهرست منبع

update UICKeyChainStore lib

Marino Faggiana 7 سال پیش
والد
کامیت
49254dad41
2فایلهای تغییر یافته به همراه28 افزوده شده و 5 حذف شده
  1. 11 3
      Libraries external/UICKeyChainStore/UICKeyChainStore.h
  2. 17 2
      Libraries external/UICKeyChainStore/UICKeyChainStore.m

+ 11 - 3
Libraries external/UICKeyChainStore/UICKeyChainStore.h

@@ -96,9 +96,16 @@ typedef NS_ENUM(NSInteger, UICKeyChainStoreAccessibility) {
 }
 __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_4_0);
 
-typedef NS_ENUM(NSInteger, UICKeyChainStoreAuthenticationPolicy) {
-    UICKeyChainStoreAuthenticationPolicyUserPresence = kSecAccessControlUserPresence,
-};
+typedef NS_ENUM(unsigned long, UICKeyChainStoreAuthenticationPolicy) {
+    UICKeyChainStoreAuthenticationPolicyUserPresence        = 1 << 0,
+    UICKeyChainStoreAuthenticationPolicyTouchIDAny          NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 1,
+    UICKeyChainStoreAuthenticationPolicyTouchIDCurrentSet   NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 3,
+    UICKeyChainStoreAuthenticationPolicyDevicePasscode      NS_ENUM_AVAILABLE(10_11, 9_0) = 1u << 4,
+    UICKeyChainStoreAuthenticationPolicyControlOr           NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 14,
+    UICKeyChainStoreAuthenticationPolicyControlAnd          NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 15,
+    UICKeyChainStoreAuthenticationPolicyPrivateKeyUsage     NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 30,
+    UICKeyChainStoreAuthenticationPolicyApplicationPassword NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 31,
+}__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
 
 @interface UICKeyChainStore : NSObject
 
@@ -114,6 +121,7 @@ typedef NS_ENUM(NSInteger, UICKeyChainStoreAuthenticationPolicy) {
 @property (nonatomic) UICKeyChainStoreAccessibility accessibility;
 @property (nonatomic, readonly) UICKeyChainStoreAuthenticationPolicy authenticationPolicy
 __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);
+@property (nonatomic) BOOL useAuthenticationUI;
 
 @property (nonatomic) BOOL synchronizable;
 

+ 17 - 2
Libraries external/UICKeyChainStore/UICKeyChainStore.m

@@ -117,6 +117,7 @@ static NSString *_defaultService;
 - (void)commonInit
 {
     _accessibility = UICKeyChainStoreAccessibilityAfterFirstUnlock;
+    _useAuthenticationUI = YES;
 }
 
 #pragma mark -
@@ -360,9 +361,9 @@ static NSString *_defaultService;
 {
     NSMutableDictionary *query = [self query];
     query[(__bridge __strong id)kSecAttrAccount] = key;
-    
+
     OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
-    return status == errSecSuccess;
+    return status == errSecSuccess || status == errSecInteractionNotAllowed;
 }
 
 #pragma mark -
@@ -1140,6 +1141,20 @@ static NSString *_defaultService;
         }
     }
 #endif
+
+    if (!_useAuthenticationUI) {
+#if TARGET_OS_IOS
+        if (floor(NSFoundationVersionNumber) > floor(1144.17)) { // iOS 9+
+            query[(__bridge __strong id)kSecUseAuthenticationUI] = (__bridge id)kSecUseAuthenticationUIFail;
+#if  __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0
+        } else if (floor(NSFoundationVersionNumber) > floor(1047.25)) { // iOS 8+
+            query[(__bridge __strong id)kSecUseNoAuthenticationUI] = (__bridge id)kCFBooleanTrue;
+#endif
+        }
+#elif TARGET_OS_WATCH || TARGET_OS_TV
+        query[(__bridge __strong id)kSecUseAuthenticationUI] = (__bridge id)kSecUseAuthenticationUIFail;
+#endif
+    }
     
     return query;
 }