RSA: encrypt in iOS, decrypt in Java

后端 未结 2 1424
执笔经年
执笔经年 2020-12-13 07:18

I have a public key that\'s sent from a Java server. The base64 encoded strings match before I decode and strip out the ASN.1 headers. I store the public key in the keychain

2条回答
  •  旧巷少年郎
    2020-12-13 07:58

    I had same problem. Does work with kSecPaddingNone, but doesn't work with kSecPaddingPKCS1 with any PKCS1 combination in Java code.

    But, it's not good idea to use it without padding.

    So, on iOS, replace kSecPaddingNone with kSecPaddingOAEP and use RSA/NONE/OAEPWithSHA1AndMGF1Padding in your Java code. This does work for me.

提交回复
热议问题