trusty: keymaster: Implement begin

Test: builds
Change-Id: Icb5470a8c95131ee3d68ab2ce41423302b9ed531
This commit is contained in:
Jocelyn Bohr 2017-02-09 17:40:47 -08:00
parent 22812e9a30
commit d7da42c0fa
1 changed files with 35 additions and 0 deletions

View File

@ -463,6 +463,41 @@ keymaster_error_t TrustyKeymasterDevice::begin(keymaster_purpose_t purpose,
keymaster_key_param_set_t* out_params,
keymaster_operation_handle_t* operation_handle) {
ALOGD("Device received begin");
if (error_ != KM_ERROR_OK) {
return error_;
}
if (!key || !key->key_material) {
return KM_ERROR_UNEXPECTED_NULL_POINTER;
}
if (!operation_handle) {
return KM_ERROR_OUTPUT_PARAMETER_NULL;
}
if (out_params) {
*out_params = {};
}
BeginOperationRequest request;
request.purpose = purpose;
request.SetKeyMaterial(*key);
request.additional_params.Reinitialize(*in_params);
BeginOperationResponse response;
keymaster_error_t err = Send(KM_BEGIN_OPERATION, request, &response);
if (err != KM_ERROR_OK) {
return err;
}
if (response.output_params.size() > 0) {
if (out_params) {
response.output_params.CopyToParamSet(out_params);
} else {
return KM_ERROR_OUTPUT_PARAMETER_NULL;
}
}
*operation_handle = response.op_handle;
return KM_ERROR_OK;
}