简体   繁体   English

即使卸载应用程序后,安全的Enclave密钥仍然存在

[英]Secure Enclave keys exists even after app uninstallation

I have generated Keys inside the Secure enclave using the following Code Snippet, 我已使用以下代码段在安全区域内生成了密钥,

func generateKeyPair(accessControl: SecAccessControl) throws -> (`public`: SecureEnclaveKeyReference, `private`: SecureEnclaveKeyReference) {

        let privateKeyParams: [String: Any] = [
            kSecAttrLabel as String: privateLabel,
            kSecAttrIsPermanent as String: true,
            kSecAttrAccessControl as String: accessControl,
        ]
        let params: [String: Any] =
        [
            kSecAttrKeyType as String: attrKeyTypeEllipticCurve,
            kSecAttrKeySizeInBits as String: 256,
            kSecAttrTokenID as String: kSecAttrTokenIDSecureEnclave,
            kSecPrivateKeyAttrs as String: privateKeyParams
        ]
        var publicKey, privateKey: SecKey?

        let status = SecKeyGeneratePair(params as CFDictionary, &publicKey, &privateKey)

        guard status == errSecSuccess else {

            throw SecureEnclaveHelperError(message: "Could not generate keypair", osStatus: status)
        }

        return (public: SecureEnclaveKeyReference(publicKey!), private: SecureEnclaveKeyReference(privateKey!))
    }

Post un-installation of the application the keys still exists, is there a way to remove the keys from secure enclave ? 卸载应用程序后,密钥仍然存在,是否有办法从安全区域中移除密钥?

Thank you in advance :) 先感谢您 :)

There is no trigger to perform code when the app is deleted from the device. 从设备删除应用程序后,没有触发器可以执行代码。 Access to the keychain is dependant on the provisioning profile that is used to sign the application. 对钥匙串的访问取决于用于对应用程序进行签名的供应配置文件。 Therefore no other applications would be able to access this information in the keychain. 因此,没有其他应用程序能够访问钥匙串中的此信息。

https://stackoverflow.com/a/5711090/7350472 https://stackoverflow.com/a/5711090/7350472

If you want to delete key from Secure Enclave you can call: 如果要从Secure Enclave删除密钥,可以致电:

SecItemDelete(query as CFDictionary)

https://developer.apple.com/documentation/security/1395547-secitemdelete https://developer.apple.com/documentation/security/1395547-secitemdelete

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM