ios - 安全飞地 : update SecAccessControlCreateFlags after key creation

标签 ios swift enclave

我想知道是否有人知道是否可以在安全飞地内创建 key 之后更新标志? 以下是我创建 key 的方法:

let access = SecAccessControlCreateWithFlags(kCFAllocatorDefault,
                                             kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
                                             [SecAccessControlCreateFlags.userPresence, 
                                              SecAccessControlCreateFlags.privateKeyUsage],
                                              nil)!
let attributes: [String: Any] = [
    kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom,
    kSecAttrKeySizeInBits as String: 256,
    kSecAttrTokenID as String: kSecAttrTokenIDSecureEnclave,
    kSecPrivateKeyAttrs as String: [
        kSecAttrIsPermanent as String: true,
        kSecAttrApplicationTag as String: "stacksometimesoverflow",
        kSecAttrAccessControl as String: access
    ]
]

var error: Unmanaged<CFError>?
guard SecKeyCreateRandomKey(attributes as CFDictionary, &error) != nil else {
    throw error!.takeRetainedValue() as Error
}

如您所见, key 是用

创建的
SecAccessControlCreateFlags.userPresence, SecAccessControlCreateFlags.privateKeyUsage

我的问题是,是否可以更新 key 的访问标志(相同 key ),假设我想删除SecAccessControlCreateFlags.userPresence

祝一切顺利!

约翰尼

最佳答案

我认为这是不可能的。根据Apple's documentation :

... because its backing storage is physically part of the Secure Enclave, you can never inspect the key’s data.

我认为最好的方法是使用 SecItemDelete(_:) 删除 key ,然后创建不带 .userPresence 标志的新 key 。

关于ios - 安全飞地 : update SecAccessControlCreateFlags after key creation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53796228/

相关文章:

javascript - 在 native react 中链接外部组件后不能有任何值(value)

ios - git checkout master 命令给出文件将被覆盖的错误

ios - 在日期对象上设置时间(小时,分钟)

ios - iOS Secure Enclave 中可以存储多少个 key ?

c++ - 将 2D vector 转换为 C 类型的最佳方法(对于 SGX enclave)

ios - 集成触摸姿势

ios - Swift:可以从许多地方访问的 ViewController 模式

swift - 使用 AlamoFireImage 在 CollectionView 中使用 .af_setImage 方法加载数组的 url 时发生 fatal error

ios - 在 swift : Difference between Array VS NSArray VS [AnyObject]

sgx - 如何证明某些数据是在Enclave(Intel SGX)内部计算(或生成)的?