summaryrefslogtreecommitdiffstats
path: root/keystore/operation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'keystore/operation.cpp')
-rw-r--r--keystore/operation.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/keystore/operation.cpp b/keystore/operation.cpp
index 2fde0da..e871f83 100644
--- a/keystore/operation.cpp
+++ b/keystore/operation.cpp
@@ -27,9 +27,10 @@ OperationMap::OperationMap(IBinder::DeathRecipient* deathRecipient)
sp<IBinder> OperationMap::addOperation(keymaster_operation_handle_t handle,
const keymaster1_device_t* dev,
sp<IBinder> appToken,
- const keymaster_key_blob_t& key, bool pruneable) {
+ keymaster_key_characteristics_t* characteristics,
+ bool pruneable) {
sp<IBinder> token = new BBinder();
- mMap[token] = Operation(handle, dev, key, appToken);
+ mMap[token] = std::move(Operation(handle, dev, characteristics, appToken));
if (pruneable) {
mLru.push_back(token);
}
@@ -42,7 +43,7 @@ sp<IBinder> OperationMap::addOperation(keymaster_operation_handle_t handle,
bool OperationMap::getOperation(sp<IBinder> token, keymaster_operation_handle_t* outHandle,
const keymaster1_device_t** outDevice,
- keymaster_key_blob_t* key) {
+ const keymaster_key_characteristics_t** outCharacteristics) {
if (!outHandle || !outDevice) {
return false;
}
@@ -54,12 +55,8 @@ bool OperationMap::getOperation(sp<IBinder> token, keymaster_operation_handle_t*
*outHandle = entry->second.handle;
*outDevice = entry->second.device;
- if (key) {
- key->key_material_size = entry->second.key.key_material_size;
- uint8_t* material = new uint8_t[key->key_material_size];
- memcpy(reinterpret_cast<void*>(material), entry->second.key.key_material,
- key->key_material_size);
- key->key_material = material;
+ if (outCharacteristics) {
+ *outCharacteristics = entry->second.characteristics.get();
}
return true;
}
@@ -78,7 +75,6 @@ bool OperationMap::removeOperation(sp<IBinder> token) {
return false;
}
sp<IBinder> appToken = entry->second.appToken;
- delete[] entry->second.key.key_material;
mMap.erase(entry);
auto lruEntry = std::find(mLru.begin(), mLru.end(), token);
if (lruEntry != mLru.end()) {
@@ -125,19 +121,14 @@ std::vector<sp<IBinder>> OperationMap::getOperationsForToken(sp<IBinder> appToke
OperationMap::Operation::Operation(keymaster_operation_handle_t handle_,
const keymaster1_device_t* device_,
- const keymaster_key_blob_t& key_,
+ keymaster_key_characteristics_t* characteristics_,
sp<IBinder> appToken_)
: handle(handle_),
device(device_),
+ characteristics(characteristics_),
appToken(appToken_) {
- uint8_t* material = new uint8_t[key_.key_material_size];
- memcpy(material, key_.key_material, key_.key_material_size);
- key.key_material = material;
- key.key_material_size = key_.key_material_size;
}
-OperationMap::Operation::Operation() : handle(0), device(NULL), appToken(NULL) {
- key.key_material = NULL;
- key.key_material_size = 0;
+OperationMap::Operation::Operation() : handle(0), device(NULL), characteristics(), appToken(NULL) {
}
} // namespace android