Rename KeymasterException to KeyStoreException.
The code in question talks to KeyStore which returns error codes
which are a mix of keystore and keymaster error codes. To better
match the layering of KeyStore on top of keystore and keymaster,
this CL renames KeymasterException into KeyStoreException. It also
adds human-readable error messages to exceptions raised by keystore
rather than keymaster (e.g., key not found).
Bug: 18088752
Change-Id: I4cd1235e16518c9f2e8c5557a457774c6e687b88
diff --git a/keystore/java/android/security/KeyStoreCryptoOperationChunkedStreamer.java b/keystore/java/android/security/KeyStoreCryptoOperationChunkedStreamer.java
index 993614b..1f8b7e4 100644
--- a/keystore/java/android/security/KeyStoreCryptoOperationChunkedStreamer.java
+++ b/keystore/java/android/security/KeyStoreCryptoOperationChunkedStreamer.java
@@ -80,7 +80,7 @@
mMaxChunkSize = maxChunkSize;
}
- public byte[] update(byte[] input, int inputOffset, int inputLength) throws KeymasterException {
+ public byte[] update(byte[] input, int inputOffset, int inputLength) throws KeyStoreException {
if (inputLength == 0) {
// No input provided
return EMPTY_BYTE_ARRAY;
@@ -120,7 +120,7 @@
if (opResult == null) {
throw new KeyStoreConnectException();
} else if (opResult.resultCode != KeyStore.NO_ERROR) {
- throw KeymasterUtils.getKeymasterException(opResult.resultCode);
+ throw KeyStore.getKeyStoreException(opResult.resultCode);
}
if (opResult.inputConsumed == chunk.length) {
@@ -188,7 +188,7 @@
}
public byte[] doFinal(byte[] input, int inputOffset, int inputLength)
- throws KeymasterException {
+ throws KeyStoreException {
if (inputLength == 0) {
// No input provided -- simplify the rest of the code
input = EMPTY_BYTE_ARRAY;
@@ -203,7 +203,7 @@
if (opResult == null) {
throw new KeyStoreConnectException();
} else if (opResult.resultCode != KeyStore.NO_ERROR) {
- throw KeymasterUtils.getKeymasterException(opResult.resultCode);
+ throw KeyStore.getKeyStoreException(opResult.resultCode);
}
return concat(output, opResult.output);
@@ -213,7 +213,7 @@
* Passes all of buffered input into the the KeyStore operation (via the {@code update}
* operation) and returns output.
*/
- public byte[] flush() throws KeymasterException {
+ public byte[] flush() throws KeyStoreException {
if (mBufferedLength <= 0) {
return EMPTY_BYTE_ARRAY;
}
@@ -227,7 +227,7 @@
if (opResult == null) {
throw new KeyStoreConnectException();
} else if (opResult.resultCode != KeyStore.NO_ERROR) {
- throw KeymasterUtils.getKeymasterException(opResult.resultCode);
+ throw KeyStore.getKeyStoreException(opResult.resultCode);
}
if (opResult.inputConsumed < chunk.length) {