2

在 iOS7 中,当我在钥匙串中添加 RSA 公钥时,它已成功添加,但如果我想检索“kSecReturnRef”,我会得到 nil,但如果我检索“kSecReturnPersistentRef”或“kSecReturnData”它工作正常。仅当我通过“SecItemAdd()”方法添加 RSA 公钥时才会出现此问题。如果我通过“SecKeyGeneratePair()”生成公钥并检索“kSecReturnRef”,一切都很好。

重现步骤:

  1. 下载示例代码“CryptoExercise”
  2. 调用方法“addPeerPublicKey:keyBits:”
  3. 传递公钥数据和名称
  4. 上述方法内部调用“getKeyRefWithPersistentKeyRef”,该方法返回“SecKeyRef”的nil值。

这个问题只存在于 iOS 7 中,而相同的代码从 iOS3 到 iOS6 都可以正常工作。

预期成绩:

< SecKeyRef algorithm id: 1, key type: RSAPublicKey, version: 2, block size: 512 bits, exponent: {hex: 10001, decimal: 65537}, modulus: AE098BC28358D88AE7602E8BB91007239018D40BB1A87F2245199A208CA21B8EFCFFE2373B470E6075D740AC1A25CD7914A6BA5680701DFB9428E2DD461965B7, addr: 0x9abe600 >

实际结果:

< nil>

示例代码:https ://developer.apple.com/library/IOs/samplecode/CryptoExercise/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008019-Intro-DontLinkElementID_2

任何帮助,将不胜感激。

4

0 回答 0