Merge "keymaster HAL users don't need delete_keypair"

This commit is contained in:
Kenny Root 2012-08-14 13:41:49 -07:00 committed by android code review
commit 593786c9b8

View file

@ -1156,19 +1156,25 @@ static ResponseCode del_key(KeyStore* keyStore, int, uid_t uid, Value* keyName,
return responseCode; return responseCode;
} }
ResponseCode rc = NO_ERROR;
const keymaster_device_t* device = keyStore->getDevice(); const keymaster_device_t* device = keyStore->getDevice();
if (device == NULL) { 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) { if (rc != NO_ERROR) {
ALOGE("device has no delete_keypair implementation!"); return rc;
return SYSTEM_ERROR;
} }
int rc = device->delete_keypair(device, keyBlob.getValue(), keyBlob.getLength()); return (unlink(filename) && errno != ENOENT) ? SYSTEM_ERROR : NO_ERROR;
return rc ? SYSTEM_ERROR : NO_ERROR;
} }
static ResponseCode sign(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* data, static ResponseCode sign(KeyStore* keyStore, int sock, uid_t uid, Value* keyName, Value* data,