@@ -51,9 +51,6 @@ const MIGTD_DATA_TYPE_INIT_MIG_POLICY: u32 = 0;
5151const MIGTD_DATA_TYPE_INIT_TD_REPORT : u32 = 1 ;
5252const MIGTD_DATA_TYPE_INIT_EVENT_LOG : u32 = 2 ;
5353
54- const MIGTD_REBIND_OP_PREPARE : u8 = 0 ;
55- const MIGTD_REBIND_OP_FINALIZE : u8 = 1 ;
56-
5754#[ repr( C ) ]
5855pub struct RebindingToken {
5956 token : [ u8 ; 32 ] ,
@@ -90,22 +87,20 @@ pub struct RebindingInfo {
9087 pub mig_request_id : u64 ,
9188 pub rebinding_src : u8 ,
9289 pub has_init_data : u8 ,
93- pub operation : u8 ,
9490 pub target_td_uuid : [ u64 ; 4 ] ,
9591 pub binding_handle : u64 ,
9692 pub init_migtd_data : Option < InitData > ,
9793}
9894
9995impl RebindingInfo {
10096 pub fn read_from_bytes ( b : & [ u8 ] ) -> Option < Self > {
101- // Check the length of input and the reserved fields
102- if b. len ( ) < 56 || b[ 11 ..16 ] != [ 0 ; 5 ] {
97+ // Check the length of input and the reserved fields (bytes 10-15 per GHCI 1.5)
98+ if b. len ( ) < 56 || b[ 10 ..16 ] != [ 0 ; 6 ] {
10399 return None ;
104100 }
105101 let mig_request_id = u64:: from_le_bytes ( b[ ..8 ] . try_into ( ) . unwrap ( ) ) ;
106102 let rebinding_src = b[ 8 ] ;
107103 let has_init_data = b[ 9 ] ;
108- let operation = b[ 10 ] ;
109104
110105 let target_td_uuid: [ u64 ; 4 ] = core:: array:: from_fn ( |i| {
111106 let offset = 16 + i * 8 ;
@@ -123,7 +118,6 @@ impl RebindingInfo {
123118 mig_request_id,
124119 rebinding_src,
125120 has_init_data,
126- operation,
127121 target_td_uuid,
128122 binding_handle,
129123 init_migtd_data,
@@ -392,90 +386,77 @@ pub async fn start_rebinding(
392386 // Exchange policy firstly because of the message size limitation of TLS protocol
393387 const PRE_SESSION_TIMEOUT : Duration = Duration :: from_secs ( 60 ) ; // 60 seconds
394388 if info. rebinding_src == 1 {
395- match info. operation {
396- MIGTD_REBIND_OP_PREPARE => {
397- let local_data = InitData :: get_from_local ( & [ 0u8 ; 64 ] )
398- . ok_or ( MigrationResult :: InvalidParameter ) ?;
399- let init_migtd_data = info
400- . init_migtd_data
401- . as_ref ( )
402- . or ( Some ( & local_data) )
403- . ok_or ( MigrationResult :: InvalidParameter ) ?;
404- let remote_policy = Box :: pin ( with_timeout (
405- PRE_SESSION_TIMEOUT ,
406- rebinding_old_pre_session_data_exchange ( & mut transport, & init_migtd_data. init_policy ) ,
407- ) )
408- . await
409- . map_err ( |e| {
410- log:: error!(
411- "start_rebinding: rebinding_old_pre_session_data_exchange timeout error: {:?}\n " ,
412- e
413- ) ;
414- e
415- } ) ?
416- . map_err ( |e| {
417- log:: error!(
418- "start_rebinding: rebinding_old_pre_session_data_exchange error: {:?}\n " ,
419- e
420- ) ;
421- e
422- } ) ?;
423- #[ cfg( not( feature = "spdm_attestation" ) ) ]
424- rebinding_old_prepare ( transport, info, & init_migtd_data, data, remote_policy)
425- . await ?;
426-
427- #[ cfg( feature = "spdm_attestation" ) ]
428- rebinding_old_prepare (
429- transport,
430- info,
431- data,
432- #[ cfg( feature = "policy_v2" ) ]
433- remote_policy,
434- )
435- . await ?;
436- }
437- MIGTD_REBIND_OP_FINALIZE => rebinding_old_finalize ( info, data) . await ?,
438- _ => return Err ( MigrationResult :: InvalidParameter ) ,
439- }
389+ let local_data =
390+ InitData :: get_from_local ( & [ 0u8 ; 64 ] ) . ok_or ( MigrationResult :: InvalidParameter ) ?;
391+ let init_migtd_data = info
392+ . init_migtd_data
393+ . as_ref ( )
394+ . or ( Some ( & local_data) )
395+ . ok_or ( MigrationResult :: InvalidParameter ) ?;
396+ let remote_policy = Box :: pin ( with_timeout (
397+ PRE_SESSION_TIMEOUT ,
398+ rebinding_old_pre_session_data_exchange ( & mut transport, & init_migtd_data. init_policy ) ,
399+ ) )
400+ . await
401+ . map_err ( |e| {
402+ log:: error!(
403+ "start_rebinding: rebinding_old_pre_session_data_exchange timeout error: {:?}\n " ,
404+ e
405+ ) ;
406+ e
407+ } ) ?
408+ . map_err ( |e| {
409+ log:: error!(
410+ "start_rebinding: rebinding_old_pre_session_data_exchange error: {:?}\n " ,
411+ e
412+ ) ;
413+ e
414+ } ) ?;
415+ #[ cfg( not( feature = "spdm_attestation" ) ) ]
416+ rebinding_old_prepare ( transport, info, & init_migtd_data, data, remote_policy) . await ?;
417+
418+ #[ cfg( feature = "spdm_attestation" ) ]
419+ rebinding_old_prepare (
420+ transport,
421+ info,
422+ data,
423+ #[ cfg( feature = "policy_v2" ) ]
424+ remote_policy,
425+ )
426+ . await ?;
440427 } else {
441- match info. operation {
442- MIGTD_REBIND_OP_PREPARE => {
443- let pre_session_data = Box :: pin ( with_timeout (
444- PRE_SESSION_TIMEOUT ,
445- rebinding_new_pre_session_data_exchange ( & mut transport) ,
446- ) )
447- . await
448- . map_err ( |e| {
449- log:: error!(
450- "start_rebinding: rebinding_new_pre_session_data_exchange timeout error: {:?}\n " ,
451- e
452- ) ;
453- e
454- } ) ?
455- . map_err ( |e| {
456- log:: error!(
457- "start_rebinding: rebinding_new_pre_session_data_exchange error: {:?}\n " ,
458- e
459- ) ;
460- e
461- } ) ?;
462-
463- #[ cfg( not( feature = "spdm_attestation" ) ) ]
464- rebinding_new_prepare ( transport, info, data, pre_session_data) . await ?;
465-
466- #[ cfg( feature = "spdm_attestation" ) ]
467- rebinding_new_prepare (
468- transport,
469- info,
470- data,
471- #[ cfg( feature = "policy_v2" ) ]
472- pre_session_data,
473- )
474- . await ?;
475- }
476- MIGTD_REBIND_OP_FINALIZE => rebinding_new_finalize ( info, data) . await ?,
477- _ => return Err ( MigrationResult :: InvalidParameter ) ,
478- }
428+ let pre_session_data = Box :: pin ( with_timeout (
429+ PRE_SESSION_TIMEOUT ,
430+ rebinding_new_pre_session_data_exchange ( & mut transport) ,
431+ ) )
432+ . await
433+ . map_err ( |e| {
434+ log:: error!(
435+ "start_rebinding: rebinding_new_pre_session_data_exchange timeout error: {:?}\n " ,
436+ e
437+ ) ;
438+ e
439+ } ) ?
440+ . map_err ( |e| {
441+ log:: error!(
442+ "start_rebinding: rebinding_new_pre_session_data_exchange error: {:?}\n " ,
443+ e
444+ ) ;
445+ e
446+ } ) ?;
447+
448+ #[ cfg( not( feature = "spdm_attestation" ) ) ]
449+ rebinding_new_prepare ( transport, info, data, pre_session_data) . await ?;
450+
451+ #[ cfg( feature = "spdm_attestation" ) ]
452+ rebinding_new_prepare (
453+ transport,
454+ info,
455+ data,
456+ #[ cfg( feature = "policy_v2" ) ]
457+ pre_session_data,
458+ )
459+ . await ?;
479460 }
480461 #[ cfg( feature = "vmcall-raw" ) ]
481462 {
@@ -629,14 +610,8 @@ async fn rebinding_old_prepare(
629610 Ok ( ( ) )
630611}
631612
632- pub async fn rebinding_old_finalize (
633- _info : & RebindingInfo ,
634- _data : & mut Vec < u8 > ,
635- ) -> Result < ( ) , MigrationResult > {
636- Ok ( ( ) )
637- }
638-
639613#[ cfg( not( feature = "spdm_attestation" ) ) ]
614+
640615async fn rebinding_new_prepare (
641616 transport : TransportType ,
642617 info : & RebindingInfo ,
@@ -675,15 +650,6 @@ async fn rebinding_new_prepare(
675650 Ok ( ( ) )
676651}
677652
678- async fn rebinding_new_finalize (
679- _info : & RebindingInfo ,
680- _data : & mut Vec < u8 > ,
681- ) -> Result < ( ) , MigrationResult > {
682- write_rebinding_session_token ( & [ 0u8 ; 32 ] ) ?;
683- write_approved_servtd_ext_hash ( & [ 0u8 ; SHA384_DIGEST_SIZE ] ) ?;
684- Ok ( ( ) )
685- }
686-
687653pub fn write_rebinding_session_token ( rebind_token : & [ u8 ] ) -> Result < ( ) , MigrationResult > {
688654 if rebind_token. len ( ) != 32 {
689655 return Err ( MigrationResult :: InvalidParameter ) ;
0 commit comments