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
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -676,7 +676,7 @@
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
680
'''
681
681
}
682
682
{ bits: "9"
@@ -715,6 +715,17 @@
715
715
In this stage, SW can manually run the hashing engine.
716
716
'''
717
717
}
718
+
{ bits: "4"
719
+
name: "entropy_ready"
720
+
desc: '''If 1, the internal PRNG is ready.
721
+
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.
722
+
'''
723
+
}
724
+
{ bits: "5"
725
+
name: "entropy_reseeding"
726
+
desc: '''If 1, the internal PRNG is currently performing a reseed operation via EDN or waiting for software to provide a new seed.
727
+
'''
728
+
}
718
729
{ bits: "12:8"
719
730
name: "fifo_depth"
720
731
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
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -369,7 +369,7 @@ 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
373
374
374
### CMD . cmd
375
375
Issue a command to the KMAC/SHA3 IP. The command is sparse
| 12:8 | ro | x |[fifo_depth](#status--fifo_depth)|
409
-
| 7:3 ||| Reserved |
409
+
| 7:6 ||| Reserved |
410
+
| 5 | ro | x |[entropy_reseeding](#status--entropy_reseeding)|
411
+
| 4 | ro | x |[entropy_ready](#status--entropy_ready)|
412
+
| 3 ||| Reserved |
410
413
| 2 | ro | x |[sha3_squeeze](#status--sha3_squeeze)|
411
414
| 1 | ro | x |[sha3_absorb](#status--sha3_absorb)|
412
415
| 0 | ro | 0x1 |[sha3_idle](#status--sha3_idle)|
@@ -444,6 +447,13 @@ See the "Message FIFO" section in the spec for the reason.
444
447
### STATUS . fifo_depth
445
448
Count of occupied entries in the message FIFO.
446
449
450
+
### STATUS . entropy_reseeding
451
+
If 1, the internal PRNG is currently performing a reseed operation via EDN or waiting for software to provide a new seed.
452
+
453
+
### STATUS . entropy_ready
454
+
If 1, the internal PRNG is ready.
455
+
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.
456
+
447
457
### STATUS . sha3_squeeze
448
458
If 1, SHA3 completes sponge absorbing stage.
449
459
In this stage, SW can manually run the hashing engine.
0 commit comments