gpt4 book ai didi

ios - 如何检查安全飞地是否在设备中可用

转载 作者:可可西里 更新时间:2023-11-01 04:37:33 26 4
gpt4 key购买 nike

我们知道 secure Enclave 是 Apple A7 中制造的协处理器,它在 A7 及更高版本中可用,但它在 iOS 9 中公开使用 kSecAttrTokenIDSecureEnclave 但我们如何检查某些设备是否支持安全飞地与否?谢谢

最佳答案

我没有找到任何东西,所以我自己做了检查:

+ (BOOL) isDeviceOkForSecureEnclave
{

double OSVersionNumber = floor(NSFoundationVersionNumber);
UIUserInterfaceIdiom deviceType = [[UIDevice currentDevice] userInterfaceIdiom];

BOOL isOSForSecureEnclave = OSVersionNumber > NSFoundationVersionNumber_iOS_8_4 ? YES:NO;
//iOS 9 and up are ready for SE


BOOL isDeviceModelForSecureEnclave = NO;

switch (deviceType) {

case UIUserInterfaceIdiomPhone:
//iPhone
isDeviceModelForSecureEnclave = [self isPhoneForSE];
break;
case UIUserInterfaceIdiomPad:
//iPad
isDeviceModelForSecureEnclave = [self isPadForSE];

break;
default:
isDeviceModelForSecureEnclave = false;
break;
}

return (isOSForSecureEnclave && isDeviceModelForSecureEnclave) ? YES:NO;
}


/**
The arrays are models that we know not having SE in hardware, so if the current device is on the list it means it dosent have SE
*/

+ (BOOL) isPhoneForSE
{
NSString *thisPlatform = [self platform];
NSArray * oldModels = [NSArray arrayWithObjects:
@"x86_64",
@"iPhone1,1",
@"iPhone1,2",
@"iPhone2,1",
@"iPhone3,1",
@"iPhone3,3",
@"iPhone4,1",
@"iPhone5,1",
@"iPhone5,2",
@"iPhone5,3",
@"iPhone5,4", nil];

BOOL isInList = [oldModels containsObject: thisPlatform];
return !isInList;
}


+ (BOOL) isPadForSE
{
//iPad Mini 2 is the earliest with SE // "iPad4,4"
NSString *thisPlatform = [self platform];

NSArray * oldModels = [NSArray arrayWithObjects:
@"x86_64",
@"@iPad",
@"@iPad1,0",
@"@iPad1,1",
@"iPad2,1",
@"iPad2,2",
@"iPad2,3",
@"iPad2,4",
@"iPad2,5",
@"iPad2,6",
@"iPad2,7",
@"iPad3,1",
@"iPad3,2",
@"iPad3,3",
@"iPad3,4",
@"iPad3,5",
@"iPad3,6",nil];

BOOL isInList = [oldModels containsObject: thisPlatform];

return !isInList;

}


+ (NSString *)platform
{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithUTF8String:machine];
free(machine);

return platform;

}

@end

检查 Touch ID

- (BOOL)canAuthenticateByTouchId {
if ([LAContext class]) {
return [[[LAContext alloc] init] canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];
}
return YES;
}

您还可以找到检测 Secure Enclave here you find

关于ios - 如何检查安全飞地是否在设备中可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41216403/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com