You can decode the Base64 using
That will give you either an ASN.1
SubjectPublicKeyInfoor an ASN.1
RSAPublicKeystructure. If it’s the former, you will need to strip the
SubjectPublicKeyInfoheader to get the
You can add that key to your keychain (using
SecItemAdd) and thus get a
SecKeyRef. You can pass that
SecKeyEncryptto do the encryption.
This isn’t much fun. If you can change the server side of things, I recommend that you have the server send you a certificate. Importing a certificate into iOS is trivial (
SecCertificateCreateWithData) and getting the public key from that certificate is also pretty easy (create a trust object using
SecTrustCreateWithCertificates, evaluate that trust object, then get the public key via
Share and Enjoy
Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"