@@ -68,6 +68,12 @@ class keymgr_dpe_scoreboard extends cip_base_scoreboard #(
6868 bit is_kmac_rsp_err;
6969 bit is_kmac_invalid_data;
7070 bit is_sw_share_corrupted;
71+ // Indicates if the UDS was fetched by the keymgr_dpe for the first time.
72+ // The UDS needs to be xored with randomness to counter SCA, however the
73+ // current dv environment cannot replicate this randomness. As a workaround
74+ // the generated value (UDS xored with randomness) is loaded by a backdoor
75+ // directly from the DUT.
76+ bit load_uds_with_randomness;
7177
7278 // HW internal key, used for OP in current state
7379 keymgr_dpe_env_pkg :: keymgr_dpe_key_slot_t current_key_slot;
@@ -990,6 +996,12 @@ class keymgr_dpe_scoreboard extends cip_base_scoreboard #(
990996 current_internal_key[current_key_slot.dst_slot].valid = 1 ;
991997 current_internal_key[current_key_slot.dst_slot].boot_stage = keymgr_dpe_pkg :: BootStageCreator;
992998 current_internal_key[current_key_slot.dst_slot].max_key_version = max_key_version;
999+ // This call load the "true" UDS without the randomness present in the
1000+ // hw slot. The problem is that when this function is called (when writing
1001+ // the first time into the start register) the randomness in the hw slot
1002+ // is not yet generated.
1003+ // The current workaround is to backdoor load on the first advance call
1004+ // in the available state as the src_slot has the UDS loaded.
9931005 current_internal_key[current_key_slot.dst_slot].key = otp_key;
9941006 current_internal_key[current_key_slot.dst_slot].key_policy =
9951007 keymgr_dpe_pkg :: DEFAULT_UDS_POLICY ;
@@ -1004,6 +1016,15 @@ class keymgr_dpe_scoreboard extends cip_base_scoreboard #(
10041016 );
10051017 endfunction
10061018
1019+ // Directly access the slot which holds the UDS with the xored randmoness
1020+ // Otherwise the scorebord would need to manually replicate the randomness
1021+ // generation.
1022+ virtual function void backdoor_load_uds (int slot);
1023+ `uvm_info (`gfn , " Load UDS with randomness via backdoor" , UVM_MEDIUM )
1024+ current_internal_key[slot].key =
1025+ cfg.keymgr_dpe_ctrl_vif.get_key_of_slot (slot);
1026+ endfunction
1027+
10071028 virtual function bit [TL_DW - 1 : 0 ] get_current_max_version (
10081029 keymgr_dpe_pkg :: keymgr_dpe_exposed_working_state_e state = current_state);
10091030 // design change this to 0 if LC turns off keymgr_dpe.
@@ -1127,6 +1148,13 @@ class keymgr_dpe_scoreboard extends cip_base_scoreboard #(
11271148 " src_slot valid == 0 err" } , op.name, current_state.name), UVM_MEDIUM )
11281149 return 1 ;
11291150 end
1151+ // Workaround to load the UDS with the xored randomness into the
1152+ // correct internal slot. The first (successful) advance call will
1153+ // use the UDS per default.
1154+ if (load_uds_with_randomness == 1'b0 ) begin
1155+ load_uds_with_randomness = 1'b1 ;
1156+ backdoor_load_uds (current_key_slot.src_slot);
1157+ end
11301158 return 0 ;
11311159 end
11321160 keymgr_dpe_pkg :: OpDpeGenSwOut, keymgr_dpe_pkg :: OpDpeGenHwOut: begin
@@ -1534,6 +1562,7 @@ class keymgr_dpe_scoreboard extends cip_base_scoreboard #(
15341562 is_kmac_rsp_err = 0 ;
15351563 is_kmac_invalid_data = 0 ;
15361564 is_sw_share_corrupted = 0 ;
1565+ load_uds_with_randomness = 0 ;
15371566 req_fifo.flush ();
15381567 rsp_fifo.flush ();
15391568 foreach (current_internal_key[slot]) begin
0 commit comments