iphone - 使用私钥的 NSData 进行数据签名
我正在开发 iPhone 电子银行应用程序。
我正在使用带有 XML 签名的 WSS 对发送给客户的 SOAP 服务器的请求进行签名。
由于iPhone设备不可信(由于越狱),客户 要求是在将密钥存储到钥匙串之前手动加密 RSA 密钥对(使用 AES128)。
据我目前所知,密钥在生成时会自动添加到钥匙串中。
所以我的想法是随后提取数据(与 CryptoExercise 示例中提取公钥的方式相同),从钥匙串中删除密钥,进行 AES 加密并将其作为自定义 NSData 再次存储到钥匙串中。
1) 你觉得这有什么问题吗?
我在某处读到检索数据或删除密钥可能需要某种密码,尽管我不知道密码是什么。今天晚些时候我会尝试这个,如果同时没有发布答案,我会发布答案:)
2)我找不到是否有任何方法可以使用这个密钥而不在代码中实现更多的黑客?
它看起来像 SecKeyRawSign 方法只接受 SecKeyRef 引用,它是指向钥匙串中密钥的指针。是否有其他方法使用密钥的 NSData 进行签名?
我目前唯一的想法是使用 SecItemAdd 方法在签名之前将非加密密钥添加到钥匙串中,并在签名后将其删除。但我不喜欢这种情况,因为它会一直发生,并且如果在从钥匙串中删除密钥之前应用程序被关闭(崩溃或其他原因),它将保留在那里,直到下次应用程序启动时为止。
有更好的解决方案吗?
问候
I am working on a e-banking iphone application.
I am using WSS with XML-Signature to sign the requests to the customer's SOAP server.
Since the iPhone device can not be trusted (due to jail-breaking), the customer
requirement is to manually encrypt the RSA key pair (using AES128) before storing the keys into keychain.
From what I have found so far, the keys are automatically added to the keychain when generated.
So my idea is to extract the data afterwards (the same way the public key is extracted in the CryptoExercise example), remove the keys from keychain, do the AES encryption and store it again into keychain as a custom NSData.
1) Do you see any problem with this ?
I read somewhere that retrieving the data or deleting the key might require some sort of password, although I didn't got what password. I will try this later today and will post the answer if no answer is posted in meantime :)
2) I can not find if there is any way to use this key without implementing some more hacks in the code?
It seams like the SecKeyRawSign method only accepts a SecKeyRef reference which is a pointer to the key in keychain. Is there some other method for signing using the NSData of the key ?
The only idea I have in the moment is to use SecItemAdd method to add the non-encrypted key into the keychain before signing, and remove it after signing. But I don't like this since it will happen all the time, and if the application is shut down (crashes or something) before the key is removed from keychain it will remain there until lets say the next time application is started.
Any idea for a better solution ?
regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑检查 Apple 示例和安全文档。框架:
https://developer.apple.com/library/ios/#DOCUMENTATION/Security/Conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html#//apple_ref/doc/uid/TP40001358-CH208-SW13 - 请参阅此链接
Consider checking Apple example and documentation for Security. Framework:
https://developer.apple.com/library/ios/#DOCUMENTATION/Security/Conceptual/CertKeyTrustProgGuide/iPhone_Tasks/iPhone_Tasks.html#//apple_ref/doc/uid/TP40001358-CH208-SW13 - see this link