It looks like you're new here. If you want to get involved, click one of these buttons!
Dreamwriter
Posts: 768Member
I created my game in the My Games section of the Ouya Devs website. I then downloaded the key.der file, and opened it in a Hex Editor (Hexplorer). I copied the hex data, pasted it over the default data in the APPLICATION_KEY, and when this code is run:
try {
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(APPLICATION_KEY);
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
mPublicKey = keyFactory.generatePublic(keySpec);
} catch (Exception e) {
Log.e(LOG_TAG, "Unable to create encryption key", e);
}
I get this exception:
E/IapSample( 1897): Unable to create encryption key
E/IapSample( 1897): java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
Anyone see what I'm doing wrong? The key I pasted in is the same number of bytes as in the IAPSample, and even the first 3 1/2 lines or so match up exactly, so it *seems* right.
Comments
Fixed it - what the table needed was for the last byte to end in a comma! As in, I had ended it like this:
(byte) 0x00, (byte) 0x01
};
and it wanted:
(byte) 0x00, (byte) 0x01,
};