private static final String TAG = "AndroidKeyStoreTestUtil";
+ private static final DefaultAndroidKeyStore sKeyStore = new DefaultAndroidKeyStore();
/**
* Called from native code to create a PrivateKey object from its
* encoded PKCS#8 representation.
* @return new PrivateKey handle, or null in case of error.
*/
@CalledByNative
- public static PrivateKey createPrivateKeyFromPKCS8(int type, byte[] encodedKey) {
+ public static AndroidPrivateKey createPrivateKeyFromPKCS8(int type, byte[] encodedKey) {
String algorithm = null;
switch (type) {
case PrivateKeyType.RSA:
KeyFactory factory = KeyFactory.getInstance(algorithm);
KeySpec ks = new PKCS8EncodedKeySpec(encodedKey);
PrivateKey key = factory.generatePrivate(ks);
- return key;
+ return sKeyStore.createKey(key);
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "Could not create " + algorithm + " factory instance!");