Merge "Process large messages from TA" am: 6dfeccf9c8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2255237 Change-Id: I3be470fe74b409dbd6c2ac290a83c93139f7d76a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
65b3fb7f5e
1 changed files with 25 additions and 16 deletions
|
|
@ -14,7 +14,9 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
//! This module implements the HAL service for Keymint (Rust) in Trusty.
|
//! This module implements the HAL service for Keymint (Rust) in Trusty.
|
||||||
use kmr_hal::{keymint, rpc, secureclock, send_hal_info, sharedsecret, SerializedChannel};
|
use kmr_hal::{
|
||||||
|
extract_rsp, keymint, rpc, secureclock, send_hal_info, sharedsecret, SerializedChannel,
|
||||||
|
};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use std::{
|
use std::{
|
||||||
ffi::CString,
|
ffi::CString,
|
||||||
|
|
@ -41,6 +43,7 @@ struct HalServiceError(String);
|
||||||
struct TipcChannel(trusty::TipcChannel);
|
struct TipcChannel(trusty::TipcChannel);
|
||||||
|
|
||||||
impl SerializedChannel for TipcChannel {
|
impl SerializedChannel for TipcChannel {
|
||||||
|
const MAX_SIZE: usize = 4000;
|
||||||
fn execute(&mut self, serialized_req: &[u8]) -> binder::Result<Vec<u8>> {
|
fn execute(&mut self, serialized_req: &[u8]) -> binder::Result<Vec<u8>> {
|
||||||
self.0.send(serialized_req).map_err(|e| {
|
self.0.send(serialized_req).map_err(|e| {
|
||||||
binder::Status::new_exception(
|
binder::Status::new_exception(
|
||||||
|
|
@ -54,21 +57,27 @@ impl SerializedChannel for TipcChannel {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
let mut recv_buf = Vec::new();
|
let mut expect_more_msgs = true;
|
||||||
// TODO(b/253501976): cope with fragmentation of responses
|
let mut full_rsp = Vec::new();
|
||||||
self.0.recv(&mut recv_buf).map_err(|e| {
|
while expect_more_msgs {
|
||||||
binder::Status::new_exception(
|
let mut recv_buf = Vec::new();
|
||||||
binder::ExceptionCode::TRANSACTION_FAILED,
|
self.0.recv(&mut recv_buf).map_err(|e| {
|
||||||
Some(
|
binder::Status::new_exception(
|
||||||
&CString::new(format!(
|
binder::ExceptionCode::TRANSACTION_FAILED,
|
||||||
"Failed to receive the response via tipc channel because of {:?}",
|
Some(
|
||||||
e
|
&CString::new(format!(
|
||||||
))
|
"Failed to receive the response via tipc channel because of {:?}",
|
||||||
.unwrap(),
|
e
|
||||||
),
|
))
|
||||||
)
|
.unwrap(),
|
||||||
})?;
|
),
|
||||||
Ok(recv_buf)
|
)
|
||||||
|
})?;
|
||||||
|
let current_rsp_content;
|
||||||
|
(expect_more_msgs, current_rsp_content) = extract_rsp(&recv_buf)?;
|
||||||
|
full_rsp.extend_from_slice(current_rsp_content);
|
||||||
|
}
|
||||||
|
Ok(full_rsp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue