1

I am getting decryption error on sever when I used SwiftyRSA to encrypt a text using publicKey on client.

I have referred this RSA: encrypt in iOS, decrypt in Java but this is for SHA1.

I am using https://github.com/TakeScoop/SwiftyRSA library.

kSecPaddingOAEP and RSA/NONE/OAEPWithSHA1AndMGF1Padding works. But how Can I make it work for RSA/NONE/OAEPWithSHA256AndMGF1Padding

let str = "Clear Text"
let clear = try ClearMessage(string: str, using: .utf8)    
let encrypted = try clear.encrypted(with: publicKey, padding: .OAEP)

I want to encrypt data in swift3 without touching server code.

Community
  • 1
  • 1

1 Answers1

1

As far as I know, Apple's security framework, it does not support OAEP padding with a SHA256 hash digest, but it can be done through the OpenSSL library. https://github.com/x2on/OpenSSL-for-iPhone

Lei Zhang
  • 634
  • 4
  • 6