File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 3
3
use crate :: {
4
4
constants:: tss:: TPM2_RH_UNASSIGNED ,
5
5
context:: handle_manager:: HandleDropAction ,
6
- ffi:: to_owned_bytes,
6
+ ffi:: { to_owned_bytes, FfiSizeType } ,
7
7
handles:: ObjectHandle ,
8
8
handles:: { handle_conversion:: TryIntoNotNone , TpmHandle } ,
9
9
structures:: Auth ,
@@ -516,17 +516,15 @@ impl Context {
516
516
/// let new_handle = context.tr_deserialize(&data).unwrap();
517
517
/// assert_eq!(public_key, context.read_public(new_handle.into()).unwrap());
518
518
/// ```
519
- pub fn tr_deserialize ( & mut self , buffer : & Vec < u8 > ) -> Result < ObjectHandle > {
519
+ pub fn tr_deserialize ( & mut self , buffer : & [ u8 ] ) -> Result < ObjectHandle > {
520
520
let mut handle = TPM2_RH_UNASSIGNED ;
521
+ let size = FfiSizeType :: try_from ( buffer. len ( ) ) ?;
521
522
ReturnCode :: ensure_success (
522
523
unsafe {
523
524
Esys_TR_Deserialize (
524
525
self . mut_context ( ) ,
525
526
buffer. as_ptr ( ) ,
526
- buffer. len ( ) . try_into ( ) . map_err ( |e| {
527
- error ! ( "Failed to convert buffer len to usize: {}" , e) ;
528
- Error :: local_error ( WrapperErrorKind :: InvalidParam )
529
- } ) ?,
527
+ size. into ( ) ,
530
528
& mut handle,
531
529
)
532
530
} ,
You can’t perform that action at this time.
0 commit comments