@@ -77,6 +77,7 @@ typedef struct {
77
77
void * recv_pdu ; /**< received pdu */
78
78
uint16_t recv_size ; /**< received pdu size */
79
79
uint64_t recv_replay_cnt ; /**< received replay counter */
80
+ bool msg3_received : 1 ; /**< Valid Message 3 has been received */
80
81
bool msg3_retry_wait : 1 ; /**< Waiting for Message 3 retry */
81
82
} fwh_sec_prot_int_t ;
82
83
@@ -137,6 +138,7 @@ static int8_t supp_fwh_sec_prot_init(sec_prot_t *prot)
137
138
sec_prot_state_set (prot , & data -> common , FWH_STATE_INIT );
138
139
139
140
data -> common .ticks = 30 * 10 ; // 30 seconds
141
+ data -> msg3_received = false;
140
142
data -> msg3_retry_wait = false;
141
143
data -> recv_replay_cnt = 0 ;
142
144
@@ -351,6 +353,9 @@ static void supp_fwh_sec_prot_state_machine(sec_prot_t *prot)
351
353
if (supp_fwh_sec_prot_ptk_generate (prot , prot -> sec_keys ) < 0 ) {
352
354
return ;
353
355
}
356
+
357
+ supp_fwh_sec_prot_recv_replay_counter_store (prot );
358
+
354
359
// Send 4WH message 2
355
360
supp_fwh_sec_prot_message_send (prot , FWH_MESSAGE_2 );
356
361
data -> common .ticks = 30 * 10 ; // 30 seconds
@@ -376,6 +381,7 @@ static void supp_fwh_sec_prot_state_machine(sec_prot_t *prot)
376
381
377
382
supp_fwh_sec_prot_recv_replay_counter_store (prot );
378
383
supp_fwh_sec_prot_security_replay_counter_update (prot );
384
+ data -> msg3_received = true;
379
385
380
386
// Sends 4WH Message 4
381
387
supp_fwh_sec_prot_message_send (prot , FWH_MESSAGE_4 );
@@ -389,17 +395,24 @@ static void supp_fwh_sec_prot_state_machine(sec_prot_t *prot)
389
395
sec_prot_state_set (prot , & data -> common , FWH_STATE_FINISHED );
390
396
return ;
391
397
}
392
- data -> msg3_retry_wait = true;
393
398
394
- tr_info ("4WH: finish, wait Message 3 retry" );
399
+ // If Message 3 has been received updates key data and waits for Message 3 retry
400
+ if (data -> msg3_received ) {
401
+ data -> msg3_retry_wait = true;
402
+
403
+ tr_info ("4WH: finish, wait Message 3 retry" );
404
+
405
+ sec_prot_keys_ptk_write (prot -> sec_keys , data -> new_ptk );
406
+ sec_prot_keys_ptk_eui_64_write (prot -> sec_keys , data -> remote_eui64 );
407
+
408
+ data -> common .ticks = 60 * 10 ; // 60 seconds
409
+ sec_prot_state_set (prot , & data -> common , FWH_STATE_MESSAGE_3_RETRY_WAIT );
410
+ } else {
411
+ tr_info ("4WH: finish" );
412
+ }
395
413
396
414
// KMP-FINISHED.indication
397
- sec_prot_keys_ptk_write (prot -> sec_keys , data -> new_ptk );
398
- sec_prot_keys_ptk_eui_64_write (prot -> sec_keys , data -> remote_eui64 );
399
415
prot -> finished_ind (prot , sec_prot_result_get (& data -> common ), prot -> sec_keys );
400
-
401
- data -> common .ticks = 60 * 10 ; // 60 seconds
402
- sec_prot_state_set (prot , & data -> common , FWH_STATE_MESSAGE_3_RETRY_WAIT );
403
416
break ;
404
417
405
418
case FWH_STATE_MESSAGE_3_RETRY_WAIT :
0 commit comments