So, I use Spongy Castle (Android) to create a PEM encoded string for the RSA public key to be uploaded to the server. This is what I am doing now:
PublicKey publicKey = keyPair.getPublic();
StringWriter writer = new StringWriter();
PemWriter pemWriter = new PemWriter(writer);
pemWriter.writeObject(new PemObject("RSA PUBLIC KEY", publicKey.getEncoded()));
pemWriter.flush();
pemWriter.close();
return writer.toString();
Now, as you can probably tell, I'm not sure how to build PemObject, or if there is an easier way to do this.
When using the Bouncy Case, I used this as
StringWriter writer = new StringWriter();
PEMWriter pemWriter = new PEMWriter(writer);
pemWriter.writeObject(keyPair.getPublic());
pemWriter.flush();
pemWriter.close();
return writer.toString();
But for some reason, the PEMWriter class does not exist in Spongy Castle
source
share