Merge "Process large messages from TA"
This commit is contained in:
commit
6dfeccf9c8
|
@ -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,8 +57,10 @@ impl SerializedChannel for TipcChannel {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
|
let mut expect_more_msgs = true;
|
||||||
|
let mut full_rsp = Vec::new();
|
||||||
|
while expect_more_msgs {
|
||||||
let mut recv_buf = Vec::new();
|
let mut recv_buf = Vec::new();
|
||||||
// TODO(b/253501976): cope with fragmentation of responses
|
|
||||||
self.0.recv(&mut recv_buf).map_err(|e| {
|
self.0.recv(&mut recv_buf).map_err(|e| {
|
||||||
binder::Status::new_exception(
|
binder::Status::new_exception(
|
||||||
binder::ExceptionCode::TRANSACTION_FAILED,
|
binder::ExceptionCode::TRANSACTION_FAILED,
|
||||||
|
@ -68,7 +73,11 @@ impl SerializedChannel for TipcChannel {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
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…
Reference in New Issue