@@ -20,21 +20,21 @@ module kmac_app
2020 input rst_ni,
2121
2222 // Secret Key from register
23- input [MaxKeyLen- 1 : 0 ] reg_key_data_i [Share],
23+ input [MaxKeyLen- 1 : 0 ] reg_key_data_i[Share],
2424 input key_len_e reg_key_len_i,
2525
2626 // Prefix from register
2727 input [sha3_pkg :: NSRegisterSize* 8 - 1 : 0 ] reg_prefix_i,
2828
2929 // mode, strength, kmac_en from register
30- input reg_kmac_en_i,
30+ input logic reg_kmac_en_i,
3131 input sha3_pkg :: sha3_mode_e reg_sha3_mode_i,
3232 input sha3_pkg :: keccak_strength_e reg_keccak_strength_i,
3333
3434 // Data from Software
3535 input sw_valid_i,
3636 input [MsgWidth- 1 : 0 ] sw_data_i,
37- input [MsgWidth- 1 : 0 ] sw_mask_i ,
37+ input [MsgWidth- 1 : 0 ] sw_strb_i ,
3838 output logic sw_ready_o,
3939
4040 // KeyMgr Sideload Key interface
@@ -45,14 +45,15 @@ module kmac_app
4545 output app_rsp_t [NumAppIntf- 1 : 0 ] app_o,
4646
4747 // to KMAC Core: Secret key
48- output logic [MaxKeyLen- 1 : 0 ] key_data_o [Share],
48+ output logic [MaxKeyLen- 1 : 0 ] key_data_o[Share],
4949 output key_len_e key_len_o,
5050 output logic key_valid_o,
5151
5252 // to MSG_FIFO
5353 output logic kmac_valid_o,
5454 output logic [MsgWidth- 1 : 0 ] kmac_data_o,
55- output logic [MsgWidth- 1 : 0 ] kmac_mask_o,
55+ // This strobe is on bit level for the packer. The FIFO will then convert it again to byte level.
56+ output logic [MsgWidth- 1 : 0 ] kmac_strb_o,
5657 input kmac_ready_i,
5758
5859 // KMAC Core
@@ -65,19 +66,20 @@ module kmac_app
6566
6667 // STATE from SHA3 Core
6768 input keccak_state_valid_i,
68- input [sha3_pkg :: StateW- 1 : 0 ] keccak_state_i [Share],
69+ input [sha3_pkg :: StateW- 1 : 0 ] keccak_state_i[Share],
6970
7071 // to STATE TL-window if Application is not active, the incoming state goes to
7172 // register if kdf_en is set, the state value goes to application and the
7273 // output to the register is all zero.
7374 output logic reg_state_valid_o,
74- output logic [sha3_pkg :: StateW- 1 : 0 ] reg_state_o [Share],
75+ output logic [sha3_pkg :: StateW- 1 : 0 ] reg_state_o[Share],
7576
76- // Configurations If key_en is set, the logic uses KeyMgr's sideloaded key as
77- // a secret key rather than register values. This only affects when software
78- // initiates. If App initiates the hash operation and uses KMAC algorithm, it
79- // always uses sideloaded key.
80- input keymgr_key_en_i,
77+ // Controls for SW and CmdApp operations whether to take the key from the KeyMgr sideload
78+ // interface or registers. For KMAC operations initiated by an app interface, we always take the
79+ // sideloaded key.
80+ // If 1, the key for KMAC is taken from the KeyMgr sideload interface.
81+ // If 0, the key is taken from the registers.
82+ input logic keymgr_key_en_i,
8183
8284 // Commands
8385 // Command from software
@@ -166,7 +168,7 @@ module kmac_app
166168 24'h 02_0002 // Key512
167169 } ;
168170
169- localparam logic [OutLenW- 1 : 0 ] EncodedOutLenMask [5 ] = '{
171+ localparam logic [OutLenW- 1 : 0 ] EncodedOutLenStrb [5 ] = '{
170172 24'h 00FFFF , // Key128,
171173 24'h 00FFFF , // Key192
172174 24'h FFFFFF , // Key256
@@ -200,7 +202,7 @@ module kmac_app
200202 logic clr_appid, set_appid;
201203
202204 // Output length
203- logic [OutLenW- 1 : 0 ] encoded_outlen, encoded_outlen_mask ;
205+ logic [OutLenW- 1 : 0 ] encoded_outlen, encoded_outlen_strb ;
204206
205207 // state output
206208 // Mux selection signal
@@ -600,7 +602,7 @@ module kmac_app
600602
601603 // Encoded output length
602604 assign encoded_outlen = EncodedOutLen[SelDigSize];
603- assign encoded_outlen_mask = EncodedOutLenMask [SelKeySize];
605+ assign encoded_outlen_strb = EncodedOutLenStrb [SelKeySize];
604606
605607 // Data mux
606608 // This is the main part of the KeyMgr interface logic.
@@ -615,7 +617,7 @@ module kmac_app
615617
616618 kmac_valid_o = 1'b 0 ;
617619 kmac_data_o = '0 ;
618- kmac_mask_o = '0 ;
620+ kmac_strb_o = '0 ;
619621
620622 unique case (mux_sel_buf_kmac)
621623 SelApp: begin
@@ -624,7 +626,7 @@ module kmac_app
624626 kmac_data_o = app_i[app_id].data;
625627 // Expand strb to bits. prim_packer inside MSG_FIFO accepts the bit masks
626628 for (int i = 0 ; i < $bits (app_i[app_id].strb) ; i++ ) begin
627- kmac_mask_o [8 * i+ : 8 ] = { 8 { app_i[app_id].strb[i]}} ;
629+ kmac_strb_o [8 * i+ : 8 ] = { 8 { app_i[app_id].strb[i]}} ;
628630 end
629631 app_data_ready = kmac_ready_i;
630632 end
@@ -633,20 +635,20 @@ module kmac_app
633635 // Write encoded output length value
634636 kmac_valid_o = 1'b 1 ; // always write
635637 kmac_data_o = MsgWidth ' (encoded_outlen);
636- kmac_mask_o = MsgWidth ' (encoded_outlen_mask );
638+ kmac_strb_o = MsgWidth ' (encoded_outlen_strb );
637639 end
638640
639641 SelSw: begin
640642 kmac_valid_o = sw_valid_i;
641643 kmac_data_o = sw_data_i ;
642- kmac_mask_o = sw_mask_i ;
644+ kmac_strb_o = sw_strb_i ;
643645 sw_ready_o = kmac_ready_i ;
644646 end
645647
646648 default : begin // Incl. SelNone
647649 kmac_valid_o = 1'b 0 ;
648650 kmac_data_o = '0 ;
649- kmac_mask_o = '0 ;
651+ kmac_strb_o = '0 ;
650652 end
651653
652654 endcase
@@ -741,7 +743,7 @@ module kmac_app
741743 end
742744 end
743745
744- // Keccak state --> KeyMgr
746+ // Keccak state --> App interface
745747 always_comb begin
746748 app_digest_done = 1'b 0 ;
747749 app_digest = '{ default : '0 } ;
@@ -764,7 +766,7 @@ module kmac_app
764766 // Prepare merged key if EnMasking is not set.
765767 // Combine share keys into unpacked array for logic below to assign easily.
766768 // SEC_CM: KEY.SIDELOAD
767- logic [MaxKeyLen- 1 : 0 ] keymgr_key [Share];
769+ logic [MaxKeyLen- 1 : 0 ] keymgr_key[Share];
768770 if (EnMasking == 1 ) begin : g_masked_key
769771 for (genvar i = 0 ; i < Share; i++ ) begin : gen_key_pad
770772 assign keymgr_key[i] = { (MaxKeyLen- KeyMgrKeyW)'(0 ), keymgr_key_i.key[i]} ;
0 commit comments