[csrng] Return error status response for GEN commands with glen = 0 #23846
Labels
Component:RTL
Type:Enhancement
Feature requests, enhancements
Type:FutureRelease
Not relevant to currently planned releases/milestones
Milestone
Description
When taking care of #18350, I found out that CSRNG treats Generate commands with a glen = 0 similarly to commands with a glen = 1, i.e., it generates one single 128-bit block of random data instead of nothing.
I don't think this is a bug really because the CSRNG documentation specifies:
and further:
In terms of the NIST spec, we are a bit in a gray area here. NIST SP 800-90Ar1 says
What the
returned_bits
actually is ifrequested_number_of_bits
= 0 isn't clear.Right now, CSRNG produces one 128-bit block and also the following CTR_DRBG_Update is done and the reseed counter is incremented. I think this behavior is not intended from an RTL perspective. When receiving the Generate command in the command stage, there is just a check for
glen = 1
:opentitan/hw/ip/csrng/rtl/csrng_cmd_stage.sv
Lines 378 to 391 in 9cfd621
And then also the
u_prim_count_cmd_gen_cntr
output is compared against 1 again. But there is no check against 0. I think the current behavior is a coincidence.Now that we have the capability to signal error status responses, it would probably be better to change the design to return an error response when receiving a Generate command with glen = 0.
The text was updated successfully, but these errors were encountered: