0

I am exporting a public key from the Android Keystore with:

final byte[] publicKey =((KeyStore.PrivateKeyEntry)entry).getCertificate().getPublicKey().getEncoded();

It works but I cannot figure out what format this exported key is in, Android docs only say that getEncoded() returns the public key in its encoded format, which does not mean anything to me. How can I check which format this key is encoded in? Is there a standard?

Francesco Rigoni
  • 923
  • 7
  • 20
  • `((KeyStore.PrivateKeyEntry)entry).getCertificate().getPublicKey().getFormat();` will tell the format of the data that is returned by `getEncoded()`. – President James K. Polk Jan 10 '19 at 14:49
  • Can you gave example bytes from test ECC certificate? – Zergatul Jan 10 '19 at 15:12
  • Probably a SubjectPublicKeyInfo structure around a X9.62 encoded key (both specified using ASN.1 / DER). You can reload using `KeyFactory` for `"EC"` and X509EncodedKeySpec` as input. Feel free to comment "whut?". – Maarten Bodewes Jan 10 '19 at 17:00

0 Answers0