diff options
author | Kenny Root <kroot@google.com> | 2012-08-14 10:47:54 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2012-08-14 12:48:43 -0700 |
commit | 9a53d3eaf42104ddf02feeccec3cf7f5c1a34bae (patch) | |
tree | f54c67f716beb8e4eda51d16595f1ad159899e9c | |
parent | aa8467e59b561f454ff7ec902aae688145d8d297 (diff) | |
download | android_system_security-9a53d3eaf42104ddf02feeccec3cf7f5c1a34bae.tar.gz android_system_security-9a53d3eaf42104ddf02feeccec3cf7f5c1a34bae.tar.bz2 android_system_security-9a53d3eaf42104ddf02feeccec3cf7f5c1a34bae.zip |
keymaster HAL users don't need delete_keypair
The keymaster HAL implementations don't need the delete_keypair method,
but keystore currently throws an error when it's not implemented. This
causes problems with at least the OpenSSL software implementation.
Bug: 6985351
Change-Id: I3d7f7dce2a6d4aad38c20f555ab16aa45f1823b8
-rw-r--r-- | keystore/keystore.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/keystore/keystore.cpp b/keystore/keystore.cpp index 6f506dd..d90b999 100644 --- a/keystore/keystore.cpp +++ b/keystore/keystore.cpp @@ -1156,19 +1156,25 @@ static ResponseCode del_key(KeyStore* keyStore, int, uid_t uid, Value* keyName, return responseCode; } + ResponseCode rc = NO_ERROR; + const keymaster_device_t* device = keyStore->getDevice(); if (device == NULL) { - return SYSTEM_ERROR; + rc = SYSTEM_ERROR; + } else { + // A device doesn't have to implement delete_keypair. + if (device->delete_keypair != NULL) { + if (device->delete_keypair(device, keyBlob.getValue(), keyBlob.getLength())) { + rc = SYSTEM_ERROR; + } + } } - if (device->delete_keypair == NULL) { - ALOGE("device has no delete_keypair implementation!"); - return SYSTEM_ERROR; + if (rc != NO_ERROR) { + return rc; } - int rc = device->delete_keypair(device, keyBlob.getValue(), keyBlob.getLength()); - - return rc ? SYSTEM_ERROR : NO_ERROR; + return (unlink(filename) && errno != ENOENT) ? SYSTEM_ERROR : NO_ERROR; } static ResponseCode sign(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* data, |