【问题标题】:Does the flag kSecAttrAccessControl has an effect on the public key when generating the key pair using SecKeyGeneratePair?使用 SecKeyGeneratePair 生成密钥对时,标志 kSecAttrAccessControl 是否对公钥有影响?
【发布时间】:2021-04-21 06:10:15
【问题描述】:

我正在使用 SecKeyGeneratePair 方法创建一个私钥/公钥对。 为了能够做到这一点,我使用 kSecPrivateKeyAttrs 和 kSecPublicKeyAttrs 创建了一个参数字典。 在 kSecPrivateKeyAttrs 和 kSecPublicKeyAttrs(都是字典)中,我添加了 kSecAttrAccessControl 来设置密钥的保护级别(例如 kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly)。

var publicKey, privateKey: SecKey?            
let status = SecKeyGeneratePair(params as CFDictionary, &publicKey, &privateKey)

密钥的生成成功,但添加 kSecAttrAccessControl 只影响私钥。 这是否记录在某处?

【问题讨论】:

    标签: ios swift security keychain


    【解决方案1】:

    我找不到任何文档,但您观察到的内容基于以下几点是有道理的:

    • Keychain API 在 Apple 平台上存储机密。公钥不是秘密。只有私钥是。因此,数据保护仅适用于私钥是有道理的。
    • iOS 上的钥匙串类似于 macOS 上的钥匙串访问。在 Keychain Access 中,只有私钥具有访问控制。见附件。这是我的分发私钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-09
      • 2019-03-13
      • 1970-01-01
      相关资源
      最近更新 更多