开发者

Decryption with the public key in iphone

I have a public key and an encrypted string. I could encrypt with the publickey successfully.But when i try to decrypt using the publickey it fails. I mean when i pass the publickey toseckeyDecrypt it fails.

I have Googled and found out that, by default kSecAttrCanDecrypt is false for public keys.So When i import the public key, i have added this particular line ,

[publicKe开发者_JAVA技巧yAttr setObject:(id)kCFBooleanTrue forKey:(id)kSecAttrCanDecrypt];

But there is no improvement it still fails. Please somebody help.

EDIT: Apple's Certificate,Key and Trust Services Says,

kSecAttrCanEncrypt Default false for private keys, true for public keys.

kSecAttrCanDecrypt Default true for private keys, false for public keys.

Which means, the values can be changed right?. My server does not sign(Convert as a digest) the content. They just encrypt using the private key which is to be decrypted at my(in iphone) end. Is that possible?.


The point of asymmetric cryptography is that you encrypt with the public key and decrypt with the private key.

EDIT: If you're signing and verifying, you should use the associated APIs. For example, you can check this capability with kSecAttrCanSign and kSecAttrCanVerify.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜