This source file includes following definitions.
- getHandle
- getKeyStore
- getRSAKeyModulus
- getDSAKeyParamQ
- getECKeyOrder
- rawSignDigestWithPrivateKey
- getPrivateKeyType
- getPrivateKeyEncodedBytes
- getOpenSSLHandleForPrivateKey
- createKey
- releaseKey
package org.chromium.net;
import android.os.RemoteException;
import android.util.Log;
public class RemoteAndroidKeyStore implements AndroidKeyStore {
private static final String TAG = "AndroidKeyStoreRemoteImpl";
private static class RemotePrivateKey implements AndroidPrivateKey {
final int mHandle;
final RemoteAndroidKeyStore mStore;
RemotePrivateKey(int handle, RemoteAndroidKeyStore store) {
mHandle = handle;
mStore = store;
}
public int getHandle() {
return mHandle;
}
@Override
public AndroidKeyStore getKeyStore() {
return mStore;
}
}
private final IRemoteAndroidKeyStore mRemoteManager;
public RemoteAndroidKeyStore(IRemoteAndroidKeyStore manager) {
mRemoteManager = manager;
}
@Override
public byte[] getRSAKeyModulus(AndroidPrivateKey key) {
RemotePrivateKey remoteKey = (RemotePrivateKey) key;
try {
Log.d(TAG, "getRSAKeyModulus");
return mRemoteManager.getRSAKeyModulus(remoteKey.getHandle());
} catch (RemoteException e) {
e.printStackTrace();
return null;
}
}
@Override
public byte[] getDSAKeyParamQ(AndroidPrivateKey key) {
RemotePrivateKey remoteKey = (RemotePrivateKey) key;
try {
Log.d(TAG, "getDSAKeyParamQ");
return mRemoteManager.getDSAKeyParamQ(remoteKey.getHandle());
} catch (RemoteException e) {
e.printStackTrace();
return null;
}
}
@Override
public byte[] getECKeyOrder(AndroidPrivateKey key) {
RemotePrivateKey remoteKey = (RemotePrivateKey) key;
try {
Log.d(TAG, "getECKeyOrder");
return mRemoteManager.getECKeyOrder(remoteKey.getHandle());
} catch (RemoteException e) {
e.printStackTrace();
return null;
}
}
@Override
public byte[] rawSignDigestWithPrivateKey(AndroidPrivateKey key, byte[] message) {
RemotePrivateKey remoteKey = (RemotePrivateKey) key;
try {
Log.d(TAG, "rawSignDigestWithPrivateKey");
return mRemoteManager.rawSignDigestWithPrivateKey(remoteKey.getHandle(), message);
} catch (RemoteException e) {
e.printStackTrace();
return null;
}
}
@Override
public int getPrivateKeyType(AndroidPrivateKey key) {
RemotePrivateKey remoteKey = (RemotePrivateKey) key;
try {
Log.d(TAG, "getPrivateKeyType");
return mRemoteManager.getPrivateKeyType(remoteKey.getHandle());
} catch (RemoteException e) {
e.printStackTrace();
return 0;
}
}
@Override
public byte[] getPrivateKeyEncodedBytes(AndroidPrivateKey key) {
assert false;
return null;
}
@Override
public long getOpenSSLHandleForPrivateKey(AndroidPrivateKey privateKey) {
assert false;
return 0;
}
public AndroidPrivateKey createKey(String alias) {
try {
int handle = mRemoteManager.getPrivateKeyHandle(alias);
return new RemotePrivateKey(handle, this);
} catch (RemoteException e) {
e.printStackTrace();
return null;
}
}
@Override
public void releaseKey(AndroidPrivateKey key) {
RemotePrivateKey remoteKey = (RemotePrivateKey) key;
try {
Log.d(TAG, "releaseKey");
mRemoteManager.releaseKey(remoteKey.getHandle());
} catch (RemoteException e) {
e.printStackTrace();
}
}
}