1

I have a public RSA key in the PEM format

 -----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAw9dJXFAt/DcHhh1bA5VHHsQyF1bDapwcwFJWEtOMNdi60PVd3FBD
W5RFrLSUqAZzVuKx3rGgJRMS9bsZ7WZckuERqX200KtdTRqdjUmmH3Zy2CvanjJJ
CN4TUPmCdxNklc4fnLjqbnZjXeMSwxgGQNCyMrBZoI/OnFEwtVshk5Gl0OpNhB6S
GNOoz4kIHH0wFkYeXd/JnOWjaiYN2Lg9epZbahoq6aaEPfk7ivRzvWype4k5MvDL
XjG05XLcsAYqirHRRYZjvloUZhH15ATrDTyFUJK4OUcOlBZeDXB6aEj/TJCUH70T
xIvTGJlr6epnqsZDLdASgHCymMXZFELKLwIDAQAB
-----END RSA PUBLIC KEY-----

And I'd like to have it in the OpenSSH Public Key format which looks like this

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDW8dVZHqiVEwMAbH6sihJn10GaJZCOCcbCE8KWwuR/nSVXO3adm71XOsAXF4CcKng+k0QgVYveUF4nvTqfa09Rl/7wPPKFdg+ZyFRbNf+bfXLmKhCG/ZiE/ENp3dedoJPDZAqu48ZVagdEPBkJl1S7ZNPzcfJaAOXxLRpPf0pzobK/T5rQROC4k919OELX58y3+opkZLbFBRFwY7dLB9xj7fLT5r7oaZezbGucJ55Hj6yo8/+F52ATKm8QZg/ULzVzgHD9LoNDbI7a1eywiu2zDaKjI1wWCN3NmgNiZlciGsU/RG0mrRPkiwg7xd+uM0qd1P6Yiyg2/N6ydHxtAyJH

I was able to do this conversion on my Mac by running ssh-keygen -y -f private > public, but I need to do this conversion inside an iOS app.

Any ways of accomplishing this with Apple's crypto or security libraries in Swift?

joehinkle11
  • 491
  • 1
  • 4
  • 9
  • For more context, I've generated the RSA key using SecKeyGeneratePair (https://developer.apple.com/documentation/security/1395339-seckeygeneratepair). Example code of how to fully create an RSA key-air like this can be found here. https://stackoverflow.com/a/45916908/3902590 – joehinkle11 May 07 '21 at 03:50
  • Why is this a programming question? – El Tomato May 07 '21 at 03:57
  • Is there another stack exchange you think would be better to ask on? – joehinkle11 May 07 '21 at 04:14

0 Answers0