7 Replies
      Latest reply on Sep 8, 2019 9:46 AM by Gargoyle
      SN81 Level 1 Level 1 (0 points)

        Hi guys,


        I need to generate an RSA public key from a modulus and exponent and I'm unable to find any resources where someone has done this successfully. I can't even find a way to do it in Apples documentation.


        I have heard using SecKeyRef and/or OpenSSL is the way to go but searches on both of those lead to nothing that has worked (and what I tried is far too extensive to list here). Is this something not possible in iOS? If anyone has any ideas how to accomplish this I would greatly appreciate hearing them. Thank you.

        • Re: How do I generate an RSA public key using a modulus and exponent in iOS? (Obj-C)
          eskimo Apple Staff Apple Staff (13,145 points)

          iOS does not provide any public APIs for this.  You'll need to write or acquire the necessary code.  You can do it with a full-featured security toolkit, like OpenSSL, or just hack something together (this is a relatively simple use of ASN.1).


          What I recommend is that you restructure your system so that you don't require this.  Most folks who have this problem are getting the modulus and exponent from a server that has a full-featured security toolkit (OpenSSL, something Java-ish, and so on).  In that case you can have the server build the public key and send you that.  Or, to make things even easier, have the server put the public key into a certificate, which is trivial to work with on iOS.


          Share and Enjoy


          Quinn "The Eskimo!"

          Apple Developer Relations, Developer Technical Support, Core OS/Hardware