[csrng/rtl] Mechanism to disable the AES cipher block bypass function
There is a concern that the disabling of the AES cipher block in csrng may be forced by some security attack. There exists two mechanisms to prevent this: one is the lock register will prevents registers to be written after boot time. Another is use an efuse to prevent this from happening. A third alternative is to remove the bypass logic altogether, via the use of a parameter and a condition statement. Looking for a consistent system level way to handle this case.
Referencing https://github.com/lowRISC/opentitan/pull/3842#issue-505088218.
@mwbranstad can you remind me again the purpose of the bypass? I think depending on what its intended function is, we should handle it differently.
For example, if it's meant to be a software decision (ie, we don't know until way later if we want a software or hardware function), then using a lock register is more appropriate.
If this is meant for debugging only, then a fuse bit, or one that is tied into the life cycle would be more appropriate. Since at some point we will move into production and certain types of debug just won't be allowed anymore.
@cdgori @msfschaffner @tomroberts-lowrisc @vogelpi
It occurs to me also that Mark's question, ie in general how we handle things like this, probably should be discussed more at the project level so there is consistency. One thing that's hanging around is the dev_mode_i input going into all the regfiles that we really should tie into life cycle but have said very little about in some time.
Let me know what you guys think.
@tjaychen this bypass function is purely for debug. After verification begins in earnest, it may be that this path is deemed to be removed anyway.
ah if it's purely for debug, I would recommend a connection to life cycle. That way we can make use of it during ATE / RMA if required, and otherwise disable it during field production.
@msfschaffner can comment more here, but we have other things that are in a similar vein.
yeah so in this case I suggest to use the lc_dft_en_i signal, and use it as described below.
this signal will be set to lc_ctrl_pkg::On if the device is in any of the TEST_UNLOCKED* or RMA states, as @tjaychen mentioned above, otherwise it is set to lc_ctrl_pkg::Off (this is a 4bit redundantly encoded value).
- synchronize to local clock domain:
lc_ctrl_pkg::lc_tx_t lc_dft_en;
prim_multibit_sync #(
.Width(lc_ctrl_pkg::TxWidth),
.NumChecks (2),
.ResetValue(lc_ctrl_pkg::TxWidth'(lc_ctrl_pkg::Off))
) u_prim_multibit_sync (
.clk_i,
.rst_ni,
.data_i (lc_dft_en_i),
.data_o (lc_dft_en)
);
- use the signal in order to enable the CSR. you can do this in several ways, but I think the safest would be to add it to the AES cipher enable condition:
assign aes_enable = aes_enable_csr_q || (lc_dft_en != lc_ctrl_pkg::On);
this forces AES to be on if we are not in a DFT-enabled state. if we are in a DFT-enabled state, the CSR can be used to enable/disable AES. if needed, you can additionally force the aes_enable_csr_d value to 1 in case DFT is disabled, for consistency (i.e. such that SW can observe the correct state).
note however that aes_enable should go directly to the logic, and should not be registered if possible in order to minimize susceptibility to glitch attacks (which typically target registers).
Sidenote: I will give an overview over the life cycle signals in the upcoming weeks, which should provide a more complete picture of how this works.
PR #4011 has solved this issue, closing.