diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-09-28 18:21:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-09-28 18:21:50 +0000 |
commit | bd9751a387d4b587bd284f2661245504f2a92f26 (patch) | |
tree | 01a2c0e51d9417dbb9cf6465a1f0dc65cb32b9c6 | |
parent | 49163e96a154478d314b8207cd1ad6cf10103863 (diff) | |
parent | bfccad24747339aaa0e8d11a0361f5c91061af7d (diff) | |
download | system_core-bd9751a387d4b587bd284f2661245504f2a92f26.tar.gz system_core-bd9751a387d4b587bd284f2661245504f2a92f26.tar.bz2 system_core-bd9751a387d4b587bd284f2661245504f2a92f26.zip |
Merge "trusty: keymaster3: Modify TrustyKeymaster3Device::update method"
-rw-r--r-- | trusty/keymaster/3.0/TrustyKeymaster3Device.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/trusty/keymaster/3.0/TrustyKeymaster3Device.cpp b/trusty/keymaster/3.0/TrustyKeymaster3Device.cpp index 8e3b3b127..0849ee959 100644 --- a/trusty/keymaster/3.0/TrustyKeymaster3Device.cpp +++ b/trusty/keymaster/3.0/TrustyKeymaster3Device.cpp @@ -21,6 +21,7 @@ #include <cutils/log.h> #include <keymaster/android_keymaster_messages.h> #include <trusty_keymaster/TrustyKeymaster3Device.h> +#include <trusty_keymaster/ipc/trusty_keymaster_ipc.h> using ::keymaster::AbortOperationRequest; using ::keymaster::AbortOperationResponse; @@ -393,20 +394,32 @@ Return<void> TrustyKeymaster3Device::update(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams, const hidl_vec<uint8_t>& input, update_cb _hidl_cb) { UpdateOperationRequest request; + UpdateOperationResponse response; + hidl_vec<KeyParameter> resultParams; + hidl_vec<uint8_t> resultBlob; + uint32_t resultConsumed = 0; + request.op_handle = operationHandle; - request.input.Reinitialize(input.data(), input.size()); request.additional_params.Reinitialize(KmParamSet(inParams)); - UpdateOperationResponse response; - impl_->UpdateOperation(request, &response); + size_t inp_size = input.size(); + size_t ser_size = request.SerializedSize(); - uint32_t resultConsumed = 0; - hidl_vec<KeyParameter> resultParams; - hidl_vec<uint8_t> resultBlob; - if (response.error == KM_ERROR_OK) { - resultConsumed = response.input_consumed; - resultParams = kmParamSet2Hidl(response.output_params); - resultBlob = kmBuffer2hidlVec(response.output); + if (ser_size > TRUSTY_KEYMASTER_SEND_BUF_SIZE) { + response.error = KM_ERROR_INVALID_INPUT_LENGTH; + } else { + if (ser_size + inp_size > TRUSTY_KEYMASTER_SEND_BUF_SIZE) { + inp_size = TRUSTY_KEYMASTER_SEND_BUF_SIZE - ser_size; + } + request.input.Reinitialize(input.data(), inp_size); + + impl_->UpdateOperation(request, &response); + + if (response.error == KM_ERROR_OK) { + resultConsumed = response.input_consumed; + resultParams = kmParamSet2Hidl(response.output_params); + resultBlob = kmBuffer2hidlVec(response.output); + } } _hidl_cb(legacy_enum_conversion(response.error), resultConsumed, resultParams, resultBlob); return Void(); |