You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[kmac] Improve handling of manual PRNG reseeding requests
This commit modifies the design to latch manual PRNG reseeding requests
and to indicate the status of the PRNG via new bits in the status
register. This allows software to verify that a reseed request has
indeed been accepted and prevents the accidental dropping of such
requests in case they reach the PRNG while the SHA3 engine is busy.
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Copy file name to clipboardExpand all lines: hw/ip/kmac/data/kmac.hjson
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -676,7 +676,9 @@
676
676
Software can set this bit to 1 to manually trigger the reseeding of the internal PRNG when running in EDN mode.
677
677
This will also clear !!ENTROPY_REFRESH_HASH_CNT.
678
678
679
-
Note that the hardware may miss the trigger pulse if the module is not idle, or if the module is currently performing a reseed operation.
679
+
After setting this bit, the !!STATUS.entropy_ready bit should read as 0 and the !!STATUS.entropy_reseeding bit as 1 indicating that a reseed operation is ongoing.
680
+
681
+
If masking is disabled, this bit is ignored.
680
682
'''
681
683
}
682
684
{ bits: "9"
@@ -715,6 +717,23 @@
715
717
In this stage, SW can manually run the hashing engine.
716
718
'''
717
719
}
720
+
{ bits: "4"
721
+
name: "entropy_ready"
722
+
desc: '''If 1, the internal PRNG is ready.
723
+
If 0, the internal PRNG is either not configured in EDN mode or software mode, or currently performing a reseed operation via EDN or waiting for software to provide a new seed.
724
+
725
+
If masking is disabled, this bit mirrors the !!CFG_SHADOWED.entropy_ready bit.
726
+
'''
727
+
resval: "0"
728
+
}
729
+
{ bits: "5"
730
+
name: "entropy_reseeding"
731
+
desc: '''If 1, the internal PRNG is currently performing a reseed operation via EDN or waiting for software to provide a new seed.
732
+
733
+
If masking is disabled, this always reads as 0.
734
+
'''
735
+
resval: "0"
736
+
}
718
737
{ bits: "12:8"
719
738
name: "fifo_depth"
720
739
desc: "Count of occupied entries in the message FIFO."
Copy file name to clipboardExpand all lines: hw/ip/kmac/doc/programmers_guide.md
+3-10Lines changed: 3 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,18 +94,11 @@ If the value of [`ENTROPY_REFRESH_HASH_CNT`](registers.md#entropy_refresh_hash_c
94
94
1. Ensure that the entropy complex is running.
95
95
2. Check that the KMAC module is idle by reading the [`STATUS.sha3_idle`](registers.md#status--sha3_idle) bit.
96
96
3. Trigger a manual reseed operation by setting the [`CMD.entropy_req`](registers.md#cmd--entropy_req) bit.
97
-
4. Configure the module to process a message in cSHAKE mode (but not in KMAC mode).
98
-
More precisely, set [`CFG_SHADOWED.mode`](registers.md#cfg_shadowed--mode) to `0x3` and [`CFG_SHADOWED.kmac_en`](registers.md#cfg_shadowed--kmac_en) to 0.
99
-
5. Configure the module to use the PRNG and block any hashing operation if the PRNG is not ready by setting [`CFG_SHADOWED.entropy_fast_process`](registers.md#cfg_shadowed--entropy_fast_process) to 0.
100
-
6. Send the `start` command to the [`CMD`](registers.md#cmd) register.
101
-
The SHA3 engine will start loading and hashing the function name `N` and the customization string `S` first.
102
-
7. Send the `process` command to the [`CMD`](registers.md#cmd) register.
103
-
8. Wait for the [`STATUS.sha3_squeeze`](registers.md#status--sha3_squeeze) bit to get set.
104
-
Due to the ongoing reseed operation, the [`STATUS.sha3_squeeze`](registers.md#status--sha3_squeeze) bit should remain 0 for an extended period of time.
105
-
9. Send the `done` command to the [`CMD`](registers.md#cmd) register to finish processing.
97
+
4. Wait for the [`STATUS.entropy_reseeding`](registers.md#status--entropy_reseeding) bit to get set.
98
+
Due to the ongoing reseed operation, the [`STATUS.entropy_reseeding`](registers.md#status--entropy_reseeding) bit should remain 1 for an extended period of time.
99
+
5. Wait for the [`STATUS.entropy_reseeding`](registers.md#status--entropy_reseeding) bit to get cleared and the [`STATUS.entropy_ready`](registers.md#status--entropy_ready) bit to get set.
106
100
107
101
The [`ENTROPY_REFRESH_HASH_CNT`](registers.md#entropy_refresh_hash_cnt) register should now read as 0.
108
-
Note however that if the manual reseed operation is triggered while the KMAC module is busy, the reseed operation may get skipped despite the hash counter being cleared back to 0.
109
102
110
103
111
104
#### Checking Message FIFO depth before pushing data
Copy file name to clipboardExpand all lines: hw/ip/kmac/doc/registers.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -369,7 +369,9 @@ Software can set this bit to 1 to manually clear [`ENTROPY_REFRESH_HASH_CNT.`](#
369
369
Software can set this bit to 1 to manually trigger the reseeding of the internal PRNG when running in EDN mode.
370
370
This will also clear [`ENTROPY_REFRESH_HASH_CNT.`](#entropy_refresh_hash_cnt)
371
371
372
-
Note that the hardware may miss the trigger pulse if the module is not idle, or if the module is currently performing a reseed operation.
372
+
After setting this bit, the [`STATUS.entropy_ready`](#status) bit should read as 0 and the [`STATUS.entropy_reseeding`](#status) bit as 1 indicating that a reseed operation is ongoing.
373
+
374
+
If masking is disabled, this bit is ignored.
373
375
374
376
### CMD . cmd
375
377
Issue a command to the KMAC/SHA3 IP. The command is sparse
| 2 | ro | x |[sha3_squeeze](#status--sha3_squeeze)|
411
416
| 1 | ro | x |[sha3_absorb](#status--sha3_absorb)|
412
417
| 0 | ro | 0x1 |[sha3_idle](#status--sha3_idle)|
@@ -444,6 +449,17 @@ See the "Message FIFO" section in the spec for the reason.
444
449
### STATUS . fifo_depth
445
450
Count of occupied entries in the message FIFO.
446
451
452
+
### STATUS . entropy_reseeding
453
+
If 1, the internal PRNG is currently performing a reseed operation via EDN or waiting for software to provide a new seed.
454
+
455
+
If masking is disabled, this always reads as 0.
456
+
457
+
### STATUS . entropy_ready
458
+
If 1, the internal PRNG is ready.
459
+
If 0, the internal PRNG is either not configured in EDN mode or software mode, or currently performing a reseed operation via EDN or waiting for software to provide a new seed.
460
+
461
+
If masking is disabled, this bit mirrors the [`CFG_SHADOWED.entropy_ready`](#cfg_shadowed) bit.
462
+
447
463
### STATUS . sha3_squeeze
448
464
If 1, SHA3 completes sponge absorbing stage.
449
465
In this stage, SW can manually run the hashing engine.
0 commit comments