From 4516ca7cc0b2650d67455d6443da60cd42631c0a Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Mon, 18 Mar 2019 13:04:34 -0700 Subject: Fix ImportWrappedKeyRequest Serialization SerializedSize is missing the biometric_sid and password_sid fields, and Serialize forgets to update the buffer pointer after each append. Bug: 128851694 Test: VTS 4.0 against Trusty implementation Change-Id: Ie4d3eb918c1d0344c7eaed2087050f446cc892f1 --- android_keymaster/android_keymaster_messages.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/android_keymaster/android_keymaster_messages.cpp b/android_keymaster/android_keymaster_messages.cpp index 1c5695e..6eb6a5f 100644 --- a/android_keymaster/android_keymaster_messages.cpp +++ b/android_keymaster/android_keymaster_messages.cpp @@ -635,13 +635,14 @@ size_t ImportWrappedKeyRequest::SerializedSize() const { return sizeof(uint32_t) /* wrapped_key_data_length */ + wrapped_key.key_material_size + sizeof(uint32_t) /* wrapping_key_data_length */ + wrapping_key.key_material_size + sizeof(uint32_t) /* masking_key_data_length */ + masking_key.key_material_size + - additional_params.SerializedSize(); + additional_params.SerializedSize() + sizeof(uint64_t) /* password_sid */ + + sizeof(uint64_t) /* biometric_sid */; } uint8_t* ImportWrappedKeyRequest::Serialize(uint8_t* buf, const uint8_t* end) const { - serialize_key_blob(wrapped_key, buf, end); - serialize_key_blob(wrapping_key, buf, end); - serialize_key_blob(masking_key, buf, end); + buf = serialize_key_blob(wrapped_key, buf, end); + buf = serialize_key_blob(wrapping_key, buf, end); + buf = serialize_key_blob(masking_key, buf, end); buf = additional_params.Serialize(buf, end); buf = append_uint64_to_buf(buf, end, password_sid); return append_uint64_to_buf(buf, end, biometric_sid); -- cgit v1.2.3