Merge "Allow uid to be passed for more operations"

This commit is contained in:
Alex Klyubin
2015-09-10 22:37:50 +00:00
committed by Android (Google) Code Review
2 changed files with 41 additions and 19 deletions

View File

@@ -155,15 +155,19 @@ public class KeyStore {
return state() == State.UNLOCKED;
}
public byte[] get(String key) {
public byte[] get(String key, int uid) {
try {
return mBinder.get(key);
return mBinder.get(key, uid);
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return null;
}
}
public byte[] get(String key) {
return get(key, UID_SELF);
}
public boolean put(String key, byte[] value, int uid, int flags) {
return insert(key, value, uid, flags) == NO_ERROR;
}
@@ -348,9 +352,9 @@ public class KeyStore {
* Returns the last modification time of the key in milliseconds since the
* epoch. Will return -1L if the key could not be found or other error.
*/
public long getmtime(String key) {
public long getmtime(String key, int uid) {
try {
final long millis = mBinder.getmtime(key);
final long millis = mBinder.getmtime(key, uid);
if (millis == -1L) {
return -1L;
}
@@ -362,6 +366,10 @@ public class KeyStore {
}
}
public long getmtime(String key) {
return getmtime(key, UID_SELF);
}
public boolean duplicate(String srcKey, int srcUid, String destKey, int destUid) {
try {
return mBinder.duplicate(srcKey, srcUid, destKey, destUid) == NO_ERROR;
@@ -423,15 +431,20 @@ public class KeyStore {
}
public int getKeyCharacteristics(String alias, KeymasterBlob clientId, KeymasterBlob appId,
KeyCharacteristics outCharacteristics) {
int uid, KeyCharacteristics outCharacteristics) {
try {
return mBinder.getKeyCharacteristics(alias, clientId, appId, outCharacteristics);
return mBinder.getKeyCharacteristics(alias, clientId, appId, uid, outCharacteristics);
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return SYSTEM_ERROR;
}
}
public int getKeyCharacteristics(String alias, KeymasterBlob clientId, KeymasterBlob appId,
KeyCharacteristics outCharacteristics) {
return getKeyCharacteristics(alias, clientId, appId, UID_SELF, outCharacteristics);
}
public int importKey(String alias, KeymasterArguments args, int format, byte[] keyData,
int uid, int flags, KeyCharacteristics outCharacteristics) {
try {
@@ -449,9 +462,23 @@ public class KeyStore {
}
public ExportResult exportKey(String alias, int format, KeymasterBlob clientId,
KeymasterBlob appId) {
KeymasterBlob appId, int uid) {
try {
return mBinder.exportKey(alias, format, clientId, appId);
return mBinder.exportKey(alias, format, clientId, appId, uid);
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return null;
}
}
public ExportResult exportKey(String alias, int format, KeymasterBlob clientId,
KeymasterBlob appId) {
return exportKey(alias, format, clientId, appId, UID_SELF);
}
public OperationResult begin(String alias, int purpose, boolean pruneable,
KeymasterArguments args, byte[] entropy, int uid) {
try {
return mBinder.begin(getToken(), alias, purpose, pruneable, args, entropy, uid);
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return null;
@@ -460,12 +487,7 @@ public class KeyStore {
public OperationResult begin(String alias, int purpose, boolean pruneable,
KeymasterArguments args, byte[] entropy) {
try {
return mBinder.begin(getToken(), alias, purpose, pruneable, args, entropy);
} catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e);
return null;
}
return begin(alias, purpose, pruneable, args, entropy, UID_SELF);
}
public OperationResult update(IBinder token, KeymasterArguments arguments, byte[] input) {