I'm looking to generate a rsa public key (pem) from both the modulus and exponent in Objective-C. This function can be done in Java by the following;
PublicKey publicKey = KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(modulus, exponent));
Although I'm having some trouble writing this for the iOS platform. Am aware of
解决方案
If you want to create a .PEM format you need to base64 encode the output from the berData method. You also need to add the header and footer lines.
Test data and code, see the end of the answer for bytesFromHexString:
NSString *modulusString = @"c19bccae1e67743fab1c978f03122fb1a78ef05d565a2964728062ad0365e4751b8253df5fd13ab4ecb95c81ff17b91f969e4fb3d8274c30533338684278f6e5548027df775c055943a24a4117b0274c296c68b722c71670d4b21489a3da05d37ba06f2fb771b671a2c746bae4a049dc718fba19a75f1fb8ae1