Changes to Hardware Specification

Comparing version 2.1 to 2.0
+1328 additions -242 deletions
@@ -1,12 +1,12 @@
11 <div style="font-size: 0.85em; color: #656d76; margin-bottom: 1em; padding: 0.5em; background: #f6f8fa; border-radius: 4px;">
2-📄 Source: <a href="https://github.com/chipsalliance/caliptra-rtl/blob/35b0bc5691b2bd0fc180403914cfabe207379089/docs/CaliptraHardwareSpecification.md" target="_blank">chipsalliance/caliptra-rtl/docs/CaliptraHardwareSpecification.md</a> @ <code>35b0bc5</code>
2+📄 Source: <a href="https://github.com/chipsalliance/caliptra-rtl/blob/298ad4313ed8b4da25e98e3f1131c89363a6eb92/docs/CaliptraHardwareSpecification.md" target="_blank">chipsalliance/caliptra-rtl/docs/CaliptraHardwareSpecification.md</a> @ <code>298ad43</code>
33 </div>
44
55 ![OCP Logo](../images/caliptra-rtl/docs/images/OCP_logo.png)
66
77 <p style="text-align: center;">Caliptra Hardware Specification</p>
88
9-<p style="text-align: center;">Revision 2.0.3</p>
9+<p style="text-align: center;">Revision 2.2</p>
1010
1111 <div style="page-break-after: always"></div>
1212
@@ -28,10 +28,10 @@
2828 * Caliptra uC may use internally in mailbox mode or via the Caliptra AXI DMA assist engine in streaming mode
2929 * SHA Accelerator adds new SHA save/restore functionality
3030 * Adams Bridge Dilithium/ML-DSA (refer to [Adams bridge spec](https://github.com/chipsalliance/adams-bridge/blob/main/docs/AdamsBridgeHardwareSpecification.md))
31-* Subsystem mode support (refer to [Subsystem Specification](https://github.com/chipsalliance/caliptra-ss/blob/main/docs/Caliptra%202.0%20Subsystem%20Specification%201.pdf) for details)
31+* Subsystem mode support (refer to [Subsystem Specification](https://github.com/chipsalliance/caliptra-ss/blob/main/docs/CaliptraSSIntegrationSpecification.md) for details)
3232 * ECDH hardware support
3333 * HMAC512 hardware support
34- * AXI Manager with DMA support (refer to [DMA Specification](https://github.com/chipsalliance/caliptra-ss/blob/main/docs/CaliptraSSHardwareSpecification.md#caliptra-axi-manager--dma-assist))
34+ * AXI Manager with DMA support (refer to [DMA Specification](https://github.com/chipsalliance/caliptra-ss/blob/main/docs/CaliptraSSHardwareSpecification.md#caliptra-core-axi-manager--dma-assist))
3535 * Manufacturing and Debug Unlock
3636 * UDS programming
3737 * Read logic for Secret Fuses
@@ -39,29 +39,49 @@
3939 * RISC-V core PMP support
4040 * CSR HMAC key for manufacturing flow
4141
42+## Key Caliptra 2.1 Changes
43+* AXI Manager DMA AES feature for OCP L.O.C.K. support (refer to [DMA Specification](https://github.com/chipsalliance/caliptra-ss/blob/main/docs/CaliptraSSHardwareSpecification.md#caliptra-core-axi-manager--dma-assist))
44+* [AES Big Endian mode](#aes-endian)
45+* [External Staging Area](./CaliptraIntegrationSpecification.md#external-staging-area)
46+* [OCP LOCK Support](#ocp-lock-hardware-architecture)
47+* [SHA3](#sha3)
48+* [ML-KEM](#adams-bridge-kyber-ml-kem)
49+
50+## Key Caliptra 2.2 Changes
51+* [Dual-core lockstep (DCLS)](#dual-core-lockstep-dcls)
52+* [Key Vault Boot Flow Transition Enforcement](#key-vault-boot-flow-transition-enforcement)
53+* [ICCM write hash measurement](#iccm-write-hash-measurement-pcr4pcr5)
54+* [Dual iTRNG entropy combiner](#dual-itrng-entropy-combiner)
55+* HMAC area optimization and multi-block interface updates
56+* ECC area optimization
57+* Adams Bridge v3.0 area optimizations and security hardening
58+* Fault injection countermeasures for FSMs and debug controls
59+* CSR HMAC key lock
60+* SoC-side stash-measurement register bank
61+
4262 ## Boot FSM
4363
4464 The Boot FSM detects that the SoC is bringing Caliptra out of reset. Part of this flow involves signaling to the SoC that Caliptra is awake and ready for fuses. After fuses are populated and the SoC indicates that it is done downloading fuses, Caliptra can wake up the rest of the IP by de-asserting the internal reset.
4565
46-The following figure shows the initial power-on arc of the Mailbox Boot FSM.
47-
48-*Figure 1: Mailbox Boot FSM state diagram*
49-
50-![](../images/caliptra-rtl/docs/images/HW_mbox_boot_fsm.png)
66+The following figure shows the state transitions and associated actions in Caliptra's boot state machine.
67+
68+*Figure: Caliptra Boot FSM state diagram*
69+
70+![](../images/caliptra-rtl/docs/images/Caliptra_boot_fsm.png)
5171
5272 The Boot FSM first waits for the SoC to assert cptra\_pwrgood and de-assert cptra\_rst\_b. In the BOOT\_FUSE state, Caliptra signals to the SoC that it is ready for fuses. After the SoC is done writing fuses, it sets the fuse done register and the FSM advances to BOOT\_DONE.
5373
54-BOOT\_DONE enables Caliptra reset de-assertion through a two flip-flop synchronizer.
55-
56-## FW update reset (Impactless FW update)
57-
58-When a firmware update is initiated, Runtime FW writes to fw\_update\_reset register to trigger the FW update reset. When this register is written, only the RISC-V core is reset using cptra\_uc\_fw\_rst\_b pin and all AHB targets are still active. All registers within the targets and ICCM/DCCM memories are intact after the reset. Reset is deasserted synchronously after a programmable number of cycles; the minimum allowed number of wait cycles is 5, which is also the default configured value. Reset de-assertion is done through a two flip-flop synchronizer. Since ICCM is locked during runtime, the boot FSM unlocks it when the RISC-V reset is asserted. Following FW update reset deassertion, normal boot flow updates the ICCM with the new FW from the mailbox SRAM. The boot flow is modified as shown in the following figure.
59-
60-*Figure 2: Mailbox Boot FSM state diagram for FW update reset*
61-
62-![](../images/caliptra-rtl/docs/images/mbox_boot_fsm_FW_update_reset.png)
74+Once in the BOOT\_DONE state, Caliptra de-asserts resets through a two flip-flop synchronizer.
75+
76+### FW update reset (Impactless FW update)
77+
78+When a firmware update is initiated, Runtime FW writes to fw\_update\_reset register to trigger the FW update reset. When this register is written, only the RISC-V core is reset using cptra\_uc\_rst\_b pin and all AHB targets are still active. All registers within the targets and ICCM/DCCM memories are intact after the reset. Reset is deasserted synchronously after a programmable number of cycles; the minimum allowed number of wait cycles is 5, which is also the default configured value. Reset de-assertion is done through a two flip-flop synchronizer. Since ICCM is locked during runtime, the boot FSM unlocks it when the RISC-V reset is asserted. Following FW update reset deassertion, normal boot flow updates the ICCM with the new FW from the mailbox SRAM.
6379
6480 Impactless firmware updates may be initiated by writing to the fw\_update\_reset register after Caliptra comes out of global reset and enters the BOOT\_DONE state. In the BOOT\_FWRST state, only the reset to the RISC-V core is asserted and the wait timer is initialized. After the timer expires, the FSM advances from the BOOT\_WAIT to BOOT\_DONE state where the reset is deasserted and ICCM is unlocked.
81+
82+### Breakpoints for Debug
83+
84+Integrators may connect a breakpoint input to Caliptra, which is intended to connect to a chip GPIO pin. When asserted, this pin causes the Caliptra boot FSM to follow a modified arc. Instead of transitioning immediately to the BOOT_DONE state upon completion of fuse programming, the state machine transitions from BOOT_FUSE to BOOT_WAIT. Here, the state machine halts until the Caliptra register [CPTRA_BOOTFSM_GO](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.soc_ifc_reg.CPTRA_BOOTFSM_GO) is set, either by AXI or TAP access.
6585
6686 ## RISC-V core
6787
@@ -81,6 +101,11 @@
81101 | Fast Interrupt Redirect | Enabled |
82102 | External Interrupts | 31 |
83103 | PMP | Enabled |
104+| Dual-Core Lockstep | Enabled |
105+| RF Read Port Comparison | Enabled |
106+| DCCM Write-Readback | Disabled |
107+| DCCM Address Infection | Disabled |
108+| ICCM Address Infection | Disabled |
84109
85110
86111 ### Embedded memory export
@@ -116,8 +141,9 @@
116141 | Data Vault | 5 | 8 KiB | 0x1001_C000 | 0x1001_DFFF |
117142 | SHA512 | 6 | 32 KiB | 0x1002_0000 | 0x1002_7FFF |
118143 | SHA256 | 10 | 32 KiB | 0x1002_8000 | 0x1002_FFFF |
119-| ML-DSA | 14 | 64 KiB | 0x1003_0000 | 0x1003_FFFF |
144+| ABR (MLDSA/MLKEM) | 14 | 64 KiB | 0x1003_0000 | 0x1003_FFFF |
120145 | AES | 15 | 4 KiB | 0x1001_1000 | 0x1001_1FFF |
146+| SHA3 | 16 | 4 KiB | 0x1004_0000 | 0x1004_0FFF |
121147
122148
123149 #### Peripherals subsystem
@@ -196,12 +222,44 @@
196222 | Mailbox (Notifications) | 20 | 7 |
197223 | SHA512 Accelerator (Errors) | 23 | 8 |
198224 | SHA512 Accelerator (Notifications) | 24 | 7 |
199-| MLDSA (Errors) | 23 | 8 |
200-| MLDSA (Notifications) | 24 | 7 |
225+| ABR (MLDSA/MLKEM) (Errors) | 23 | 8 |
226+| ABR (MLDSA/MLKEM) (Notifications) | 24 | 7 |
201227 | AXI DMA (Errors) | 25 | 8 |
202228 | AXI DMA (Notifications) | 26 | 7 |
203229
204230
231+### Fault tolerance and FI hardening
232+
233+The Caliptra VeeR EL2 configuration provides several fault-injection (FI) hardening features. These are compile-time properties of the delivered core configuration (enabled by defines in the auto-generated [common_defines.sv](../src/riscv_core/veer_el2/rtl/common_defines.sv)), not integrator-tunable options. Dual-core lockstep (DCLS) is enabled through `dcls_en` in both passive and subsystem profiles. The **DCCM write-readback** and **DCCM / ICCM address-XOR integrity** features are **disabled in this release** until the features mature - they are compiled out of the delivered configuration and are documented below for reference. All three are described below.
234+
235+#### Dual-core lockstep (DCLS)
236+
237+The RISC-V core is instantiated in a dual-core lockstep (DCLS) configuration. A redundant *shadow* core is driven with the same input stream as the main core, offset by a fixed number of pipeline stages. The main core's outputs are delayed by the same offset and compared cycle-by-cycle against the shadow core's outputs; any divergence indicates a fault in one of the cores. Tying `dcls_en` low may allow synthesis to remove the shadow core and comparison logic. The shadow core is not architecturally visible and drives no system state; it exists solely for comparison.
238+
239+The `dcls_en` input enables DCLS in both passive and subsystem profiles (`1` = enabled, `0` = disabled), controlling normal mismatch reporting. Integrators may tie it low or high, or drive it from a synchronous SoC register. The sampled enable is reflected read-only to firmware and the SoC in [CPTRA_HW_CONFIG](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.soc_ifc_reg.CPTRA_HW_CONFIG)`.DCLS_en`. The comparison logic fails safe: an invalid multi-bit encoding on the internal disable control is treated as a detected corruption.
240+
241+In scan mode (`scan_mode` = 1), the shadow core's resets are driven directly by the reset inputs so that they are controllable for scan test. The shadow core is then no longer aligned to the main core. Corruption detection is therefore suspended while `scan_mode` is set, and remains suspended until the next Caliptra reset after `scan_mode` is cleared.
242+
243+While detection is enabled, a detected mismatch asserts [CPTRA_HW_ERROR_FATAL](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.soc_ifc_reg.CPTRA_HW_ERROR_FATAL)`.rv_dcls_err` (bit [7]; see [Error register summary](#error-register-summary)) and raises the `cptra_error_fatal` interrupt to the SoC. The status bit and the interrupt clear independently: the bit is RW1C, so Caliptra firmware or the SoC can clear it, but its reset is `cptra_pwrgood`, so it survives a warm Caliptra reset. The interrupt has no clear mechanism by design — clearing the status bit does not deassert it, and it deasserts only on a Caliptra reset.
244+
245+#### DCCM write-readback
246+
247+> **Disabled in this release:** the DCCM write-readback feature is compiled out of the delivered core configuration (`RV_DCCM_WR_READBACK` is not set) and is inactive until the feature matures. The description below applies when the feature is re-enabled in a future release.
248+
249+The DCCM store path is protected by a write-readback check (enabled by `RV_DCCM_WR_READBACK`). After a store commits to the DCCM, the hardware reads the target location back and compares it against the data that was intended to be written; a mismatch indicates the store was corrupted (for example, by a fault injected on the write datapath) and is reported as a fault.
250+
251+When compiled in, the write-readback check is *enabled out of reset*. It can be disabled at runtime through bit [7] of the microarchitectural feature-disable CSR (`MFDC`, `dec_tlu_dccm_wr_readback_disable`), which is internal to the core and accessible only to code running on the RISC-V core. The core does not take an internal trap on the mismatch; the fault is reported solely through the exported error pin described below.
252+
253+A detected mismatch asserts [CPTRA_HW_ERROR_FATAL](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.soc_ifc_reg.CPTRA_HW_ERROR_FATAL)`.dccm_wr_readback_err` (bit [8]; see [Error register summary](#error-register-summary)) and raises the `cptra_error_fatal` interrupt to the SoC. The status bit and the interrupt clear independently: the bit is RW1C, so Caliptra firmware or the SoC can clear it, but its reset is `cptra_pwrgood`, so it survives a warm Caliptra reset. The interrupt has no clear mechanism by design — clearing the status bit does not deassert it, and it deasserts only on a Caliptra reset. The interrupt assertion can be masked by firmware via [internal_hw_error_fatal_mask](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.soc_ifc_reg.internal_hw_error_fatal_mask)`.mask_dccm_wr_readback_err`; masking suppresses only the interrupt output, not the sticky status bit.
254+
255+#### DCCM / ICCM address-XOR integrity
256+
257+> **Disabled in this release:** the DCCM/ICCM address-XOR integrity scheme is compiled out of the delivered core configuration (`RV_DCCM_ADDR_XOR` and `RV_ICCM_ADDR_XOR` are not set) and is inactive until the feature matures. The description below applies when the feature is re-enabled in a future release.
258+
259+The core's tightly-coupled memories are protected by an address-XOR integrity scheme (enabled by `RV_DCCM_ADDR_XOR` and `RV_ICCM_ADDR_XOR`). On a write, the replicated word address is XOR-folded into the stored data bits before the ECC codeword is formed; on a read, the same address is XOR-ed back out before the ECC check. When the read address matches the address used at write time, the original data is recovered and the ECC check passes. If a fault causes an access to resolve to the wrong line (for example, an address-decode glitch), the recovered data is garbled and the existing ECC logic flags it as an uncorrectable error — converting a silent mis-address into a detectable fault. Such errors surface through the standard uncorrectable-ECC reporting path (`CPTRA_HW_ERROR_FATAL.dccm_ecc_unc` for DCCM, `iccm_ecc_unc` for ICCM).
260+
261+> **Backdoor-access note:** while this feature is enabled, any access to DCCM/ICCM that bypasses the core's normal datapath (testbench preload, external loader, debug read/write, memory dump) must apply the address-XOR itself - XOR the data with the replicated word address on write, and de-XOR it on read.
262+
205263 ## Watchdog timer
206264
207265 The primary function of Caliptra Watchdog Timer (WDT) is to reset the microcontroller (Caliptra), in the event of a software malfunction, by resetting the device if it has not been cleared in software. It is a two-stage timer, independent of the RISCV core.
@@ -220,7 +278,7 @@
220278
221279 The following figure shows the two timers.
222280
223-*Figure 3: Caliptra Watchdog Timer*
281+*Figure: Caliptra Watchdog Timer*
224282
225283 ![](../images/caliptra-rtl/docs/images/WDT.png)
226284
@@ -266,11 +324,21 @@
266324
267325 ## Security state
268326
269-Caliptra uses the MSB of the security state input to determine whether or not Caliptra is in debug mode.
270-
271-When Caliptra is in debug mode:
272-
273-* Security state MSB is set to 0.
327+The security state input is a packed value encoded as `{debug_locked[3:0], device_lifecycle[1:0]}`. Caliptra uses the `debug_locked` field to determine whether or not Caliptra is in debug mode.
328+
329+To harden this security-critical decision against fault-injection (glitch) attacks, `debug_locked` is a multi-bit (MuBi4) encoded value rather than a single bit:
330+
331+* `debug_locked` = `4'h6` (MuBi4True) &rarr; debug is **locked** (secure).
332+* `debug_locked` = `4'h9` (MuBi4False) &rarr; debug is **unlocked** (debug mode).
333+
334+The two legal encodings are bitwise complements, so a single- or multi-bit glitch is unlikely to convert one legal value into the other. Caliptra evaluates the field with a fail-secure policy:
335+
336+* The "debug unlocked" decision uses a *strict* test: only the exact `4'h9` encoding unlocks debug. Any other value (including any invalid encoding) leaves debug locked.
337+* The "debug locked" decision uses a *loose* test: `4'h6` and any invalid encoding are all treated as locked.
338+
339+Consequently, any value other than the two legal MuBi4 encodings resolves to debug **locked**. Integrators must drive one of the two legal MuBi4 values on the external `security_state` strap; see the Caliptra Integration Specification for the strap layout.
340+
341+When Caliptra is in debug mode (`debug_locked` = MuBi4False):
274342
275343 * Caliptra JTAG is opened for the microcontroller and HW debug.
276344
@@ -296,12 +364,7 @@
296364
297365 ## Clock gating
298366
299-Caliptra provides a clock gating feature that turns off clocks when the microcontroller is halted. Clock gating is disabled by default, but can be globally enabled via the following register.
300-
301-| Control register | Start address | Description |
302-| :------------------- | :---------------- | :------------------------ |
303-| CPTRA_CLK_GATING_EN | 0x300300bc | Register bit to enable or disable the clock gating feature. |
304-
367+Caliptra provides a clock gating feature that turns off clocks when the microcontroller is halted. Clock gating is disabled by default, but can be globally enabled via the [CPTRA_CLK_GATING_EN](https://chipsalliance.github.io/caliptra-rtl/main/external-regs/?p=caliptra_top_reg.generic_and_fuse_reg.CPTRA_CLK_GATING_EN) register.
305368
306369 When enabled, halting the microcontroller turns off clocks to all of the cryptographic subsystem, the vaults (key vault, PCR vault, and data vault), mailbox SRAM, SoC interface, and peripherals subsystem. The Watchdog timer and SoC registers run on the gated RDC clock. The RV core implements its own clock gating mechanism. Halting the core automatically turns off its clock.
307370
@@ -358,7 +421,7 @@
358421
359422 The following figure shows the timing information for clock gating.
360423
361-*Figure 10: Clock gating timing*
424+*Figure: Clock gating timing*
362425
363426 ![](../images/caliptra-rtl/docs/images/clock_gating_timing.png)
364427
@@ -372,19 +435,19 @@
372435
373436 The following figure shows the integrated TRNG block.
374437
375-*Figure 11: Integrated TRNG block*
438+*Figure: Integrated TRNG block*
376439
377440 ![](../images/caliptra-rtl/docs/images/integrated_TRNG.png)
378441
379442 The following figure shows the CSRNG block.
380443
381-*Figure 12: CSRNG block*
444+*Figure: CSRNG block*
382445
383446 ![](../images/caliptra-rtl/docs/images/CSRNG_block.png)
384447
385448 The following figure shows the entropy source block.
386449
387-*Figure 13: Entropy source block*
450+*Figure: Entropy source block*
388451
389452 ![](../images/caliptra-rtl/docs/images/entropy_source_block.png)
390453
@@ -444,13 +507,16 @@
444507
445508 | Name | Input or output | Description |
446509 | :---------- | :-------------- | :------------ |
447-| itrng_data | input | Physical true random noise source data |
448-| itrng_valid | input | Valid is asserted high for one cycle when data is valid. The expected valid output rate is about 50KHz. |
510+| itrng0_data | input | Primary physical true random noise source (ES0) data. |
511+| itrng0_valid | input | Primary source valid, asserted high for one cycle when data is valid. The expected valid output rate is about 50KHz. |
512+| itrng1_data | input | Secondary physical true random noise source (ES1) data, used only when the dual iTRNG entropy combiner is enabled; tie to 0 if unused. |
513+| itrng1_valid | input | Secondary source valid, asserted high for one cycle when data is valid. Used only in dual-iTRNG mode; tie to 0 if unused. |
514+| itrng1_en | input | Dual iTRNG enable strap: enables the secondary entropy source (ES1) and the SHA3-384 entropy combiner. Tie to 0 for a single iTRNG. See [Dual iTRNG entropy combiner](#dual-itrng-entropy-combiner). |
449515
450516
451517 The following figure shows the top level signals defined in caliptra\_top.
452518
453-*Figure 14: caliptra\_top signals*
519+*Figure: caliptra\_top signals*
454520
455521 ![](../images/caliptra-rtl/docs/images/caliptra_top_signals.png)
456522
@@ -459,22 +525,50 @@
459525 The following table provides descriptions of the entropy source signals.
460526
461527 | Name | Input or output | Description |
462-| :------------------ | :-------------- | :--------------- |
528+| :------------------------------ | :-------------- | :--------------------------------------------------------------------------------------------------------------------------------- |
463529 | clk_i | input | All signal timings are related to the rising edge of clk. |
464530 | rst_ni | input | The reset signal is active LOW and resets the core. |
465-| entropy_src_rng_req | output | Request from the entropy_src module to the physical true random noise source to start generating data. |
466-| entropy_src_rng_rsp | input | Contains the internal TRNG data and a flag indicating the data is valid. Valid is asserted high for one cycle when data is valid. |
531+| debugUnlock_or_scan_mode_switch | input | Zeroizes entropy\_src on debug lock/unlock, scan mode and lifecycle change. See [Entropy source zeroize](#entropy-source-zeroize). |
532+| entropy_src_rng_enable_o | output | Request from the entropy_src module to the physical true random noise source to start generating data. |
533+| entropy_src_rng_valid_i | input | Flag indicating the TRNG data is valid. Valid is asserted high for one cycle when data is valid. |
534+| entropy_src_rng_bits_i | input | The internal TRNG data. Sampled when entropy_src_rng_valid_i is asserted high. |
467535 | entropy_src_hw_if_i | input | Downstream block request for entropy bits. |
468536 | entropy_src_hw_if_o | output | 384 bits of entropy data. Valid when es_ack is asserted high. |
469-| cs_aes_halt_i | input | Response from csrng that all requests to AES block are halted. |
470-| cs_aes_halt_o | output | Request to csrng to halt requests to the AES block for power leveling purposes. |
471-
537+
538+
539+While `entropy_src_rng_enable_o` is asserted, entropy\_src accepts every `entropy_src_rng_bits_i` value marked by an asserted `entropy_src_rng_valid_i`; the noise source cannot be back-pressured.
540+The maximum supported rate is one `entropy_src_rng_bits_i` value (i.e. one sample) every two clock cycles.
472541
473542 The following figure shows the entropy source signals.
474543
475-*Figure 15: Entropy source signals*
544+*Figure: Entropy source signals*
476545
477546 ![](../images/caliptra-rtl/docs/images/entropy_source_signals.png)
547+
548+### Entropy source zeroize
549+
550+Writing 1 to `ENTROPY_SRC_CTRL.ZEROIZE` zeroizes entropy\_src and aborts any operation in progress, in any state.
551+entropy\_src is also zeroized on debug lock/unlock, scan mode and lifecycle change (`debugUnlock_or_scan_mode_switch`).
552+While a Caliptra fatal error is asserted, entropy\_src is held in zeroize.
553+
554+Zeroize clears:
555+- all FIFOs, including their storage: the raw entropy FIFOs, the observe FIFO and the esfinal FIFO that holds the conditioned seeds
556+- the main and ack state machines, which return to idle
557+- the health test state, the health test watermark and the alert counters
558+- the SHA3 conditioner (see the Zeroize section of [SHA3](#sha3))
559+
560+All state is cleared synchronously at the end of the zeroize cycle, except for the data of the packer FIFOs, which is cleared one cycle later and is never output in between.
561+In the zeroize cycle, no seed is acknowledged on the hardware interface, and `ENTROPY_DATA` and `FW_OV_RD_DATA` read 0.
562+Zeroize has precedence over the Error state of the state machines. They only return to the Error state if the local escalation is still asserted.
563+
564+Zeroize does not clear:
565+- the configuration registers
566+- the interrupt and alert status
567+- the enable of the noise source: the noise source keeps running. The sample received in the zeroize cycle is dropped.
568+
569+If entropy\_src is enabled, it restarts on its own after the zeroize: it runs the boot or startup health tests again and then delivers new seeds.
570+No seed is delivered from the state before the zeroize, so firmware does not need to disable and re-enable entropy\_src.
571+A pending request from CSRNG stays asserted and is served with a seed produced after the zeroize.
478572
479573 ### CSRNG signal descriptions
480574
@@ -488,11 +582,10 @@
488582 | lc_hw_debug_en_i | input | Lifecycle that selects which diversification value is used for xoring with the seed from entropy_src. |
489583 | entropy_src_hw_if_i | input | 384 bits of entropy data. Valid when es_ack is asserted high. |
490584 | entropy_src_hw_if_o | output | Downstream block request for entropy bits. |
491-| cs_aes_halt_i | input | Request from entropy_src to halt requests to the AES block for power leveling purposes. |
492-| cs_aes_halt_o | output | Response to entropy_src that all requests to AES block are halted. |
493-
494-
495-The CSRNG may only be enabled if entropy\_src is enabled. After it is disabled, CSRNG may only be re-enabled after entropy\_src has been disabled and re-enabled.
585+
586+
587+The recommended enable sequence is to first enable entropy\_src and then CSRNG.
588+entropy\_src can be disabled and re-enabled while CSRNG remains enabled; pending seed requests from CSRNG are served once entropy\_src is re-enabled.
496589
497590 ### FIPS considerations
498591
@@ -503,100 +596,272 @@
503596 publication SP 800-90B.
504597
505598 The TRNG must be re-initialized whenever self-test parameter changes are
506-needed. As described in the previous section, the initialization steps
507-are as follows:
508-
509-1. Disable `csrng` and `entropy_src` in that order.
599+needed. The initialization steps are as follows:
600+
601+1. Disable `entropy_src`. `csrng` can remain enabled.
510602 2. Apply new self-test configuration.
511-3. Enable `entropy_src` and `csrng` in that order.
603+3. Enable `entropy_src`.
512604
513605 ### Adaptive self-test window and thresholds
514606
515-This section details the configuration of the `entropy_src`, focusing on how
516-the test window size for the adaptive self-test is determined and how it
517-relates to threshold calculations.
518-
519-#### Understanding Test Window Sizes
520-
521-The adaptive self-test within the `entropy_src` block utilizes a
522-configurable test window. To clarify its interpretation, two terms are
523-defined:
524-
525-* `ENTROPY_TEST_WINDOW`: This refers to the test window size directly
526- configured in the hardware registers of the `entropy_src` block.
527-* `ACTUAL_TEST_WINDOW`: This refers to the effective window size used for
528- the adaptive self-test threshold calculations. Its value depends on how
529- the test scores are aggregated.
530-
531-The aggregation method is determined by the CONF.THRESHOLD_SCOPE setting in
532-the entropy_src block.
533-
534-#### Aggregate per symbol
535-
536-When CONF.THRESHOLD_SCOPE is enabled:
537-
538-* The adaptive test combines the inputs from all physical entropy lines
539- into a single, cumulative score.
540-* The test essentially treats the combined input as a single binary stream,
541- counting the occurrences of '1's.
542-* In this configuration:
543- * If `ENTROPY_TEST_WINDOW` is set to 1024, then
544- * `ACTUAL_TEST_WINDOW` = `ENTROPY_TEST_WINDOW` = 1024
545-
546-#### Handle each physical noise source separately
547-
548-When `CONF.THRESHOLD_SCOPE` is disabled:
549-
550-* The adaptive test scores each individual physical noise input line
551- independently.
552-* This allows for monitoring the health of each noise source.
553-* In this configuration (assuming, for example, 4 noise sources):
554- * If `ENTROPY_TEST_WINDOW` is set to 4096 bits, then
555- * `ACTUAL_TEST_WINDOW` = (`ENTROPY_TEST_WINDOW` / 4) = 1024
607+This section details the configuration of the `entropy_src` health test
608+windows and of the adaptive self-test thresholds.
609+
610+#### Test windows
611+
612+The size of a sample is determined by `CONF.RNG_BIT_ENABLE`:
613+
614+* In multi-channel mode (`CONF.RNG_BIT_ENABLE` disabled), a sample consists of
615+ one bit from each of the 4 noise source lines.
616+* In single-channel mode (`CONF.RNG_BIT_ENABLE` enabled), a sample is one bit
617+ of the line selected by `CONF.RNG_BIT_SEL`.
618+
619+The window size, in samples, depends on the operating mode:
620+
621+* FIPS mode (`CONF.FIPS_ENABLE` enabled): the window size is configured in
622+ `HEALTH_TEST_WINDOWS.FIPS_WINDOW`, in samples.
623+* Boot-time / bypass mode (`CONF.FIPS_ENABLE` disabled): the window is
624+ configured in `HEALTH_TEST_WINDOWS.BYPASS_WINDOW`, in bits over all tested
625+ lines, so the window size is `BYPASS_WINDOW` / 4 samples in multi-channel
626+ mode and `BYPASS_WINDOW` samples in single-channel mode. Only the default
627+ value of 384 bits is supported: without the conditioner, each window of
628+ tested bits is output directly as one 384-bit seed (the CSRNG seed width).
629+
630+In both modes, each tested noise source line contributes one bit per sample,
631+i.e. window size bits per window.
632+
633+#### Threshold scope
634+
635+Some health tests are executed on each noise source line individually. For
636+example, the Adaptive Proportion test counts the number of '1's of each line
637+over the window. In multi-channel mode (`CONF.RNG_BIT_ENABLE` disabled),
638+`CONF.THRESHOLD_SCOPE` selects the scope in which the results of these tests
639+are compared against the thresholds and health test failures are counted:
640+
641+* `CONF.THRESHOLD_SCOPE` disabled: the count of each line is compared against
642+ the thresholds individually. This allows detecting the failure of a single
643+ noise source line.
644+* `CONF.THRESHOLD_SCOPE` enabled: the counts of all lines are summed up and the
645+ sum is compared against the thresholds. This setting should not be used in
646+ Caliptra.
647+
648+In single-channel mode (`CONF.RNG_BIT_ENABLE` enabled), `CONF.THRESHOLD_SCOPE` has no effect.
556649
557650 #### Configuring adaptive self-test thresholds
558651
559-Once the `ACTUAL_TEST_WINDOW` is determined, the adaptive self-test
560-thresholds can be configured as follows:
561-
562-* `ADAPTP_HI_THRESHOLDS.FIPS_THRESH` = `adaptp_cutoff`
563-* `ADAPTP_LO_THRESHOLDS.FIPS_THRESH` = `ACTUAL_TEST_WINDOW` - `adaptp_cutoff`
564-
565-Here, `adaptp_cutoff` represents the pre-determined cutoff value for the
566-adaptive proportion test, as defined by NIST SP 800-90B. See the threshold
567-calculations below as an example.
652+`entropy_src` provides two variants of the NIST SP 800-90B Adaptive Proportion
653+test (Section 4.4.2), which declares an error if the count reaches the cutoff
654+value \\(C = 1 + critbinom(W, 2^{-H}, 1 - α)\\), where \\(W\\) is the window size and
655+\\(H\\) the min-entropy per sample:
656+
657+* The Adaptive Proportion test (`ADAPTP_HI_THRESHOLD`, `ADAPTP_LO_THRESHOLD`)
658+ treats the noise source lines as binary sources and counts the number of
659+ '1's. It is used when the lines are modeled as binary noise sources.
660+* The Adaptive Proportion Symbol test (`ADAPTPS_THRESHOLD`) treats the 4 lines
661+ together as a non-binary source producing 4-bit symbols. It counts how often
662+ the first symbol of the window occurs within the window.
663+
664+##### Adaptive Proportion test
665+
666+The thresholds depend on the number of bits `N` over which the compared count
667+is taken:
668+
669+| Mode | `CONF.THRESHOLD_SCOPE` disabled | `CONF.THRESHOLD_SCOPE` enabled |
670+| :------------- | :------------------------------ | :----------------------------- |
671+| Multi-channel | `N` = window size | `N` = 4 * window size |
672+| Single-channel | `N` = window size | `N` = window size |
673+
674+
675+`CONF.THRESHOLD_SCOPE` enabled is listed for completeness only and should not
676+be used in Caliptra.
677+
678+The test fails if the count of '1's is greater than or equal to
679+`ADAPTP_HI_THRESHOLD` or less than or equal to `ADAPTP_LO_THRESHOLD`, i.e. if
680+either the '1's or the '0's reach the cutoff value \\(C\\). An
681+`ADAPTP_LO_THRESHOLD` of 0 (reset value) disables the low check. The
682+thresholds can then be configured as follows:
683+
684+* `ADAPTP_HI_THRESHOLD` = \\(C\\)
685+* `ADAPTP_LO_THRESHOLD` = `N` - \\(C\\)
686+
687+with \\(W\\) = `N` and \\(H\\) the min-entropy per bit. See the threshold calculations
688+below as an example.
568689
569690 \\(α = 2^{-40}\\) (recommended)\
570691 \\(H = 0.5\\) (example, estimated entropy measured from hardware)\
571-\\(W\\) = `ACTUAL_TEST_WINDOW`\
572-`adaptp_cutoff` = \\(1 + critbinom(W, 2^{-H}, 1 - α)\\)
692+\\(W\\) = `N`\
693+\\(C = 1 + critbinom(W, 2^{-H}, 1 - α)\\)
694+
695+##### Adaptive Proportion Symbol test
696+
697+The Adaptive Proportion Symbol test is used in multi-channel mode, where each
698+sample is a 4-bit symbol. The test fails if the count of the first symbol
699+reaches `ADAPTPS_THRESHOLD`, so the threshold can be configured as follows:
700+
701+* `ADAPTPS_THRESHOLD` = \\(C\\)
702+
703+with \\(W\\) = window size and \\(H\\) the min-entropy per 4-bit symbol.
704+
705+The same threshold registers are used in FIPS mode and in bypass mode.
706+Since the counts are accumulated over the window, the cutoff \\(C\\) depends on
707+the window size, so thresholds calculated for the FIPS window are wrong for the
708+much smaller bypass window and vice versa. The thresholds therefore have to be set for the window of the
709+mode that is used, and reprogrammed (while `entropy_src` is disabled) when
710+switching between bypass and FIPS mode.
573711
574712 > Note: The `critbinom` function (critical binomial distribution function) is
575713 > implemented by most spreadsheet applications.
576714
577715 ### Recommended configuration
578716
579-The following configuration is recommended for the adaptive and repetition
580-count tests:
581-
582-#### Adaptive test
583-
584-1. Set `CONF.THRESHOLD_SCOPE` to disabled. This allows the test to monitor
585- and score each physical noise source individually, providing more granular
586- health information.
587-2. Set `HEALTH_TEST_WINDOWS.FIPS_WINDOW` to 4096 bits. This value serves
588- as the `ENTROPY_TEST_WINDOW`. With the current 4 noise source configuration,
589- this is equivalent to 1024 bits per noise source, where each source produces
590- 1 bit of entropy as defined in NIST SP 800-90B.
591-3. Calculate thresholds. Use an `ACTUAL_TEST_WINDOW` of 1024 bits (derived
592- from step 2) in the adaptive test threshold formulas provided earlier in
593- this subsection.
717+The configuration of the health tests depends on how the 4 noise source lines
718+can be modeled in the sense of NIST SP 800-90B. For the window size in the
719+different operating modes, see [Test windows](#test-windows).
720+
721+#### Four independent binary noise sources
722+
723+If the 4 lines come from independent noise sources, each line can be health
724+tested as a separate binary noise source:
725+
726+1. Set `CONF.THRESHOLD_SCOPE` to disabled, so that the Adaptive Proportion
727+ test evaluates each line individually. The Repetition Count test always
728+ evaluates each line individually.
729+2. Set the window size to the window size defined by NIST SP 800-90B
730+ for binary noise sources. Each line is then tested over window size bits.
731+3. Calculate the `ADAPTP_HI_THRESHOLD`, `ADAPTP_LO_THRESHOLD` and
732+ `REPCNT_THRESHOLD` cutoffs with `N` = window size.
733+
734+`entropy_src` only supports one set of cutoff values, shared by all 4 lines.
735+This configuration therefore requires a justification that:
736+
737+* the 4 lines can legitimately be treated as independent noise sources, and
738+* the common cutoff values are appropriate for every line, i.e. they are
739+ derived from an entropy estimate that holds for each of the 4 lines.
740+
741+If this cannot be justified, this configuration must not be used. Use one of
742+the following configurations instead.
743+
744+#### Single-lane mode
745+
746+Health test and condition a single binary line:
747+
748+1. Set `CONF.RNG_BIT_ENABLE` to enabled and select the line with
749+ `CONF.RNG_BIT_SEL`. `CONF.THRESHOLD_SCOPE` has no effect in this mode.
750+2. Set the window size to the window size defined by NIST SP 800-90B
751+ for binary noise sources. The selected line is then tested over window
752+ size bits.
753+3. Calculate the `ADAPTP_HI_THRESHOLD`, `ADAPTP_LO_THRESHOLD` and
754+ `REPCNT_THRESHOLD` cutoffs for the selected line with `N` = window size.
755+
756+#### 4-bit symbol mode
757+
758+Treat the 4 lines together as a single noise source producing 4-bit symbols:
759+
760+1. Keep `CONF.RNG_BIT_ENABLE` disabled (multi-channel mode).
761+2. Set the window size to the window size defined by NIST SP 800-90B
762+ for non-binary noise sources. Each sample is a 4-bit symbol.
763+3. Use the symbol-based tests: calculate the `ADAPTPS_THRESHOLD` (see
764+ [Adaptive Proportion Symbol test](#adaptive-proportion-symbol-test)) with
765+ `W` = window size and the `REPCNTS_THRESHOLD` (Repetition Count Symbol
766+ test), both with the min-entropy `H` per 4-bit symbol.
594767
595768 #### Repetition count test
596769
597770 The methodology used for calculating the repetition count threshold in the
598-ROM boot phase can be directly applied for this test as well. The threshold is
599-applied on a per-noise-source basis.
771+ROM boot phase can be directly applied in all three configurations, using
772+the min-entropy per bit (independent sources, single-lane mode) or per 4-bit
773+symbol (4-bit symbol mode).
774+
775+
776+## Dual iTRNG entropy combiner
777+
778+Some integrations require a **second physical noise source** — for example, a
779+secondary noise-generation technology deployed alongside the primary one. To
780+support this, Caliptra can instantiate a **second `entropy_src` (ES1)** next to
781+the primary source (`ES0`) while still feeding a **single CSRNG**. A dedicated
782+**SHA3-384 entropy combiner** sits between the two entropy sources and the CSRNG
783+and merges their conditioned outputs. This feature is only available when the
784+integrated TRNG is instantiated (`CALIPTRA_INTERNAL_TRNG`) and, per the interface
785+rules, is only enabled in Subsystem mode.
786+The following figure shows the dual iTRNG entropy combiner block.
787+
788+*Figure: Dual iTRNG entropy combiner block*
789+
790+![](../images/caliptra-rtl/docs/images/dual_entropy.png)
791+
792+The combiner presents a single `entropy_src_hw_if` interface to CSRNG
793+and drives one such interface to each of ES0 and ES1. It operates in one of two
794+modes, selected by `CPTRA_HW_CONFIG.dual_iTRNG_en`:
795+
796+* **Bypass mode (`dual_iTRNG_en == 0`, default):** the combiner is transparent.
797+ A CSRNG entropy request is forwarded to ES0 and ES0's response is returned
798+ unchanged; ES1 is never requested. This is functionally identical to the
799+ single-iTRNG datapath, so the default behavior of existing integrations is
800+ unchanged.
801+* **Combine mode (`dual_iTRNG_en == 1`):** one CSRNG request is fanned out to
802+ both ES0 and ES1. The combiner waits until both 384-bit conditioned seeds are
803+ captured, concatenates them as `ES0 || ES1` (768 bits — one SHA3-384 block,
804+ because 768 < the 832-bit SHA3-384 rate), hashes them through the shared
805+ `ot_sha3` gates, and returns the single 384-bit digest to CSRNG with one
806+ acknowledge. The FIPS status returned to CSRNG follows a configurable policy
807+ (AND of both sources by default, ES0-only, or a firmware-programmed value).
808+
809+### Enabling the feature
810+
811+Combine mode is enabled by `CPTRA_HW_CONFIG.dual_iTRNG_en`, a software-readable
812+bit that hardware drives from a dedicated `itrng1_en` integration input. The bit
813+resolves to 1 only in Subsystem mode with the internal TRNG present; in any other
814+configuration it reads 0 and the combiner stays in bypass. The same `itrng1_en`
815+input also gates the secondary physical-source pins (`itrng1_data` /
816+`itrng1_valid`). Each entropy source has its own external request output
817+(`etrng0_req` for ES0, `etrng1_req` for ES1).
818+
819+### Power-on known-answer test (KAT) and AHB lock
820+
821+Because FIPS certification requires a power-on KAT of every cryptographic block,
822+the combiner exposes an AHB-lite register interface used **only** by ROM. ROM
823+runs a self-contained KAT by writing a fixed message into `KAT_MSG`, programming
824+`KAT_MSG_LEN`, and pulsing `KAT_CTRL.start`; the combiner hashes that bounded
825+single-block message through the same `ot_sha3` datapath used operationally and
826+exposes the result in `KAT_DIGEST`. After the KAT, ROM sets the write-once
827+multi-bit (MuBi4) `AHB_LOCK`. Once locked, the KAT registers are zeroized and
828+read back as 0, and the FIPS combine policy is frozen, so runtime firmware cannot
829+observe KAT state or weaken the combination. Entropy never appears in any
830+AHB-readable register — the ES0/ES1 → combiner → CSRNG path is internal only.
831+
832+### Zeroize
833+
834+Writing 1 to `COMBINER_CTRL.zeroize` zeroizes the combiner in the following
835+cycle and aborts any combine or KAT operation in progress. The field is a
836+single-cycle pulse and reads back as 0.
837+
838+The combiner is also zeroized on debug lock/unlock, scan mode and lifecycle
839+change.
840+
841+Zeroize clears:
842+- the captured ES0/ES1 seeds and the combined digest
843+- the KAT message, length and digest, including the `KAT_MSG` and `KAT_MSG_LEN` registers
844+- the combiner FSM and the `ot_sha3` core
845+
846+Zeroize does not clear the configuration (`COMBINER_CTRL.es_fips_policy`,
847+`es_fips_cfg`, `AHB_LOCK`) or the interrupt status registers.
848+
849+`zeroize` remains writable after `AHB_LOCK` is set.
850+
851+Outstanding ES0/ES1 requests stay asserted until they are acknowledged, and
852+seeds that were already captured are discarded and requested again. A CSRNG
853+request that was not yet acknowledged is completed with a digest of fresh seeds
854+from ES0 and ES1. A CSRNG request that was already acknowledged still waits for
855+`es_req` to be deasserted.
856+
857+### Fault handling
858+
859+The combiner is fault-hardened consistently with the surrounding OpenTitan
860+blocks: `AHB_LOCK` uses a MuBi4 encoding that is fail-safe to *locked*, and the
861+datapath sequencer uses a sparse Hamming-distance-3 (HD-3) FSM encoding. A
862+single-bit glitch that produces an undefined FSM code is trapped to a terminal
863+error state and latched into the combiner's error-interrupt status (alongside the
864+`ot_sha3` countermeasure errors).
600865
601866
602867 ## External-TRNG REQ HW API
@@ -619,6 +884,7 @@
619884 * A user of the HW API first locks the accelerator by reading the LOCK register. A read that returns the value 0 indicates that the resource was locked for exclusive use by the requesting user. A write of ‘1 clears the lock.
620885 * The USER register captures the AXI USERID value of the requestor that locked the SHA accelerator. This is the only user that is allowed to control the SHA accelerator by performing AXI register writes. Writes by any other agent on the AXI subordinate interface are dropped.
621886 * SHA supports **Mailbox** mode: SHA is computed on LENGTH (DLEN) bytes of data stored in the mailbox beginning at START\_ADDRESS. This computation is performed when the EXECUTE register is set by the user. When the operation is completed and the result in the DIGEST register is valid, SHA accelerator sets the VALID bit of the STATUS register.
887+* Mailbox-mode requests with START\_ADDRESS + DLEN greater than the mailbox capacity are rejected before any mailbox reads or hashing. Exact-fit requests are accepted. A rejected request leaves STATUS.VALID clear, clears EXECUTE, and sets the sticky ERROR1\_STS bit in the SHA accelerator's ERROR\_INTERNAL\_INTR\_R register. The corresponding error interrupt is asserted if enabled. Software may clear this write-one-to-clear status bit, correct the range, and retry under the same lock without resetting the accelerator. This range check does not apply to streaming or ICCM hashing.
622888 * Note that even though the mailbox size is fixed, due to SHA save/restore function enhancement, there is no limit on the size of the block that needs to be SHAd. SOC needs to follow FW API
623889 * The SHA computation engine in the SHA accelerator requires big endian data, but the SHA accelerator can accommodate mailbox input data in either the little endian or big endian format. By default, input data is assumed to be little endian and is swizzled to big endian at the byte level prior to computation. For the big endian format, data is loaded into the SHA engine as-is. Users may configure the SHA accelerator to treat data as big endian by setting the ENDIAN\_TOGGLE bit appropriately.
624890 * See the register definition for the encodings.
@@ -634,7 +900,54 @@
634900
635901 Note: If the debug security state switches to debug mode anytime, the security assets and keys are still flushed even though JTAG is not open.
636902
637-*Figure 16: JTAG implementation*
903+The following table details the alias addresses for registers in soc ifc that are accessible through JTAG.
904+Debug Locked registers are a subset of registers accessible when debug intent is set, when debug is unlocked, or the lifecycle state is DEVICE_MANUFACTURING.
905+Debug Unlocked registers are accessible when debug is unlocked, or the lifecycle state is DEVICE_MANUFACTURING.
906+
907+| Register Name | JTAG Address | Accessibility | Debug Locked | Debug Unlocked |
908+| ------------------------------------------- | -------------- | --------------- | -------------- | ---------------- |
909+| mbox_lock | 7’h75 | RO | YES | YES |
910+| mbox_cmd | 7’h76 | RW | YES | YES |
911+| mbox_dlen | 7’h50 | RW | YES | YES |
912+| mbox_dataout | 7’h51 | RO | YES | YES |
913+| mbox_datain | 7’h62 | WO | YES | YES |
914+| mbox_status | 7’h52 | RW | YES | YES |
915+| mbox_execute | 7’h77 | WO | YES | YES |
916+| CPTRA_BOOT_STATUS | 7’h53 | RO | YES | YES |
917+| CPTRA_HW_ERRROR_ENC | 7’h54 | RO | YES | YES |
918+| CPTRA_FW_ERROR_ENC | 7’h55 | RO | YES | YES |
919+| SS_UDS_SEED_BASE_ADDR_L | 7’h56 | RO || YES |
920+| SS_UDS_SEED_BASE_ADDR_H | 7’h57 | RO || YES |
921+| CPTRA_HW_ERROR_FATAL | 7’h58 | RO | YES | YES |
922+| CPTRA_FW_ERROR_FATAL | 7’h59 | RO | YES | YES |
923+| CPTRA_HW_ERROR_NON_FATAL | 7’h5a | RO | YES | YES |
924+| CPTRA_FW_ERROR_NON_FATAL | 7’h5b | RO | YES | YES |
925+| CPTRA_DBG_MANUF_SERVICE_REG | 7’h60 | RW | YES | YES |
926+| CPTRA_BOOTFSM_GO | 7’h61 | RW | YES | YES |
927+| SS_DEBUG_INTENT | 7’h63 | RW || YES |
928+| SS_CALIPTRA_BASE_ADDR_L | 7’h64 | RW || YES |
929+| SS_CALIPTRA_BASE_ADDR_H | 7’h65 | RW || YES |
930+| SS_MCI_BASE_ADDR_L | 7’h66 | RW || YES |
931+| SS_MCI_BASE_ADDR_H | 7’h67 | RW || YES |
932+| SS_RECOVERY_IFC_BASE_ADDR_L | 7’h68 | RW || YES |
933+| SS_RECOVERY_IFC_BASE_ADDR_H | 7’h69 | RW || YES |
934+| SS_OTP_FC_BASE_ADDR_L | 7’h6A | RW || YES |
935+| SS_OTP_FC_BASE_ADDR_H | 7’h6B | RW || YES |
936+| SS_STRAP_GENERIC_0 | 7’h6C | RW || YES |
937+| SS_STRAP_GENERIC_1 | 7’h6D | RW || YES |
938+| SS_STRAP_GENERIC_2 | 7’h6E | RW || YES |
939+| SS_STRAP_GENERIC_3 | 7’h6F | RW || YES |
940+| SS_DBG_SERVICE_REG_REQ | 7’h70 | RW | YES | YES |
941+| SS_DBG_SERVICE_REG_RSP | 7’h71 | RO | YES | YES |
942+| SS_DBG_UNLOCK_LEVEL0 | 7’h72 | RW || YES |
943+| SS_DBG_UNLOCK_LEVEL1 | 7’h73 | RW || YES |
944+| SS_STRAP_CALIPTRA_DMA_AXI_USER | 7’h74 | RW || YES |
945+| SS_EXTERNAL_STAGING_AREA_BASE_ADDR_L | 7’h78 | RW || YES |
946+| SS_EXTERNAL_STAGING_AREA_BASE_ADDR_H | 7’h79 | RW || YES |
947+
948+
949+
950+*Figure: JTAG implementation*
638951
639952 ![](../images/caliptra-rtl/docs/images/JTAG_implementation.png)
640953
@@ -644,18 +957,19 @@
644957
645958 * Symmetric cryptographic primitives
646959 * De-obfuscation engine
647- * SHA512/384 (based on NIST FIPS 180-4 [2])
648- * SHA256 (based on NIST FIPS 180-4 [2])
649- * HMAC512 (based on [NIST FIPS 198-1](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.198-1.pdf) [5] and [RFC 4868](https://tools.ietf.org/html/rfc4868) [6])
960+ * SHA512/384 (based on NIST FIPS 180-4 [2])
961+ * SHA256 (based on NIST FIPS 180-4 [2])
962+ * HMAC512 (based on [NIST FIPS 198-1](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.198-1.pdf) [5] and [RFC 4868](https://tools.ietf.org/html/rfc4868) [6])
963+ * SHA3 (based on [NIST FIPS 202](https://doi.org/10.6028/NIST.FIPS.202) [17])
650964 * Public-key cryptography
651- * NIST Secp384r1 Deterministic Digital Signature Algorithm (based on FIPS-186-4 [11] and RFC 6979 [7])
965+ * NIST Secp384r1 Deterministic Digital Signature Algorithm (based on FIPS-186-4 [11] and RFC 6979 [7])
652966 * Key vault
653- * Key slots
654- * Key slot management
967+ * Key slots
968+ * Key slot management
655969
656970 The high-level architecture of Caliptra cryptographic subsystem is shown in the following figure.
657971
658-*Figure 17: Caliptra cryptographic subsystem*
972+*Figure: Caliptra cryptographic subsystem*
659973
660974 ![](../images/caliptra-rtl/docs/images/Crypto-2p0.png)
661975
@@ -680,7 +994,7 @@
680994
681995 The total size should be equal to 128 bits short of a multiple of 1024 since the goal is to have the formatted message size as a multiple of 1024 bits (N x 1024). The following figure shows the SHA512 input formatting.
682996
683-*Figure 18: SHA512 input formatting*
997+*Figure: SHA512 input formatting*
684998
685999 ![](../images/caliptra-rtl/docs/images/SHA512_input.png)
6861000
@@ -692,7 +1006,7 @@
6921006
6931007 The SHA512 architecture has the finite-state machine as shown in the following figure.
6941008
695-*Figure 19: SHA512 FSM*
1009+*Figure: SHA512 FSM*
6961010
6971011 ![](../images/caliptra-rtl/docs/images/SHA512_fsm.png)
6981012
@@ -716,15 +1030,19 @@
7161030
7171031 ### Address map
7181032
719-The SHA512 address map is shown here: [sha512\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.sha512_reg)
1033+The SHA512 address map is shown here: [sha512\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.sha512_reg)
7201034
7211035 ### Pseudocode
7221036
7231037 The following pseudocode demonstrates how the SHA512 interface can be implemented.
7241038
725-*Figure 20: SHA512 pseudocode*
1039+*Figure: SHA512 pseudocode*
7261040
7271041 ![](../images/caliptra-rtl/docs/images/SHA512_pseudo.png)
1042+
1043+### Command sequencing
1044+
1045+Only one hash operation, started by an “init” command, a “next” command (with or without “restore”), or a PCR hash generation start, is accepted between zeroize commands. FW must send a zeroize after each hash operation completes (and after reading the digest) before starting a new one; the first operation after reset does not require a prior zeroize. A zeroize also clears the PCR hash used for PCR signing, so after a PCR hash generation, FW must complete all PCR signing operations that use it before sending the zeroize (see [PCR signing](#pcr-signing)). An “init” sent without an intervening zeroize is ignored: the digest registers are cleared, and the VALID status bit stays low and “next” and “restore” commands are ignored until the next zeroize. The PCR hash generation VALID status bit is cleared by a zeroize and by every PCR hash generation start command written while the engine is ready, including one that is ignored because no zeroize preceded it. FW must poll READY before sending each command; commands other than zeroize are ignored while the engine is not ready.
7281046
7291047 ### SCA countermeasure
7301048
@@ -803,7 +1121,7 @@
8031121
8041122 The following figure shows SHA256 input formatting.
8051123
806-*Figure 21: SHA256 input formatting*
1124+*Figure: SHA256 input formatting*
8071125
8081126 ![](../images/caliptra-rtl/docs/images/SHA256_input.png)
8091127
@@ -815,7 +1133,7 @@
8151133
8161134 The SHA256 architecture has the finite-state machine as shown in the following figure.
8171135
818-*Figure 22: SHA256 FSM*
1136+*Figure: SHA256 FSM*
8191137
8201138 ![](../images/caliptra-rtl/docs/images/SHA256_fsm.png)
8211139
@@ -844,13 +1162,13 @@
8441162
8451163 ### Address map
8461164
847-The SHA256 address map is shown here: [sha256\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.sha256_reg).
1165+The SHA256 address map is shown here: [sha256\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.sha256_reg).
8481166
8491167 ### Pseudocode
8501168
8511169 The following pseudocode demonstrates how the SHA256 interface can be implemented.
8521170
853-*Figure 23: SHA256 pseudocode*
1171+*Figure: SHA256 pseudocode*
8541172
8551173 ![](../images/caliptra-rtl/docs/images/SHA256_pseudo.png)
8561174
@@ -890,6 +1208,184 @@
8901208 | 1 KiB message | 8761 | 21.90 | 45,657 |
8911209
8921210
1211+## SHA3
1212+
1213+The SHA3 HWIP performs the hash functions, whose purpose is to check the integrity of the received message.
1214+It supports various SHA3 hashing functions including SHA3 Extended Output Function (XOF) known as SHAKE functions.
1215+The details of the operation are described in the [SHA3 specification, FIPS 202](https://csrc.nist.gov/publications/detail/fips/202/final) known as _sponge construction_.
1216+It has been adapted from OpenTitan and you can find documentation describing the functionality of the KMAC block it was derived from [here](https://opentitan.org/book/hw/ip/kmac/index.html).
1217+In the current use cases of the SHA3 HW IP, either (a) messages are not considered secret (External Mu), or (b) SCA hardening would not be meaningful (HPKE in OCP L.O.C.K.), hence there are no SCA requirements.
1218+
1219+### Features
1220+- Support for SHA3-224, 256, 384, 512, SHAKE[128, 256] and cSHAKE[128, 256]
1221+- Support byte-granularity on input message
1222+- Support arbitrary output length for SHAKE, cSHAKE
1223+- Support customization input string S, and function-name N up to 36 bytes total
1224+- 64b x 10 depth Message FIFO
1225+- Zeroize through the `SHA3_CTRL.ZEROIZE` register and on debug/scan mode switch
1226+- Performance (at 100 MHz):
1227+ - SHA3-224: 2.93 B/cycle, 2.34 Gbit/s - 1.19 B/cycle, 952 Mbit/s (DOM)
1228+ - SHA3-512: 1.47 B/cycle, 1.18 Gbit/s - 0.59 B/cycle, 472 Mbit/s (DOM)
1229+
1230+### Design Details
1231+
1232+#### Keccak Round
1233+
1234+A Keccak round implements the Keccak_f function described in the SHA3 specification.
1235+Keccak round logic in SHA3 HWIP not only supports 1600 bit internal states but also all possible values {25, 50, 100, 200, 400, 800, 1600} based on a parameter `Width`.
1236+Keccak permutations in the specification allow arbitrary number of rounds.
1237+This module, however, supports Keccak_f which always runs `12 + 2*L` rounds, where \\[ L = log_2 {( {Width \over 25} )} \\] .
1238+For instance, 200 bits of internal state run 18 rounds.
1239+SHA3 instantiates the Keccak round module with 1600 bit.
1240+
1241+![](../images/caliptra-rtl/docs/images/sha3-keccak-round.svg)
1242+
1243+Keccak round logic has two phases inside.
1244+Theta, Rho, Pi functions are executed at the 1st phase.
1245+Chi and Iota functions run at the 2nd phase.
1246+The first phase and the second phase run in the same cycle.
1247+
1248+To save circuit area, the Chi function uses 800 instead 1600 DOM multipliers but the multipliers are fully pipelined.
1249+The Chi and Iota functions are thus separately applied to the two halves of the state and the 2nd phase takes in total three clock cycles to complete.
1250+In the first clock cycle of the 2nd phase, the first stage of Chi is computed for the first lane halves of the state.
1251+In the second clock cycle, the new first lane halves are output and written to state register.
1252+At the same time, the first stage of Chi is computed for the second lane halves.
1253+In the third clock cycle, the new second lane halves are output and written to the state register.
1254+
1255+#### Padding for Keccak
1256+
1257+Padding logic supports SHA3/SHAKE/cSHAKE algorithms.
1258+cSHAKE needs the extra inputs for the Function-name `N` and the Customization string `S`.
1259+Other than that, SHA3, SHAKE, and cSHAKE share similar datapath inside the padding module except the last part added next to the end of the message.
1260+SHA3 adds `2'b 10`, SHAKE adds `4'b 1111`, cSHAKE adds `2'b00` then `pad10*1()` follows.
1261+All are little-endian values.
1262+
1263+Interface between this padding logic and the MSG_FIFO follows the conventional FIFO interface.
1264+So `caliptra_prim_fifo_*` can talk to the padding logic directly.
1265+This module talks to Keccak round logic with a more memory-like interface.
1266+The interface has an additional address signal on top of the valid, ready, and data signals.
1267+
1268+![](../images/caliptra-rtl/docs/images/sha3-padding.svg)
1269+
1270+The hashing process begins when the software issues the start command to `CMD` .
1271+If cSHAKE is enabled, the padding logic expands the prefix value (`N || S` above) into a block size.
1272+The block size is determined by the `CFG_SHADOWED.kstrength`.
1273+If the value is 128, the block size will be 168 bytes.
1274+If it is 256, the block size will be 136 bytes.
1275+The expanded prefix value is transmitted to the Keccak round logic.
1276+After sending the block size, the padding logic triggers the Keccak round logic to run a full 24 rounds.
1277+
1278+If the mode is not cSHAKE, or cSHAKE mode and the prefix block has been processed, the padding logic accepts the incoming message bitstream and forward the data to the Keccak round logic in a block granularity.
1279+The padding logic controls the data flow and makes the Keccak logic to run after sending a block size.
1280+
1281+After the software writes the message bitstream, it should issue the Process command into `CMD` register.
1282+The padding logic, after receiving the Process command, appends proper ending bits with respect to the `CFG_SHADOWED.mode` value.
1283+The logic writes 0 up to the block size to the Keccak round logic then ends with 1 at the end of the block.
1284+
1285+![](../images/caliptra-rtl/docs/images/sha3-padding-fsm.svg)
1286+
1287+After the Keccak round completes the last block, the padding logic asserts an `absorbed` signal to notify the software.
1288+At this point, the software is able to read the digest in `STATE` memory region.
1289+If the output length is greater than the Keccak block rate in SHAKE and cSHAKE mode, the software may run the Keccak round manually by issuing Run command to `CMD` register.
1290+
1291+The software completes the operation by issuing Done command after reading the digest.
1292+The padding logic clears internal variables and goes back to Idle state.
1293+
1294+#### Message FIFO
1295+
1296+The SHA3 HWIP has a compile-time configurable depth message FIFO inside.
1297+The message FIFO receives incoming message bitstream regardless of its byte position in a word.
1298+Then it packs the partial message bytes into the internal 64 bit data width.
1299+After packing the data, the logic stores the data into the FIFO until the internal SHA3 engine consumes the data.
1300+
1301+##### FIFO Depth calculation
1302+
1303+The depth of the message FIFO is chosen to cover the throughput of the software or other producers such as DMA engine.
1304+The size of the message FIFO is enough to hold the incoming data while the SHA3 engine is processing the previous block.
1305+Default design parameters assume the system characteristics as below:
1306+
1307+- `kmac_pkg::RegLatency`: The register write takes 5 cycles.
1308+- `kmac_pkg::Sha3Latency`: Keccak round latency takes 24 cycles.
1309+
1310+##### Empty and Full status
1311+
1312+Under normal operating conditions, the SHA3 engine will process data a lot faster than software can push it to the Message FIFO.
1313+The Message FIFO depth observable from `STATUS.fifo_depth` will remain **0** while the `STATUS.fifo_empty` status bit is lowered for one clock cycle whenever software provides new data.
1314+
1315+After the SHA3 engine starts popping the data again, the Message FIFO will eventually run empty again and the `fifo_empty` status interrupt will fire.
1316+Note that the `fifo_empty` status interrupt will not fire if i) one of the hardware application interfaces is using the SHA3 block, ii) the SHA3 core is not in the `Absorb` state, or iii) after software has written the `Process` command.
1317+
1318+If software pushes data to the Message FIFO while it is full, the write operation is blocked until there is again space in the FIFO.
1319+This means the processor is effectively stalled.
1320+If the SHA3 engine is currently running and software fills up the Message FIFO, the resulting stall won't take more than 100 clock cycles.
1321+The stall mechanism prevents data loss and the upper bound on the wait time avoids software needing to poll the `STATUS.fifo_depth` field before writing data.
1322+
1323+### Programmer's guide
1324+
1325+The software can update the SHA3 configurations only when the IP is in the idle state.
1326+The software should check `STATUS.sha3_idle` before updating the configurations.
1327+The software must first program `CFG_SHADOWED.msg_endianness` and `CFG_SHADOWED.state_endianness` at the initialization stage.
1328+These determine the byte order of incoming messages (msg_endianness) and the Keccak state output (state_endianness).
1329+
1330+#### Software Initiated SHA3 process
1331+
1332+This section describes the expected software process to run the SHA3 HWIP.
1333+At first, the software configures `CFG_SHADOWED.kmac_en` for the operation.
1334+If SHA3 is enabled, the software should configure `CFG_SHADOWED.mode` to cSHAKE and `CFG_SHADOWED.kstrength` to 128 or 256 bit security strength.
1335+The software also updates `PREFIX` registers if cSHAKE mode is used.
1336+Current design does not convert cSHAKE mode to SHAKE even if `PREFIX` is empty string.
1337+It is the software's responsibility to change the `CFG_SHADOWED.mode` to SHAKE in case of empty `PREFIX`.
1338+The SHA3 HWIP uses `PREFIX` registers as it is.
1339+It means that the software should update `PREFIX` with encoded values.
1340+
1341+After configuring, the software notifies the SHA3 engine to accept incoming messages by issuing Start command into `CMD`.
1342+If Start command is not issued, the incoming message is discarded.
1343+
1344+After the software pushes all messages, it issues Process command to `CMD` for SHA3 engine to complete the sponge absorbing process.
1345+SHA3 hashing engine pads the incoming message as defined in the SHA3 specification.
1346+
1347+After the SHA3 engine completes the sponge absorbing step, it generates `kmac_done` interrupt.
1348+Or the software can poll the `STATUS.squeeze` bit until it becomes 1.
1349+In this stage, the software may run the Keccak round manually.
1350+
1351+If the desired digest length is greater than the Keccak rate, the software issues Run command for the Keccak round logic to run one full round after the software reads the current available Keccak state.
1352+At this stage, SHA3 does not raise an interrupt when the Keccak round completes the software initiated manual run.
1353+The software should check `STATUS.squeeze` register field for the readiness of `STATE` value.
1354+
1355+After the software reads all the digest values, it issues Done command to `CMD` register to clear the internal states.
1356+Done command clears the Keccak state, FSM in SHA3, and a few internal variables.
1357+
1358+#### Zeroize
1359+
1360+Writing 1 to `SHA3_CTRL.ZEROIZE` clears all message and digest data and aborts any operation in progress, in any state.
1361+SHA3 is also zeroized on debug lock/unlock, scan mode and lifecycle change.
1362+While a Caliptra fatal error is asserted, SHA3 is held in zeroize.
1363+Each register is cleared synchronously in the zeroize cycle.
1364+
1365+Zeroize clears:
1366+- the Keccak state, the padding buffer and the message FIFO
1367+- the `STATE` read data, including the copy held in the TL-UL adapter
1368+- the SHA3 FSMs, the internal counters and any pending command, the engine returns to idle
1369+
1370+Bus transactions in flight complete normally.
1371+A `STATE` read in the zeroize cycle returns 0.
1372+Zeroize has precedence over the terminal error state and returns the SHA3 FSMs to idle.
1373+The FSMs only return to the terminal error state if the escalation signal is still asserted.
1374+
1375+After zeroize, the software must wait for `STATUS.sha3_idle` to start a new operation with the Start command.
1376+
1377+#### Endianness
1378+
1379+This SHA3 HWIP operates in little-endian.
1380+Internal SHA3 hashing engine receives in 64-bit granularity.
1381+The data written to SHA3 is assumed to be little endian.
1382+
1383+The software may write/read the data in big-endian order if `CFG_SHADOWED.msg_endianness` or `CFG_SHADOWED.state_endianness` is set.
1384+If the endianness bit is 1, the data is assumed to be big-endian.
1385+So, the internal logic byte-swap the data.
1386+For example, when the software writes `0xDEADBEEF` with endianness as 1, the logic converts it to `0xEFBEADDE` then writes into MSG_FIFO.
1387+
1388+
8931389 ## HMAC512/HMAC384
8941390
8951391 Hash-based message authentication code (HMAC) is a cryptographic authentication technique that uses a hash function and a secret key. HMAC involves a cryptographic hash function and a secret cryptographic key. This implementation supports the HMAC512 variants HMAC-SHA-512-256 and HMAC-SHA-384-192 as specified in [NIST FIPS 198-1](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.198-1.pdf) [5]. The implementation is compatible with the HMAC-SHA-512-256 and HMAC-SHA-384-192 authentication and integrity functions defined in [RFC 4868](https://tools.ietf.org/html/rfc4868) [6].
@@ -916,25 +1412,25 @@
9161412
9171413 The total size should be equal to 128 bits, short of a multiple of 1024 because the goal is to have the formatted message size as a multiple of 1024 bits (N x 1024).
9181414
919-*Figure 24: HMAC input formatting*
1415+*Figure: HMAC input formatting*
9201416
9211417 ![](../images/caliptra-rtl/docs/images/HMAC_input.png)
9221418
9231419 The following figures show examples of input formatting for different message lengths.
9241420
925-*Figure 25: Message length of 1023 bits*
1421+*Figure: Message length of 1023 bits*
9261422
9271423 ![](../images/caliptra-rtl/docs/images/msg_1023.png)
9281424
9291425 When the message is 1023 bits long, padding is given in the next block along with message size.
9301426
931-*Figure 26: 1 bit padding*
1427+*Figure: 1 bit padding*
9321428
9331429 ![](../images/caliptra-rtl/docs/images/1_bit.png)
9341430
9351431 When the message size is 895 bits, a padding of ‘1’ is also considered valid, followed by the message size.
9361432
937-*Figure 27: Multi block message*
1433+*Figure: Multi block message*
9381434
9391435 ![](../images/caliptra-rtl/docs/images/msg_multi_block.png)
9401436
@@ -945,13 +1441,13 @@
9451441
9461442 The HMAC512 core performs the sha2-512 function to process the hash value of the given message. The algorithm processes each block of the 1024 bits from the message, using the result from the previous block. This data flow is shown in the following figure.
9471443
948-*Figure 28: HMAC-SHA-512-256 data flow*
1444+*Figure: HMAC-SHA-512-256 data flow*
9491445
9501446 ![](../images/caliptra-rtl/docs/images/HMAC_SHA_512_256.png)
9511447
9521448 The HMAC384 core performs the sha2-384 function to process the hash value of the given message. The algorithm processes each block of the 1024 bits from the message, using the result from the previous block. This data flow is shown in the following figure.
9531449
954-*Figure 29: HMAC-SHA-384-192 data flow*
1450+*Figure: HMAC-SHA-384-192 data flow*
9551451
9561452 ![](../images/caliptra-rtl/docs/images/HMAC_SHA_384_192.png)
9571453
@@ -959,13 +1455,24 @@
9591455
9601456 The HMAC architecture has the finite-state machine as shown in the following figure.
9611457
962-*Figure 30: HMAC FSM*
1458+*Figure: HMAC FSM*
9631459
9641460 ![](../images/caliptra-rtl/docs/images/HMAC_FSM.png)
9651461
1462+### Multi-block operations
1463+
1464+An HMAC operation starts with `INIT` on the first block and ends with the first block that has `LAST` set (`INIT|LAST` for a single block, otherwise `NEXT|LAST`). Each block without `LAST` produces an intermediate SHA-512 chaining state, not an HMAC tag.
1465+
1466+* `NEXT` is accepted only while an operation started by `INIT` is in flight. A `NEXT` (with or without `LAST`) issued after the final tag, after zeroize, or before any `INIT` is rejected and sets `error2_sts`.
1467+* If the key or block was read from the key vault, or the result is routed to the key vault, no intermediate or final result is written to `TAG`. The key vault provenance and the `KEY` register lock are held until the final tag or zeroize, and the key vault write happens only on the final tag.
1468+* In CSR mode, intermediate results are not written to `TAG`; only the final tag is.
1469+* Key vault read controls and `CSR_MODE` cannot be changed while an operation is in flight. They must be programmed before `INIT`, or the operation must be zeroized.
1470+
9661471 ### CSR Mode
9671472
9681473 When the CSR Mode register is set, the HMAC512 core uses the value latched from the cptra_csr_hmac_key interface pins in place of the API key register. These pins are latched internally after powergood assertion during DEVICE_MANUFACTURING lifecycle state. During debug mode operation this value is overridden with all 1's, and during any other lifecycle state it has a value of zero.
1474+
1475+ROM must set `internal_csr_hmac_key_lock` (write-1-to-set) before handing off to FMC. Once the lock is set, the latched CSR HMAC key is cleared to zero, so FMC and Runtime FW can never use it. The lock is cleared only by warm or cold reset. A firmware-update (hitless) reset does not clear it, so the key stays unavailable through hitless updates.
9691476
9701477 ### Signal descriptions
9711478
@@ -991,13 +1498,13 @@
9911498
9921499 ### Address map
9931500
994-The HMAC address map is shown here: [hmac\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.hmac_reg).
1501+The HMAC address map is shown here: [hmac\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.hmac_reg).
9951502
9961503 ### Pseudocode
9971504
9981505 The following pseudocode demonstrates how the HMAC interface can be implemented.
9991506
1000-*Figure 31: HMAC pseudocode*
1507+*Figure: HMAC pseudocode*
10011508
10021509 ![](../images/caliptra-rtl/docs/images/HMAC_pseudo.png)
10031510
@@ -1122,7 +1629,7 @@
11221629
11231630 Secp384r1 parameters are shown in the following figure.
11241631
1125-*Figure 32: Secp384r1 parameters*
1632+*Figure: Secp384r1 parameters*
11261633
11271634 ![](../images/caliptra-rtl/docs/images/secp384r1_params.png)
11281635
@@ -1130,7 +1637,7 @@
11301637
11311638 The ECDSA consists of three operations, shown in the following figure.
11321639
1133-*Figure 33: ECDSA operations*
1640+*Figure: ECDSA operations*
11341641
11351642 ![](../images/caliptra-rtl/docs/images/ECDSA_ops.png)
11361643
@@ -1175,7 +1682,7 @@
11751682
11761683 The ECC top-level architecture is shown in the following figure.
11771684
1178-*Figure 34: ECC architecture*
1685+*Figure: ECC architecture*
11791686
11801687 ![](../images/caliptra-rtl/docs/images/ECC_arch.png)
11811688
@@ -1207,7 +1714,7 @@
12071714
12081715 ### Address map
12091716
1210-The ECC address map is shown here: [ecc\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.ecc_reg).
1717+The ECC address map is shown here: [ecc\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.ecc_reg).
12111718
12121719 ### Pseudocode
12131720
@@ -1215,27 +1722,49 @@
12151722
12161723 #### KeyGen
12171724
1218-*Figure 35: KeyGen pseudocode*
1725+*Figure: KeyGen pseudocode*
12191726
12201727 ![](../images/caliptra-rtl/docs/images/keygen_pseudo.png)
12211728
12221729 #### Signing
12231730
1224-*Figure 36: Signing pseudocode*
1731+*Figure: Signing pseudocode*
12251732
12261733 ![](../images/caliptra-rtl/docs/images/signing_pseudo.png)
12271734
12281735 #### Verifying
12291736
1230-*Figure 37: Verifying pseudocode*
1737+*Figure: Verifying pseudocode*
12311738
12321739 ![](../images/caliptra-rtl/docs/images/verify_pseudo.png)
12331740
12341741 #### ECDH sharedkey
12351742
1236-*Figure 38: ECDH sharedkey pseudocode*
1743+*Figure: ECDH sharedkey pseudocode*
12371744
12381745 ![](../images/caliptra-rtl/docs/images/sharedkey_pseudo.png)
1746+
1747+### ECC zeroize
1748+
1749+Writing 1 to `ECC_CTRL.ZEROIZE` clears all ECC internal registers and API registers, including `ECC_PRIVKEY_IN`, `ECC_SEED`, `ECC_MSG`, and all outputs. ECC is also zeroized on debug lock/unlock and scan mode switch.
1750+
1751+Firmware must issue zeroize:
1752+- After every completed operation (KeyGen, Signing, Verifying, ECDH sharedkey, PCR signing), once the results have been read, before starting the next command.
1753+- After any error, before re-issuing a command.
1754+- After writing `ECC_CTRL.PCR_SIGN`, once the PCR signature has been read.
1755+
1756+Hardware enforces this requirement:
1757+- When an operation completes (`ECC_STATUS.VALID` set), when an error is detected, or when `ECC_CTRL.PCR_SIGN` loads the PCR signing key from key vault slot 7, `ECC_STATUS.READY` stays de-asserted until zeroize is issued.
1758+- While `ECC_STATUS.READY` is de-asserted, `ECC_CTRL` commands, all API input registers, and the key vault read controls cannot be written. Results remain readable.
1759+- After zeroize, the engine runs its internal initialization and then sets `ECC_STATUS.READY`.
1760+
1761+In addition, hardware clears key material sourced from the key vault without waiting for zeroize:
1762+- `ECC_PRIVKEY_IN` loaded from the key vault, including the PCR signing key loaded by `PCR_SIGN`, and `ECC_SEED` loaded from the key vault are cleared when the operation completes.
1763+- `ECC_PRIVKEY_IN` and `ECC_SEED` are cleared when an error is detected.
1764+- The internal copy of a generated private key or shared key destined for the key vault is cleared once the key vault write completes.
1765+- `ECC_CTRL.PCR_SIGN` must be written together with the Signing command in `ECC_CTRL.CTRL`. Any other combination, including `PCR_SIGN` alone, is reported as an error and clears the loaded key.
1766+
1767+This guarantees that a private key loaded into `ECC_PRIVKEY_IN`, in particular the PCR signing key that `PCR_SIGN` loads from key vault slot 7, is cleared before any subsequent firmware-controlled operation starts.
12391768
12401769 ### SCA countermeasure
12411770
@@ -1299,7 +1828,7 @@
12991828 2. KEYGEN PRIVKEY: Running HMAC\_DRBG with seed and nonce to generate the privkey in KEYGEN operation.
13001829 3. SIGNING NONCE: Running HMAC\_DRBG based on RFC6979 in SIGNING operation with privkey and hashed\_msg.
13011830
1302-*Figure 39: HMAC\_DRBG utilization*
1831+*Figure: HMAC\_DRBG utilization*
13031832
13041833 ![](../images/caliptra-rtl/docs/images/HMAC_DRBG_util.png)
13051834
@@ -1315,7 +1844,7 @@
13151844
13161845 The data flow of the HMAC\_DRBG operation in keygen operation mode is shown in the following figure.
13171846
1318-*Figure 40: HMAC\_DRBG data flow*
1847+*Figure: HMAC\_DRBG data flow*
13191848
13201849 ![](../images/caliptra-rtl/docs/images/HMAC_DRBG_data.png)
13211850
@@ -1325,7 +1854,7 @@
13251854
13261855 In practice, observing a t-value greater than a specific threshold (mainly 4.5) indicates the presence of leakage. However, in ECC, due to its latency, around 5 million samples are required to be captured. This latency leads to many false positives and the TVLA threshold can be considered a higher value than 4.5. Based on the following figure from “Side-Channel Analysis and Countermeasure Design for Implementation of Curve448 on Cortex-M4” by Bisheh-Niasar et. al., the threshold can be considered equal to 7 in our case.
13271856
1328-*Figure 41: TVLA threshold as a function of the number of samples per trace*
1857+*Figure: TVLA threshold as a function of the number of samples per trace*
13291858
13301859 ![](../images/caliptra-rtl/docs/images/TVLA_threshold.png)
13311860
@@ -1335,7 +1864,7 @@
13351864 The TVLA results for performing seed/nonce-dependent leakage detection using 200,000 traces is shown in the following figure. Based on this figure, there is no leakage in ECC keygen by changing the seed/nonce after 200,000 operations.
13361865
13371866
1338-*Figure 42: seed/nonce-dependent leakage detection using TVLA for ECC keygen after 200,000 traces*
1867+*Figure: seed/nonce-dependent leakage detection using TVLA for ECC keygen after 200,000 traces*
13391868
13401869 ![](../images/caliptra-rtl/docs/images/tvla_keygen.png)
13411870
@@ -1343,13 +1872,13 @@
13431872
13441873 The TVLA results for performing privkey-dependent leakage detection using 20,000 traces is shown in the following figure. Based on this figure, there is no leakage in ECC signing by changing the privkey after 20,000 operations.
13451874
1346-*Figure 43: privkey-dependent leakage detection using TVLA for ECC signing after 20,000 traces*
1875+*Figure: privkey-dependent leakage detection using TVLA for ECC signing after 20,000 traces*
13471876
13481877 ![](../images/caliptra-rtl/docs/images/TVLA_privekey.png)
13491878
13501879 The TVLA results for performing message-dependent leakage detection using 64,000 traces is shown in the following figure. Based on this figure, there is no leakage in ECC signing by changing the message after 64,000 operations.
13511880
1352-*Figure 44: Message-dependent leakage detection using TVLA for ECC signing after 64,000 traces*
1881+*Figure: Message-dependent leakage detection using TVLA for ECC signing after 64,000 traces*
13531882
13541883 ![](../images/caliptra-rtl/docs/images/TVLA_msg_dependent.png)
13551884
@@ -1374,13 +1903,14 @@
13741903
13751904 ### Pure hardware architecture
13761905
1377-In this architecture, the ECC interface and controller are implemented in hardware. The performance specification of the ECC architecture is reported as shown in the following table.
1906+In this architecture, the ECC interface and controller are implemented in hardware. The Montgomery multiplier in the current RTL uses a **radix-48** datapath (`MULT_RADIX = 48` in `src/ecc/rtl/ecc_params_pkg.sv`), which reduces the number of PE iterations per 384-bit modular multiplication from 12 (radix-32) to 8. The performance specification of the ECC architecture is reported as shown in the following table. Cycle counts were measured on `ecc_top_tb` running the `ecc_normal_test` (radix-48 RTL).
13781907
13791908 | Operation | Cycle count \[CCs\] | Time \[ms\] @ 400 MHz | Throughput \[op/s\] |
1380-| :-------- | :------------------ | :-------------------- | :------------------ |
1381-| Keygen | 909,648 | 2.274 | 439 |
1382-| Signing | 932,990 | 2.332 | 428 |
1383-| Verifying | 1,223,938 | 3.060 | 326 |
1909+| :------------- | :------------------ | :-------------------- | :------------------ |
1910+| Keygen | 719,675 | 1.799 | 556 |
1911+| Signing | 736,978 | 1.842 | 543 |
1912+| Verifying | 960,404 | 2.401 | 416 |
1913+| ECDH sharedkey | 717,421 | 1.794 | 558 |
13841914
13851915
13861916
@@ -1388,15 +1918,15 @@
13881918
13891919 LMS cryptography is a type of hash-based digital signature scheme that was standardized by NIST in 2020. It is based on the Leighton-Micali Signature (LMS) system, which uses a Merkle tree structure to combine many one-time signature (OTS) keys into a single public key. LMS cryptography is resistant to quantum attacks and can achieve a high level of security without relying on large integer mathematics.
13901920
1391-Caliptra supports only LMS verification using a software/hardware co-design approach. Hence, the LMS accelerator reuses the SHA256 engine to speedup the Winternitz chain by removing software-hardware interface overhead. The LMS-OTS verification algorithm is shown in follwoing figure:
1392-
1393-*Figure 45: LMS-OTS Verification algorithm*
1921+Caliptra supports only LMS verification using a software/hardware co-design approach. Hence, the LMS accelerator reuses the SHA256 engine to speedup the Winternitz chain by removing software-hardware interface overhead. The LMS-OTS verification algorithm is shown in following figure:
1922+
1923+*Figure: LMS-OTS Verification algorithm*
13941924
13951925 ![](../images/caliptra-rtl/docs/images/LMS_verifying_alg.png)
13961926
13971927 The high-level architecture of LMS is shown in the following figure.
13981928
1399-*Figure 46: LMS high-level architecture*
1929+*Figure: LMS high-level architecture*
14001930
14011931 ![](../images/caliptra-rtl/docs/images/LMS_high_level.png)
14021932
@@ -1421,7 +1951,7 @@
14211951
14221952 The Winternitz hash chain can be accelerated in hardware to enhance the performance of the design. For that, a configurable architecture is proposed that can reuse SHA256 engine. The LMS accelerator architecture is shown in the following figure, while H is SHA256 engine.
14231953
1424-*Figure 47: Winternitz chain architecture*
1954+*Figure: Winternitz chain architecture*
14251955
14261956 ![](../images/caliptra-rtl/docs/images/LMS_wntz_arch.png)
14271957
@@ -1449,14 +1979,21 @@
14491979
14501980 ### Address map
14511981
1452-The address map for LMS accelerator integrated into SHA256 is shown here: [sha256\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.sha256_reg).
1982+The address map for LMS accelerator integrated into SHA256 is shown here: [sha256\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.sha256_reg).
14531983
14541984 ## Adams Bridge - Dilithium (ML-DSA)
14551985
14561986 Please refer to the [Adams-bridge specification](https://github.com/chipsalliance/adams-bridge/blob/main/docs/AdamsBridgeHardwareSpecification.md)
14571987
14581988 ### Address map
1459-Address map of ML-DSA accelerator is shown here: [ML-DSA\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.mldsa_reg)
1989+Address map of ML-DSA accelerator is shown here: [ML-DSA\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.abr_reg)
1990+
1991+## Adams Bridge Kyber ML-KEM
1992+
1993+Please refer to the [Adams-bridge specification](https://github.com/chipsalliance/adams-bridge/blob/main/docs/AdamsBridgeHardwareSpecification.md)
1994+
1995+### Address map
1996+Address map of ML-KEM accelerator is shown here: [ML-KEM\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.abr_reg)
14601997
14611998 ## AES
14621999
@@ -1469,6 +2006,12 @@
14692006 ### Operation
14702007
14712008 For more information, see the [AES Programmer's Guide](https://github.com/vogelpi/opentitan/blob/aes-gcm-review/hw/ip/aes/doc/programmers_guide.md).
2009+
2010+## AES Endian
2011+
2012+The AES Core uses little endian for the DATA_IN and DATA_OUT registers. Caliptra allows a user to stream the data into and out of AES in big endian when AES_CLP.CTRL0.ENDIAN_SWAP is set to 1. This is done by swizzling the write and read data when a write targets DATA_IN or a read targets DATA_OUT.
2013+
2014+By default little endian is selected.
14722015
14732016 ### Signal descriptions
14742017
@@ -1482,7 +2025,7 @@
14822025 | DATA_OUT | output | Output block result of encryption or decryption. Stored in four 32-bit registers. |
14832026 | CTRL_SHADOWED.MANUAL_OPERATION | input | Configures the AES core to operation in manual mode. |
14842027 | CTRL_SHADOWED.PRNG_RESEED_RATE | input | Configures the rate of reseeding the internal PRNG used for masking. |
1485-| CTRL_SHADOWED.SIDELOAD | input | When asserted, AES core will use the key from the keyvault interface. |
2028+| CTRL_SHADOWED.SIDELOAD | input | When asserted, AES core will use the key from the key vault interface. |
14862029 | CTRL_SHADOWED.KEY_LEN | input | Configures the AES key length. Supports 128, 192, and 256-bit keys. |
14872030 | CTRL_SHADOWED.MODE | input | Configures the AES block cipher mode. |
14882031 | CTRL_SHADOWED.OPERATION | input | Configures the AES core to operate in encryption or decryption modes. |
@@ -1504,7 +2047,7 @@
15042047
15052048 ### Address map
15062049
1507-The AES address map is shown here: [aes\_clp\_reg — clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.aes_clp_reg).
2050+The AES address map is shown here: [aes\_clp\_reg -- clp Reference (chipsalliance.github.io)](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.aes_clp_reg).
15082051
15092052 ### SCA countermeasures
15102053
@@ -1797,19 +2340,19 @@
17972340 To underpin the results of the formal verification flow, the hardening of the GHASH module has been analyzed on the ChipWhisperer [CW310](https://rtfm.newae.com/Targets/CW310%20Bergen%20Board/) FPGA board.
17982341 For this analysis, power traces with the ChipWhisperer [Husky](https://rtfm.newae.com/Capture/ChipWhisperer-Husky/) scope were captured during GCM operations.
17992342 Afterwards a Test Vector Leakage Assessment (TVLA) with the [ot-sca toolset](https://github.com/lowRISC/ot-sca) has been performed.
1800-The setup is illustrated in Figure 1.
2343+The setup is illustrated in the following Figure.
18012344
18022345 ![](../images/caliptra-rtl/docs/images/cw310_cwhusky.jpeg)
18032346 :--:
1804-**Figure 1**: Target CW310 FPGA board (left) and the CW Husky scope (right).
2347+**Figure**: Target CW310 FPGA board (left) and the CW Husky scope (right).
18052348
18062349 ##### Setup
18072350
18082351 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure2.png)
18092352 :--:
1810-**Figure 2**: Measurement setup. The main components are the target board, the scope, and the SCA framework.
1811-
1812-Figure 2 gives a detailed overview of the measurement setup that has been utilized to capture the power traces.
2353+**Figure**: Measurement setup. The main components are the target board, the scope, and the SCA framework.
2354+
2355+The prior Figure gives a detailed overview of the measurement setup that has been utilized to capture the power traces.
18132356 The SCA evaluation framework ot-sca is the central component of the measurement setup.
18142357 It is responsible for communicating with the penetration testing framework that runs on the target FPGA board and with the scope.
18152358 Initially, ot-sca configures the scope (sample rate, number of samples) and the pentest framework (which input, how many encryptions, where to trigger).
@@ -1821,9 +2364,9 @@
18212364
18222365 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure3.png)
18232366 :--:
1824-**Figure 3**: Power trace with AES encryption rounds visible (*left*). Aligned traces when zooming in (*right*).
1825-
1826-Figure 3 depicts power traces captured during AES-GCM encryptions with the setup above.
2367+**Figure**: Power trace with AES encryption rounds visible (*left*). Aligned traces when zooming in (*right*).
2368+
2369+The prior Figure depicts power traces captured during AES-GCM encryptions with the setup above.
18272370 As shown in the figure, the traces are nicely aligned, allowing to perform a sound evaluation.
18282371
18292372 ##### Methodology
@@ -1835,9 +2378,9 @@
18352378
18362379 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure4.png)
18372380 :--
1838-**Figure 4:** TVLA plot showing leakage at around sample 1000. When increasing the number of traces (from 1000 to 10000), the leakage becomes more present. Note that the traces shown in this plot are taken from an arbitrary cryptographic hardware block and not AES.
1839-
1840-Figure 4 shows a TVLA plot that will be used throughout this document. The red lines mark the ± *t*-test border.
2381+**Figure:** TVLA plot showing leakage at around sample 1000. When increasing the number of traces (from 1000 to 10000), the leakage becomes more present. Note that the traces shown in this plot are taken from an arbitrary cryptographic hardware block and not AES.
2382+
2383+The prior Figure shows a TVLA plot that will be used throughout this document. The red lines mark the ± *t*-test border.
18412384
18422385 ###### Dataset Generation for FvsR IV & Key
18432386
@@ -1878,26 +2421,26 @@
18782421
18792422 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure5.png)
18802423 :--:
1881-**Figure 5:** AES-GCM block diagram. Red lines mark the trigger windows for each analysis step.
1882-
1883-As shown in Figure 5, we focus on analyzing (*i*) the generation of the hash subkey H, (*ii*) the encryption of the initial counter block S, (*iii*) the processing of the AAD blocks, (*iv*) the plaintext blocks, and (*v*) the tag generation. Each measurement is conducted with (*a*) masks off and (*b*) masks on to analyze the effectiveness of the masking countermeasure.
2424+**Figure:** AES-GCM block diagram. Red lines mark the trigger windows for each analysis step.
2425+
2426+As shown in the prior Figure, we focus on analyzing (*i*) the generation of the hash subkey H, (*ii*) the encryption of the initial counter block S, (*iii*) the processing of the AAD blocks, (*iv*) the plaintext blocks, and (*v*) the tag generation. Each measurement is conducted with (*a*) masks off and (*b*) masks on to analyze the effectiveness of the masking countermeasure.
18842427
18852428 ###### i) SCA Evaluation of Generating the Hash Subkey H
18862429
18872430 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure6ab.png)
18882431 :--:
18892432
1890-| **Figure 6a:** Masking Off - 100k traces - **Figure 6b:** Masking On - 1M traces |
2433+| **Figure:** Masking Off - 100k traces - **Figure:** Masking On - 1M traces |
18912434
18922435
18932436 ###### Interpretation
18942437
1895-The AES encryption is clearly visible in the form of 12 distinct peaks in the power traces shown Figures 6a and 6b.
2438+The AES encryption is clearly visible in the form of 12 distinct peaks in the power traces shown in the prior set of Figures.
18962439 The 12 peaks correspond to first the loading of the key and the all-zero block into the AES cipher core, followed by the initial round and the 10 full AES rounds (AES-128).
18972440 They spread over approximately 470 samples which corresponds to the 56 target clock cycles a full AES-128 encryption takes.
18982441
1899-If the masking is turned off (Figure 6a), first and second-order leakage is clearly visible throughout the operation.
1900-If the masking is on (Figure 6b), there is first-order leakage 1) at the beginning as well as 2) at the end of the operation.
2442+If the masking is turned off (set of graphs), first and second-order leakage is clearly visible throughout the operation.
2443+If the masking is on (set of graphs), there is first-order leakage 1) at the beginning as well as 2) at the end of the operation.
19012444
19022445 1. The leakage at the beginning of the operation is due to incrementing the IV/CTR value (inc32 function in GCM spec) which spreads across the first two AES rounds.
19032446 This produces first-order leakage as the inc32 function implementation isn’t masked.
@@ -1907,26 +2450,26 @@
19072450 The leakage is most likely due to how the FPGA implementation tool maps the flip flops of the hash subkey register shares to the available FPGA logic slices: if flip flops of the different shares get mapped to the same logic slice, the carry-chain and other muxing logic present in the logic slice can combine the various inputs thereby causing SCA leakage despite these logic outputs not being used.
19082451 We’ve observed similar effects in the past and there is [research giving more insight into this and other FPGA-specific issues](https://ieeexplore.ieee.org/document/10545383).
19092452
1910-To summarize, the observed first-order leakage if masking is on (Figure 6b) is not of concern for ASIC implementations.
2453+To summarize, the observed first-order leakage if masking is on is not of concern for ASIC implementations.
19112454
19122455 ###### ii) SCA Evaluation of Encrypting the Initial Counter Block
19132456
19142457 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure7ab.png)
19152458 :--:
19162459
1917-| **Figure 7a:** Masking Off - 100k traces - **Figure 7b:** Masking On - 1M traces |
2460+| **Figure:** Masking Off - 100k traces - **Figure:** Masking On - 1M traces |
19182461
19192462
19202463 ###### Interpretation
19212464
1922-Again, the AES encryption is clearly visible in the form of 12 peaks in the power traces shown Figures 7a and 7b.
2465+Again, the AES encryption is clearly visible in the form of 12 peaks in the power traces shown in the prior set of Figures.
19232466 This AES encryption corresponds to the generation of the encrypted initial counter block S.
19242467 The AES encryption is followed by another operation visible in the power trace: the computation of repeatedly used correction terms using the Galois-field multipliers inside GHASH.
19252468 This operation takes 33 target clock cycles (approximately 275 samples).
19262469
1927-If the masking is turned off (Figure 7a), first and second-order leakage is clearly visible throughout both operations while being more pronounced during the GHASH operation.
2470+If the masking is turned off (set of graphs), first and second-order leakage is clearly visible throughout both operations while being more pronounced during the GHASH operation.
19282471 This is because the GHASH block is smaller and thus produces less noise.
1929-If the masking is on (Figure 7b), there is first-order leakage 1) at the beginning as well as 2) between the two operations.
2472+If the masking is on (set of graphs), there is first-order leakage 1) at the beginning as well as 2) between the two operations.
19302473
19312474 1. As before, the leakage at the beginning of the operation is due to incrementing the IV/CTR value (inc32 function in GCM spec) which spreads across the first two AES rounds.
19322475 This produces first-order leakage as the inc32 function implementation isn’t masked.
@@ -1936,7 +2479,7 @@
19362479 As before, the leakage is most likely due to how the FPGA implementation tool maps the multiplexers in front of the GHASH state registers to the available FPGA logic slices: Since the multiplexers for both shares use the same control signals, the multiplexing logic can be combined even into the same look-up tables (LUTs) thereby causing SCA leakage.
19372480 We’ve observed similar effects in the past and there is [research giving more insight into this and other FPGA-specific issues](https://ieeexplore.ieee.org/document/10545383).
19382481
1939-To summarize, the observed first-order leakage if masking is on (FIgure 7b) is not of concern for ASIC implementations.
2482+To summarize, the observed first-order leakage if masking is on is not of concern for ASIC implementations.
19402483
19412484 ###### iii) SCA Evaluation of Processing the AAD Blocks
19422485
@@ -1945,31 +2488,31 @@
19452488 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure8ab.png)
19462489 :--:
19472490
1948-| **Figure 8a:** Masking Off - 50k traces - **Figure 8b:** Masking On - 10M traces |
2491+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 10M traces |
19492492
19502493
19512494 ###### Interpretation
19522495
19532496 For AAD blocks, the AES cipher core is not involved.
19542497 However, during the computation of the first AAD block, the GHASH block needs to compute an additional correction term which is used for the very first block only.
1955-If the masking is turned off (Figure 8a), first- and second-order leakage is clearly visible but only for the first activity block.
2498+If the masking is turned off (first set of graphs), first- and second-order leakage is clearly visible but only for the first activity block.
19562499 The second activity block involves computing the additional correction terms which requires Share 1 of the encrypted initial counter block to be multiplied by Share 1 of the hash subkey.
19572500 But since the masking is off, both these values are zero for both the fixed and the random set and hence there is no SCA leakage.
1958-If the masking is turned on (Figure 8b), no SCA leakage is observable which is desirable.
2501+If the masking is turned on (second set of graphs), no SCA leakage is observable which is desirable.
19592502
19602503 ###### Processing AAD Block 1
19612504
19622505 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure9ab.png)
19632506 :--:
19642507
1965-| **Figure 9a:** Masking Off - 50k traces - **Figure 9b:** Masking On - 10M traces |
2508+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 10M traces |
19662509
19672510
19682511 ###### Interpretation
19692512
19702513 For the second AAD block (and any subsequent AAD blocks) there is only one activity block corresponding to the Galois-field multiplication.
1971-If masking is turned off (Figure 9a), there is both first- and second-order leakage observable.
1972-If the masking is turned on (Figure 9b), no SCA leakage is observable which is desirable.
2514+If masking is turned off (first set of graphs), there is both first- and second-order leakage observable.
2515+If the masking is turned on (second set of graphs), no SCA leakage is observable which is desirable.
19732516
19742517 ###### iv) SCA Evaluation of Processing the PTX Blocks
19752518
@@ -1978,12 +2521,12 @@
19782521 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure10ab.png)
19792522 :--:
19802523
1981-| **Figure 10a:** Masking Off - 50k traces - **Figure 10b:** Masking On - 1M traces |
2524+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 1M traces |
19822525
19832526
19842527 ###### Interpretation
19852528
1986-Like in [ii) SCA Evaluation of Encrypting the Initial Counter Block](#ii-sca-evaluation-of-encrypting-the-initial-counter-block) there is first-order leakage 1) at the beginning and 2) between the two operations if the masking is turned on (Figure 10b).
2529+Like in [ii) SCA Evaluation of Encrypting the Initial Counter Block](#ii-sca-evaluation-of-encrypting-the-initial-counter-block) there is first-order leakage 1) at the beginning and 2) between the two operations if the masking is turned on (first set of graphs).
19872530
19882531 1. As before, the leakage at the beginning of the operation is due to incrementing the IV/CTR value (inc32 function in GCM spec) which spreads across the first two AES rounds.
19892532 This produces first-order leakage as the inc32 function implementation isn’t masked.
@@ -1993,14 +2536,14 @@
19932536 But since the AAD and the plaintext have been chosen to be the same for all traces in the fixed and the random sets, the traces of the fixed set only produce all the same ciphertext and thus are expected to exhibit a static power signature for this step, whereas the ciphertext of the random set is randomized through the random key and IV.
19942537 However, since the ciphertext is not secret in the context of GCM, this leakage is of no concern.
19952538
1996-To summarize, the observed first-order leakage if masking is on (FIgure 10b) is not of concern.
2539+To summarize, the observed first-order leakage if masking is on (second set of graphs) is not of concern.
19972540
19982541 ###### Processing PTX Block 1
19992542
20002543 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure11ab.png)
20012544 :--:
20022545
2003-| **Figure 11a:** Masking Off - 50k traces - **Figure 11b:** Masking On - 1M traces |
2546+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 1M traces |
20042547
20052548
20062549 ###### Interpretation
@@ -2013,7 +2556,7 @@
20132556 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure12ab.png)
20142557 :--:
20152558
2016-| **Figure 12a:** Masking Off - 50k traces - **Figure 12b:** Masking On - 1M traces |
2559+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 1M traces |
20172560
20182561
20192562 ###### Interpretation
@@ -2023,12 +2566,12 @@
20232566 The GHASH state is unmasked (still masked with the encrypted initial counter block S) and Share 1 of S is added to write the final authentication tag to the data output registers readable by software.
20242567 2) In parallel to writing the final authentication tag to the data output registers, the internal state is all cleared to random values and an additional multiplication is triggered to clear the internal state of the Galois-field multipliers and the correction term registers.
20252568
2026-If masking is turned off (Figure 12a), there is both first- and second-order leakage observable during the first activity block (tag generation) but not during the clearing operation.
2027-If the masking is turned on (Figure 12b), some SCA leakage is observable between the two operations, i.e., when the final authentication tag is written to the output data registers.
2569+If masking is turned off (first set of graphs), there is both first- and second-order leakage observable during the first activity block (tag generation) but not during the clearing operation.
2570+If the masking is turned on (second set of graphs), some SCA leakage is observable between the two operations, i.e., when the final authentication tag is written to the output data registers.
20282571 This leakage is expected as both the fixed and the random data sets use a static AAD and plaintext.
20292572 This means, the tag for the fixed data set is fixed whereas the tags for the random set get randomized through the ciphertext (random due to the random key and IV).
20302573
2031-To summarize, the observed first-order leakage if masking is on (FIgure 12b) is not of concern.
2574+To summarize, the observed first-order leakage if masking is on (second set of graphs) is not of concern.
20322575
20332576 ##### Results – FvsR PTX & AAD
20342577
@@ -2040,16 +2583,16 @@
20402583 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure13ab.png)
20412584 :--:
20422585
2043-| **Figure 13a:** Masking Off - 50k traces - **Figure 13b:** Masking On - 1M traces |
2586+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 1M traces |
20442587
20452588
20462589 ###### Interpretation
20472590
2048-There is no SCA leakage visible in both cases without masking (Figure 13a) and with masking turned on (Figure 13b).
2591+There is no SCA leakage visible in both cases without masking (first set of graphs) and with masking turned on (second set of graphs).
20492592 This is expected as the hash subkey generation doesn’t involve the plaintext and the AAD but only the key and IV.
20502593 Both the fixed and random set use the same static key and IV.
20512594
2052-This experiment was specifically done to check whether the leakage identified in Figure 6b and attributed to how the FPGA implementation tool maps the flip flops of the hash subkey register shares to the available FPGA logic slices.
2595+This experiment was specifically done to check whether the leakage identified in [i) SCA Evaluation of Generating the Hash Subkey H](#i-SCA-Evaluation-of-Generating-the-Hash-Subkey-H) and attributed to how the FPGA implementation tool maps the flip flops of the hash subkey register shares to the available FPGA logic slices.
20532596 As expected, the leakage peak is now gone.
20542597
20552598 ###### ii) SCA Evaluation of Encrypting the Initial Counter Block
@@ -2057,16 +2600,16 @@
20572600 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure14ab.png)
20582601 :--:
20592602
2060-| **Figure 14a:** Masking Off - 50k traces - **Figure 14b:** Masking On - 1M traces |
2603+| **Figure:** Masking Off - 50k traces - **Figure:** Masking On - 1M traces |
20612604
20622605
20632606 ###### Interpretation
20642607
2065-There is no SCA leakage visible in both cases without masking (Figure 14a) and with masking turned on (Figure 14b).
2608+There is no SCA leakage visible in both cases without masking (first set of graphs) and with masking turned on (second set of graphs).
20662609 This is expected as the encryption of the initial counter block and the subsequent computation of repeatedly used correction terms doesn’t involve the plaintext and the AAD but only the key and IV.
20672610 Both the fixed and random set use the same static key and IV.
20682611
2069-This experiment was specifically done to check whether the leakage identified in Figure 7b and attributed to how the FPGA implementation tool maps the multiplexers in front of the GHASH state registers to the available FPGA logic slices.
2612+This experiment was specifically done to check whether the leakage identified in [ii) SCA Evaluation of Encrypting the Initial Counter Block](#ii-SCA-Evaluation-of-Encrypting-the-Initial-Counter-Block) and attributed to how the FPGA implementation tool maps the multiplexers in front of the GHASH state registers to the available FPGA logic slices.
20702613 As expected, the leakage peak is now gone.
20712614
20722615 ###### iv) SCA Evaluation of Processing the PTX Block 0
@@ -2074,12 +2617,12 @@
20742617 ![](../images/caliptra-rtl/docs/images/GHASH_TVLA_Figure15ab.png)
20752618 :--:
20762619
2077-| **Figure 15a:** Masking Off - 100k traces - **Figure 15b:** Masking On - 1M traces |
2620+| **Figure:** Masking Off - 100k traces - **Figure:** Masking On - 1M traces |
20782621
20792622
20802623 ###### Interpretation
20812624
2082-With the masking turned off (Figure 15a), there is first-order leakage 1) at the beginning of the operation and 2) throughout the entire GHASH operation.
2625+With the masking turned off (first set of graphs), there is first-order leakage 1) at the beginning of the operation and 2) throughout the entire GHASH operation.
20832626
20842627 1. The leakage at the beginning of the operation is due to the input data (the plaintext) being written to an internal buffer register.
20852628 The AES cipher is operated in counter mode, meaning it doesn’t encrypt the input data but the counter value (incremented IV).
@@ -2088,7 +2631,7 @@
20882631 2. The GHASH operation then processes this ciphertext.
20892632 The observed leakage when the masking is off is expected.
20902633
2091-With the masking turned on (Figure 15b), the first-order leakage at the beginning of the operation remains visible. The reason for this is that the internal register buffering the previous input data is not masked.
2634+With the masking turned on (second set of graphs), the first-order leakage at the beginning of the operation remains visible. The reason for this is that the internal register buffering the previous input data is not masked.
20922635 This is of no concern as the leakage is not related to key or IV.
20932636
20942637 Another first-order leakage peak is visible between the AES encryption and the GHASH operation.
@@ -2258,14 +2801,63 @@
22582801
22592802 FW must set a last cycle flag before running the last iteration of the SHA engine. This could be the first “init” cycle, or the Nth “next” cycle. This flag allows HW to copy the final resulting hash output back to the source PCR.
22602803
2804+While a hash extend is in progress, HW accepts “next” commands only after the “init” command and ignores any command after the last cycle has been sent. “Restore” and the PCR hash generation start command are ignored until the hash extend completes. To abandon a hash extend before completion, FW must send a zeroize. The SHA512 key vault read controls cannot be written while the core, the key vault read, or the key vault write is busy, so the hash extend target cannot change while the result is written back. As for any SHA512 operation, a zeroize is required before a new “init” is accepted.
2805+
22612806 ### PCR signing
22622807
22632808 * PCR signing uses the key in key slot index 7 for PCR signing
22642809 * HW implements a HW function called GEN\_PCR\_HASH
22652810 * HW reads all the PCRs from all the PCR slots and hash extends them along with the NONCE that Caliptra FW provides
22662811 * PCR Hash = Hash(PCR[0], …, PCR[31], Nonce)
2812+ * The PCR hash is held in the SHA512 engine and is used directly by the ECC and ML-DSA PCR signing functions. A SHA512 zeroize clears it. FW must complete all ECC and ML-DSA PCR signing operations before sending the SHA512 zeroize. Because a zeroize is required before the next SHA512 operation (see [Command sequencing](#command-sequencing)), PCR signing must also complete before any other SHA512 operation is started. The required order is: GEN\_PCR\_HASH, then ECC and/or ML-DSA PCR signing, then SHA512 zeroize.
22672813 * HW also implements a HW function called SIGN\_PCR. This function takes the PCR digest that was generated by the previous routine and signs it using the key in key slot 7, following the same ECC sign flow defined in the [ECC](#ecc) section.
22682814 * The resulting PCR DIGEST is used only once for signing by the HW. If a new PCR signing is required, GEN\_PCR\_HASH needs to be redone.
2815+ * `ECC_CTRL.PCR_SIGN` must be written in the same write as the Signing command; otherwise ECC reports an error. Hardware clears the key loaded from key slot 7 when the PCR signing completes or fails.
2816+ * Writing `ECC_CTRL.PCR_SIGN` locks the ECC engine (`ECC_STATUS.READY` de-asserted) until firmware issues zeroize, so the key loaded from key slot 7 can only be used to sign the hardware-generated PCR digest. See [ECC zeroize](#ecc-zeroize).
2817+
2818+### ICCM write hash measurement (PCR4/PCR5)
2819+
2820+The SHA-512 accelerator (`sha512_acc_top`) includes an ICCM hash mode that provides hardware-only measurement of all data written to ICCM during firmware loading. This creates a tamper-evident record of what code actually landed in instruction memory, closing the gap between "firmware image was verified" and "firmware image was correctly copied."
2821+
2822+#### Overview
2823+
2824+Two dedicated PCR entries are used:
2825+
2826+| PCR | Name | Reset | Behavior |
2827+| :-- | :--- | :---- | :------- |
2828+| PCR4 | ICCM Current | Cleared on `fw_update_reset` (`iccm_unlock`) | Extended from zero on each firmware load — reflects only the currently running image |
2829+| PCR5 | ICCM Journey | Cleared only on cold reset (`cptra_pwrgood`) | Extended from previous value on each firmware load — accumulates a chain of all images ever loaded |
2830+
2831+
2832+Both PCR entries are write-protected: only the ICCM hash engine (`pv_write[1]`) can write nonzero values to PCR4 and PCR5. The normal SHA512/crypto PCR extend path (`pv_write[0]`) and firmware AHB writes are blocked from targeting these entries. Firmware may clear PCR4 or PCR5 to zero via `PCR_CTRL[n].clear` as a field escape hatch, but cannot write arbitrary values.
2833+
2834+#### Operation
2835+
2836+1. **Autonomous arming**: HW measures the ICCM region automatically. The existing per-bank ICCM-write snoop sets a sticky internal `iccm_armed` flag on the very first write it sees after reset (or after `fw_update_reset` releases the `iccm_unlock`-driven clear). On the same cycle, HW acquires the SHA accelerator lock via the LOCK register's `hwset` path, blocking any concurrent SOC access for the duration of the measurement. Firmware does not need to take any action to enable the feature; ROM simply performs the memcpy as normal.
2837+
2838+2. **ICCM write capture**: As ROM copies firmware from the mailbox to ICCM via CPU store instructions, each ICCM bank write is captured by the SHA accelerator and accumulated into a SHA-384 hash. The hash runs in parallel with the copy — no backpressure or stall. Data is hashed as little-endian 32-bit words (native CPU byte order). The combinational OR of the live snoop into the `iccm_mode` enable guarantees the very first dword is captured in the same cycle, before `iccm_armed` itself updates on the next clock edge.
2839+
2840+3. **Finalization on ICCM lock**: When ROM sets `INTERNAL_ICCM_LOCK`, the SHA accelerator finalizes the hash (padding and last compression), producing a 384-bit ICCM digest.
2841+
2842+4. **PCR extend**: An internal FSM then performs proper PCR extend operations:
2843+ - Reads PCR4 current value (zeros after clear), computes `SHA-384(PCR4 || ICCM_digest)`, writes result to PCR4
2844+ - Reads PCR5 current value, computes `SHA-384(PCR5 || ICCM_digest)`, writes result to PCR5
2845+ - The extend uses the same `sha512_core` instance with the same byte ordering as the normal PCR hash extend path, ensuring consistent results
2846+
2847+5. **Lock release**: After both PCR extends complete, the sticky `iccm_mode_done` flag latches (blocking re-trigger until the next `iccm_unlock`) and the SHA accelerator lock is released for normal firmware use.
2848+
2849+#### Security properties
2850+
2851+- HW-autonomous arming closes the bypass window where firmware could "forget" to enable the feature — the hash starts unconditionally on the first ICCM write the snoop sees
2852+- ICCM measurement is single-shot per boot cycle: once `iccm_mode_done` latches, firmware cannot re-trigger it to overwrite PCR4/PCR5
2853+- The hash captures the ground truth of ICCM write data at the memory bank interface — eliminating TOCTOU gaps between verification and copy
2854+- Skipping any step (trigger, copy, or lock) results in empty PCRs, causing attestation failure
2855+- The feature operates correctly regardless of `boot_flow_monitor_en` — if debug-unlocked tests skip ICCM mode, PCRs stay empty and attestation fails (no security bypass)
2856+- PCR4 clear mechanism (`pcr4_hwclr`) is tied to `iccm_unlock` (fires on `fw_update_reset`), ensuring fresh measurement on each firmware update
2857+
2858+#### Timing impact
2859+
2860+The SHA-384 computation runs in parallel with ROM's ICCM copy. Only finalization (~80 cycles) and the two PCR extend operations (~210 cycles total) occur after `ICCM_LOCK` is set. Total added latency: ~290 cycles, invisible to boot time.
22692861
22702862 ## Key vault
22712863
@@ -2292,9 +2884,9 @@
22922884 | Lock wr\[0\] | core_only_rst_b | Setting the lock wr field prevents the entry from being written by the microcontroller. Keys are always locked. After a lock is set, it cannot be reset until cptra_rst_b is de-asserted. |
22932885 | Lock use\[1\] | core_only_rst_b | Setting the lock use field prevents the entry from being used in any cryptographic blocks. After the lock is set, it cannot be reset until cptra_rst_b is de-asserted. |
22942886 | Clear\[2\] | cptra_rst_b | If unlocked, setting the clear bit causes KV to clear the associated entry. The clear bit is reset after entry is cleared. |
2295-| Copy\[3\] | cptra_rst_b | ENHANCEMENT: Setting the copy bit causes KV to copy the key to the entry written to Copy Dest field. |
2296-| Copy Dest\[8:4\] | cptra_rst_b | ENHANCEMENT: Destination entry for the copy function. |
2297-| Dest_valid\[16:9\] | hard_reset_b | KV entry can be used with the associated cryptographic block if the appropriate index is set. <br>\[0\] - HMAC KEY <br>\[1\] - HMAC BLOCK <br>\[2\] - MLDSA SEED <br>\[3\] - ECC PRIVKEY <br>\[4\] - ECC SEED <br>\[5\] - AES KEY <br>\[7:6\] - RSVD |
2887+| rsvd0\[3\] |||
2888+| rsvd1\[8:4\] |||
2889+| Dest_valid\[16:9\] | hard_reset_b | KV entry can be used with the associated cryptographic block if the appropriate index is set. <br>\[0\] - HMAC KEY <br>\[1\] - HMAC BLOCK <br>\[2\] - MLDSA SEED <br>\[3\] - ECC PRIVKEY <br>\[4\] - ECC SEED <br>\[5\] - AES KEY <br>\[6\] - MLKEM SEED <br>\[7\] - MLKEM MSG <br>\[8\] - AXI DMA DATA |
22982890 | last_dword\[20:19\] | hard_reset_b | Store the offset of the last valid dword, used to indicate the last cycle for read operations. |
22992891
23002892
@@ -2310,9 +2902,68 @@
23102902
23112903 Similarly, after programming the key vault write control and initiating the cryptographic function that generates the key to be written, FW needs to query the associated key vault write status to confirm that the requested key was generated and written successfully.
23122904
2905+While the crypto engine, key vault read, or key vault write blocks are active, the read and write control registers are locked. After reading the status register and confirming that the operation was successful, the next key vault control can be programmed.
2906+
23132907 When a key is read from the key vault, the API register is locked and any result generated from the cryptographic block is not readable by firmware. The digest can only be sent to the key vault by appropriately programming the key vault write controls. After the cryptographic block completes its operation, the lock is cleared and the key is cleared from the API registers.
23142908
2315-If multiple iterations of the cryptographic function are required, the key vault read and write controls must be programmed for each iteration. This ensures that the lock is set and the digest is not readable.
2909+Key vault read errors will prevent the crypto engine from accepting new commands. The engine will require zeroization in order to clear the error and resume normal operation.
2910+
2911+### Key vault key-length-mismatch detection
2912+
2913+Each cryptographic consumer that reads from KV performs a length check
2914+between the KV entry's stored `last_dword` and the consumer's
2915+`expected_key_size` port (derived from mode, e.g., HMAC-384 vs HMAC-512,
2916+or fixed by the consumer, e.g., ECC P-384, MLDSA/MLKEM seed, OCP LOCK
2917+MEK). The KV read-mux broadcasts each addressed entry's stored
2918+`last_dword` on `kv_rd_resp_t.entry_last_dword`, and every
2919+`kv_read_client` latches that value into a local `stored_last_dword`
2920+register.
2921+A stored entry *larger* than the
2922+consumer's expected size is accepted. A stored entry *smaller* than the
2923+consumer's expected size triggers `KV_RD_LEN_MISMATCH`. Access-control
2924+(`dest_valid` + `kv_read_rule_check`) still gates which slots each
2925+consumer may touch, so prefix use of an oversized entry does not
2926+widen attack surface.
2927+
2928+When mismatch fires, `error_code` is registered to `KV_RD_LEN_MISMATCH`
2929+and self-holds via the existing mux fall-through (cleared only by
2930+`rst_b` or `zeroize`). The length check enforces *how much of
2931+the slot is meaningful* and closes a key-substitution class where a
2932+shorter stored key would otherwise be silently zero-padded (or worse,
2933+consumed with undefined-tail bits) by a wider engine.
2934+
2935+**Two check-time modes**, selected by parameter `LEN_CHECK_AT_KEY_USE`:
2936+- `LEN_CHECK_AT_KEY_USE=0` (default) — check fires on `read_done` (KV
2937+ FSM's `KV_DONE` state), comparing `stored_last_dword` to the fixed
2938+ `expected_key_size` the consumer wires. Used by consumers whose
2939+ expected size is stable at KV-read time (ECC privkey/seed, AXI-DMA
2940+ MEK, MLDSA/MLKEM seeds and message).
2941+- `LEN_CHECK_AT_KEY_USE=1` — check fires on the consumer's
2942+ `check_key_size` strobe (typically at `INIT`/`START`/op-commit).
2943+ Used by consumers whose expected size is not stable until the op
2944+ commits (HMAC and AES, whose mode/key_len may be programmed after
2945+ the KV read completes).
2946+
2947+**HMAC** enables the check on the key path only. `hmac_key_kv_read`
2948+uses `LEN_CHECK_AT_KEY_USE=1` with `check_key_size = (init_reg |
2949+next_reg) & kv_key_data_present` and `expected_key_size =
2950+hmac_expected_key_size` (11 for HMAC-384, 15 for HMAC-512). The HMAC
2951+block is a message chunk, not a security-sized key, and legitimate
2952+consumers (notably the OCP LOCK HEK seed at `OCP_LOCK_HEK_NUM_DWORDS=8`
2953+dwords routed to `KV_DEST_IDX_HMAC_BLOCK`) may supply KV entries
2954+shorter than the mode's key size.
2955+
2956+**AES** derives `expected_key_size` from the runtime-selectable
2957+`CTRL_SHADOWED.key_len` (128/192/256 → 3/5/7), exposed to the CLP
2958+wrapper via `aes2caliptra.key_len`. The check is armed at
2959+`kv_key_done | keymgr_key.valid`, so any FW re-program of `key_len`
2960+that would create an entry-too-small condition is caught before AES
2961+samples the key. AES does not raise an interrupt on KV errors; FW
2962+must observe `AES_KV_RD_KEY_STATUS.ERROR` after the status VALID bit
2963+sets. The `AES_KV_RD_KEY_STATUS.ERROR` field encodes the KV error
2964+code (`KV_SUCCESS=0`, `KV_READ_FAIL=1`, `KV_RD_LEN_MISMATCH=3`).
2965+
2966+If multiple iterations of the cryptographic function are required, the key vault read and write controls must be programmed for each iteration. This ensures that the lock is set and the digest is not readable. For HMAC, an iteration is a complete `INIT` ... `LAST` operation: the lock is held across all of its blocks, the key vault read controls cannot be reprogrammed until it ends, and the key vault write status becomes valid only after the final block (see [Multi-block operations](#multi-block-operations)).
23162967
23172968 The following tables describe read, write, and status values for key vault blocks.
23182969
@@ -2334,7 +2985,10 @@
23342985 | ecc_pkey_dest_valid\[9\] | ECC PKEY is a valid destination. |
23352986 | ecc_seed_dest_valid\[10\] | ECC SEED is a valid destination. |
23362987 | aes_key_dest_valid\[11\] | AES KEY is a valid destination. |
2337-| rsvd\[31:12\] | Reserved field |
2988+| mlkem_seed_dest_valid\[12\] | MLKEM SEED is a valid destination. |
2989+| mlkem_msg_dest_valid\[13\] | MLKEM MSG is a valid destination. |
2990+| dma_data_dest_valid\[14\] | DMA DATA is a valid destination. |
2991+| rsvd\[31:15\] | Reserved field |
23382992
23392993
23402994 | KV Status Reg | Description |
@@ -2342,6 +2996,41 @@
23422996 | ready\[0\] | Key vault control is idle and ready for a command. |
23432997 | valid\[1\] | Requested flow is done. |
23442998 | error\[9:2\] | SUCCESS - 0x0 - Key Vault flow was successful <br>KV_READ_FAIL - 0x1 - Key Vault Read flow failed <br>KV_WRITE_FAIL - 0x2 - Key Vault Write flow failed |
2999+
3000+
3001+### Key vault endianness and byte ordering
3002+
3003+The Key Vault stores each entry as an array of 16 DWORDs (32-bit words), indexed KV\[0\] through KV\[15\]. The KV read and write clients perform byte and DWORD ordering transformations so that data written by one engine can be correctly consumed by another.
3004+
3005+The KV write client has a configurable parameter, `KV_WRITE_SWAP_DWORDS`, that controls DWORD ordering when writing result data into a KV entry. When set to 1 (default), the write client reverses DWORD order so that KV\[0\] holds the most-significant DWORD: KV\[offset\] = data\[N−1−offset\]. When set to 0, DWORDs are stored sequentially: KV\[offset\] = data\[offset\]. The KV read client always reads sequentially from KV\[0\] through KV\[15\]; each engine applies its own register-level mapping.
3006+
3007+#### Per-engine endianness conventions
3008+
3009+| Engine | Native endianness | KV write SWAP\_DWORDS | KV read register mapping | Notes |
3010+| :----- | :---------------- | :-------------------- | :----------------------- | :---- |
3011+| HMAC-512 | Big-endian | 1 (default) | Sequential: BLOCK\[d\] = KV\[d\], KEY\[d\] = KV\[d\] | Block read supports PAD and HMAC auto-padding. |
3012+| SHA-512 | Big-endian | 1 (default) | Sequential: BLOCK\[d\] = KV\[d\] | Block read supports PAD. |
3013+| ECC (P-384) | Big-endian | 1 (default) | Sequential: PRIVKEY\[d\] = KV\[d\], SEED\[d\] = KV\[d\] | -- |
3014+| AES | Little-endian | 0 | Byte swap per DWORD: key\_reg\[d\]\[b\] = KV\_data\[3−b\] | CTRL0.ENDIAN\_SWAP optionally swaps bytes in FW DATA\_IN/DATA\_OUT registers. |
3015+| ML-KEM | Little-endian | 0 | DWORD-reversed: SEED\_D\[d\] = KV\[N−1−d\], SEED\_Z\[i\] = KV\[2N−1−i\] | Shared key undergoes DWORD reversal in the ABR controller before the write client. |
3016+| ML-DSA | Little-endian | N/A (no KV write) | DWORD-reversed: SEED\[d\] = KV\[N−1−d\] | -- |
3017+
3018+
3019+**Write path:** HMAC, SHA-512, and ECC produce results with the most-significant DWORD at the highest internal index; the write client reversal (SWAP\_DWORDS=1) places the most-significant DWORD at KV\[0\]. AES stores its 128-bit (4 DWORD) output sequentially. The ML-KEM shared key is pre-reversed in the ABR controller (`mlkem_sharedkey_data[d] = shared_key[SHAREDKEY_NUM_DWORDS-1-d]`), producing the same KV layout as the big-endian engines despite using SWAP\_DWORDS=0.
3020+
3021+**Read path:** Big-endian engines (HMAC, SHA-512, ECC) use sequential mapping; register\[d\] receives KV\[d\]. AES applies a per-DWORD byte swap to convert from big-endian to its little-endian internal format. ML-KEM and ML-DSA reverse the DWORD index (`SEED[d]` is written when `kv_read_offset == N-1-d`), producing a full byte reversal of the original data.
3022+
3023+#### Firmware byte-ordering rules
3024+
3025+When firmware passes data between engines via software registers (without using KV), it must perform the following transformations. In this table, "big-endian" means the lowest-addressed register (index 0) holds the most-significant DWORD; "little-endian" means index 0 holds the least-significant DWORD. AES is little-endian but additionally byte-swaps each DWORD on the KV read path, so firmware must apply `BSWAP32` per DWORD when writing AES key registers directly.
3026+
3027+| Source → Destination | Transformation | Example |
3028+| :--- | :--- | :--- |
3029+| Big-endian → big-endian | Copy DWORDs directly | HMAC tag → ECC seed |
3030+| Big-endian → little-endian | Reverse DWORD order: DEST\[i\] = SRC\[N−1−i\] | HMAC tag → ML-KEM seed |
3031+| Big-endian → AES | Byte-swap each DWORD: AES\_KEY\[i\] = BSWAP32(src\[i\]) | HMAC tag → AES key |
3032+| Little-endian → AES | Reverse DWORDs and byte-swap each: AES\_KEY\[i\] = BSWAP32(src\[N−1−i\]) | ML-KEM shared key → AES key |
3033+| Little-endian → big-endian (non-AES) | Reverse DWORD order only: DEST\[i\] = src\[N−1−i\] | ML-KEM shared key → HMAC block |
23453034
23463035
23473036 ### De-obfuscation engine
@@ -2363,12 +3052,12 @@
23633052
23643053 ### Key vault de-obfuscation block operation
23653054
2366-A de-obfuscation engine (DOE) is used in conjunction with AES cryptography to de-obfuscate the UDS and field entropy.  
2367-
2368-1. The obfuscation key is driven to the AES key. The data to be decrypted (either obfuscated UDS or obfuscated field entropy) is fed into the AES data. 
2369-2. An FSM manually drives the AES engine and writes the decrypted data back to the key vault. 
2370-3. FW programs the DOE with the requested function (UDS or field entropy de-obfuscation), and the destination for the result. 
2371-4. After de-obfuscation is complete, FW can clear out the UDS and field entropy values from any flops until cptra\_pwrgood de-assertion.  
3055+A de-obfuscation engine (DOE) is used in conjunction with AES cryptography to de-obfuscate the UDS and field entropy and HEK seed.  
3056+
3057+1. The obfuscation key is wired to DOE engine. The data to be decrypted (either obfuscated UDS, obfuscated field entropy, or obfuscated HEK seed) is fed into the DOE data.
3058+2. An FSM manually drives the DOE engine and writes the decrypted data back to the key vault. 
3059+3. FW programs the DOE with the requested function (UDS, field entropy, or HEK seed de-obfuscation), and the destination for the result. 
3060+4. After de-obfuscation is complete, FW can clear out the UDS, field entropy, and HEK seed values from any flops until cptra\_pwrgood de-assertion.  
23723061
23733062 The following tables describe DOE register and control fields.
23743063
@@ -2381,19 +3070,280 @@
23813070
23823071 | DOE Ctrl Fields | Reset | Description |
23833072 | :--------------- | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------- |
2384-| COMMAND\[1:0\] | Cptra_rst_b | 2’b00 Idle <br>2’b01 Run UDS flow <br>2’b10 Run FE flow <br>2’b11 Clear Obf Secrets |
2385-| DEST\[4:2\] | Cptra_rst_b | Destination register for the result of the de-obfuscation flow. Field entropy writes into DEST and DEST+1 <br>Key entry only, can’t go to PCR . |
3073+| CMD\[1:0\] | Cptra_rst_b | 2’b00 Idle <br>2’b01 Run UDS flow <br>2’b10 Run FE flow <br>2’b11 Clear Obf Secrets |
3074+| DEST\[6:2\] | Cptra_rst_b | Destination register for the result of the de-obfuscation flow. Field entropy writes into DEST and DEST+1 <br>Key entry only, can’t go to PCR . |
3075+| CMD_EXT\[8:7\] | Cptra_rst_b | 2’b00 Idle (or running a standard, non-extended command) <br>2’b01 Run OCP LOCK HEK seed flow <br>2’b10 RESERVED <br>2’b11 RESERVED |
23863076
23873077
23883078 ### Key vault de-obfuscation flow 
23893079
2390-1. ROM loads IV into DOE. ROM writes to the DOE control register the destination for the de-obfuscated result and sets the appropriate bit to run UDS and/or the field entropy flow. 
3080+1. ROM loads IV into DOE. ROM writes to the DOE control register the destination for the de-obfuscated result and sets the appropriate bit to run UDS, field entropy, and/or HEK seed flow. 
23913081 2. DOE state machine takes over and loads the Caliptra obfuscation key into the key register. 
23923082 3. Next, either the obfuscated UDS or field entropy are loaded into the block register 4 DWORDS at a time. 
23933083 4. Results are written to the KV entry specified in the DEST field of the DOE control register. 
23943084 5. State machine resets the appropriate RUN bit when the de-obfuscated key is written to KV. FW can poll this register to know when the flow is complete.
23953085 6. The clear obf secrets command flushes the obfuscation key, the obfuscated UDS, and the field entropy from the internal flops. This should be done by ROM after both de-obfuscation flows are complete.
23963086
3087+## Key vault boot flow transition enforcement
3088+
3089+**Disabled until reworked:** the monitor instance is commented out and its KV/control/fault connections are tied inactive in all builds. Monitor-specific tests, assertions, coverage, and TB enable hooks are disabled. ICCM region CSRs remain but cannot raise feature faults. The policy below is reference only.
3090+
3091+The Key Vault Boot Flow Transition Enforcement feature provides hardware-enforced integrity monitoring and access control for DICE key derivation across boot phase transitions (ROM->FMC->RT). It detects ICCM code execution transitions, validates key vault state at each boundary, and atomically applies lock/clear enforcement to key slots.
3092+
3093+### Overview
3094+
3095+The feature consists of three cooperating blocks:
3096+
3097+1. **Boot Flow Monitor** (in `caliptra_top`): Detects ROM->FMC and FMC->RT transitions by observing ICCM memory bank read enables against programmed address regions.
3098+2. **KV Monitor** (in `kv`): Validates dest_valid permissions and crypto write counts on DICE key slots at each transition boundary.
3099+3. **KV Enforcement** (in `kv`): Atomically applies lock_wr, lock_use, and slot clearing at each transition.
3100+
3101+*Figure: KV Boot Flow Transition Enforcement high-level block diagram*
3102+
3103+![](../images/caliptra-rtl/docs/images/kv_monitor.png)
3104+
3105+### Boot flow monitor
3106+
3107+The boot flow monitor detects firmware execution phase transitions by spying the ICCM memory interface. It compares bank-level read addresses against programmed FMC and RT region boundaries.
3108+
3109+#### ICCM region registers
3110+
3111+Four shadow-hardened registers define the FMC and RT code regions within ICCM address space:
3112+
3113+| Register | Address | Description |
3114+| :------- | :------ | :---------- |
3115+| INTERNAL_ICCM_FMC_START_ADDR | 0x30030650 | Start address of FMC region (18-bit ICCM-relative) |
3116+| INTERNAL_ICCM_FMC_END_ADDR | 0x30030654 | End address of FMC region (inclusive) |
3117+| INTERNAL_ICCM_RT_START_ADDR | 0x30030658 | Start address of RT region (18-bit ICCM-relative) |
3118+| INTERNAL_ICCM_RT_END_ADDR | 0x3003065C | End address of RT region (inclusive) |
3119+| INTERNAL_ICCM_REGION_LOCK | 0x30030660 | W1S lock -- once set, address registers cannot be modified until reset |
3120+
3121+
3122+These registers use the `caliptra_prim_subreg_shadow` primitive for glitch hardening:
3123+- **2-phase write protocol**: Each register must be written twice with the same value to commit. A single write updates only the shadow copy; the second matching write commits to the primary register.
3124+- **Phase-clear-on-read**: A read operation resets the write phase to 0, preventing stale partial writes from persisting.
3125+- **Error lockout**: If the shadow and committed copies diverge (storage fault), all further writes are blocked until reset.
3126+- **Error reporting**: Storage faults assert `CPTRA_HW_ERROR_FATAL.shadow_storage_err[5]`. Phase-1/phase-0 mismatches assert `CPTRA_HW_ERROR_NON_FATAL.shadow_update_err[3]`.
3127+
3128+The effective lock for the boot flow monitor is `iccm_region_lock & iccm_all_shadows_committed` -- both the lock register must be set AND all four address registers must have completed their 2-phase writes.
3129+
3130+#### Transition detection
3131+
3132+The monitor uses MuBi4-encoded signals for glitch resistance:
3133+
3134+| Signal | Encoding | Meaning |
3135+| :----- | :------- | :------ |
3136+| `boot_flow_fmc` | MuBi4True/False | CPU has begun executing from the FMC region |
3137+| `boot_flow_rt` | MuBi4True/False | CPU has begun executing from the RT region |
3138+| `boot_flow_error` | MuBi4True/False | Fatal error detected in boot flow |
3139+
3140+
3141+Transitions are one-way: once `boot_flow_fmc` becomes True, it remains True until reset. The monitor fires on the first ICCM read within the FMC region (after effective lock is set), and similarly for RT.
3142+
3143+#### Error conditions
3144+
3145+`boot_flow_error` is asserted (fatal) when any of the following occur:
3146+- ICCM fetch while region lock is not set or shadow registers are not committed
3147+- RT region fetch while `boot_flow_fmc` is False (illegal ROM->RT jump -- the RT transition is gated on FMC, so this fires the error without producing a transient `boot_flow_rt` pulse)
3148+- ICCM fetch outside both the FMC and RT programmed regions after region lock is set (out-of-range execution)
3149+- Any boot flow MuBi4 signal enters an invalid (non-True, non-False) encoding state
3150+
3151+#### Simulation support
3152+
3153+In simulation, `boot_flow_monitor_en` defaults to 0 (disabled). The testbench overrides this signal with a `force` when testing the feature. In hardware, the monitor is enabled when `debug_locked` is asserted AND `scan_mode` is deasserted. The monitor is disabled when debug is unlocked (to allow JTAG ICCM access and fake-ROM flows) and during scan mode (to prevent false transitions from clock-override activity on the ICCM banks).
3154+
3155+### KV monitor
3156+
3157+At each boot phase transition, the KV monitor validates that the listed DICE and PCR quote key slots are correctly populated. Optional feature keys (Stable Owner Key, OCP Lock keys) are excluded from monitoring because they are conditionally derived and do not participate in the DICE trust chain. A mismatch triggers `kv_monitor_alert`, which escalates to `CPTRA_HW_ERROR_FATAL.kv_error[4]` and flushes all key entries.
3158+
3159+#### ROM->FMC checks (on `enter_fmc`)
3160+
3161+| Slot | Name | Expected dest_valid |
3162+| :--- | :--- | :------------------ |
3163+| 0 | SI_IDEV | AES_KEY |
3164+| 1 | SI_LDEV | AES_KEY |
3165+| 2 | KEY_LADDER | HMAC_KEY |
3166+| 6 | FMC_CDI | HMAC_KEY &#124; MLDSA_SEED &#124; ECC_SEED |
3167+| 7 | PCR_ECDSA | ECC_PKEY |
3168+| 8 | PCR_MLDSA | MLDSA_SEED |
3169+| 13 | FMC_ECDSA | ECC_PKEY |
3170+| 14 | FMC_MLDSA | MLDSA_SEED |
3171+
3172+
3173+Additionally, per-slot crypto write counters verify **exact** expected derivation counts:
3174+- Slot 6 (FMC_CDI): == 4 writes (IDevID CDI + LDevID intermediate + LDevID CDI + FMC Alias CDI)
3175+- Slot 7 (PCR_ECDSA): == 2 writes (IDevID ECC keygen + PCR quote ECC keygen)
3176+- Slot 8 (PCR_MLDSA): == 2 writes (IDevID MLDSA keygen + PCR quote MLDSA keygen)
3177+
3178+The existing counters remain on accumulators 6/7/8, not the relocated FMC aliases. Slots 13/14 are checked for their final permissions and protected by phase locks; slot 14 may also hold temporary HEK material earlier in ROM. This policy requires the ROM allocation with dedicated quote keys in 7/8 and FMC aliases in 13/14.
3179+
3180+An exact match (rather than a minimum threshold) detects both truncated DICE chains (too few writes, indicating a skipped derivation step) and glitch-replayed operations (too many writes, which could overwrite the final safe key with an earlier intermediate value such as raw UDS).
3181+
3182+Write counters are 3-bit saturating counters that reset only on hard reset (`cptra_pwrgood`) or `flush_keyvault`, persisting across warm and FW update resets. Since ROM does not re-derive DICE keys on warm or FW update reset, the counters retain their cold-boot values and pass the exact-match check on subsequent transitions.
3183+
3184+#### FMC->RT checks (on `enter_rt`)
3185+
3186+| Slot | Name | Expected dest_valid |
3187+| :--- | :--- | :------------------ |
3188+| 4 | RT_CDI | HMAC_KEY &#124; MLDSA_SEED &#124; ECC_SEED |
3189+| 5 | RT_ECDSA | ECC_PKEY |
3190+| 9 | RT_MLDSA | MLDSA_SEED |
3191+
3192+
3193+### KV enforcement
3194+
3195+Enforcement is applied continuously based on the current boot phase and atomically at transitions.
3196+
3197+#### Lock enforcement (continuous)
3198+
3199+| Condition | Slots affected | Action |
3200+| :-------- | :------------- | :----- |
3201+| `boot_flow_fmc` = True | 0, 1, 2, 6, 7, 8, 13, 14 | `lock_wr` asserted via hwset (HW-driven, cannot be cleared by SW) |
3202+| `boot_flow_fmc` = True | 7, 8 | `lock_use` asserted via hwset (PCR quote-only keys) |
3203+| `boot_flow_rt` = True | 4, 5, 9 | `lock_wr` asserted via hwset |
3204+| `boot_flow_rt` = True | 6, 13, 14 | `lock_use` asserted via hwset (FMC keys cannot be used in RT) |
3205+
3206+
3207+PCR quote keys in slots 7/8 remain accessible through the dedicated PCR signing ports, which are unchanged. Their `lock_use` bits block ordinary KV client access from FMC onward, while the FMC aliases in 13/14 remain usable by FMC until the RT transition.
3208+
3209+The `lock_wr` and `lock_use` fields have `hwset` property in the register definition, allowing hardware to set them without firmware intervention. Once set, they can only be cleared by `core_only_rst_b` de-assertion.
3210+
3211+#### Slot clearing (atomic, on cold-boot transition edges)
3212+
3213+Unused-slot clearing runs only during cold boot, identified by both read-only `CPTRA_RESET_REASON.WARM_RESET` and `CPTRA_RESET_REASON.FW_UPD_RESET` being zero. Warm-reset and firmware-update transitions do not generate `boot_flow_key_clear` requests for any slot. Their key data, `dest_valid`, and `last_dword` are not modified by transition cleanup; firmware operations and independent clear/flush paths may still change them. Monitor checks, phase tracking, and lock enforcement remain active independently of this cold-boot gate.
3214+
3215+**DICE and runtime slots** — cold-boot transition behavior:
3216+
3217+| Slot | Purpose | ROM→FMC | FMC→RT |
3218+| :--- | :------ | :------ | :----- |
3219+| 0 | SI_IDEV | Preserved | Preserved |
3220+| 1 | SI_LDEV | Preserved | Preserved |
3221+| 2 | KEY_LADDER | Preserved | Preserved |
3222+| 3 | TMP | Cleared | Cleared |
3223+| 4 | RT_CDI | Cleared | Preserved |
3224+| 5 | RT_ECDSA | Cleared | Preserved |
3225+| 6 | FMC_CDI | Preserved | Preserved |
3226+| 7 | PCR_ECDSA | Preserved | Preserved |
3227+| 8 | PCR_MLDSA | Preserved | Preserved |
3228+| 9 | RT_MLDSA | Cleared | Preserved |
3229+| 10–11 | DPE scratch | Cleared | Cleared |
3230+| 12 | Exported DPE CDI | Cleared | Cleared |
3231+| 13 | FMC_ECDSA | Preserved | Preserved |
3232+| 14 | FMC_MLDSA | Preserved | Preserved |
3233+
3234+
3235+**Conditionally-preserved slots** — cold-boot behavior depends on active mode:
3236+
3237+| Slot | Purpose | Default (no optional features) | `stable_owner_key_en` | `ocp_lock_mode_en` |
3238+| :--- | :------ | :----------------------------- | :-------------------- | :----------------- |
3239+| 15 | Stable Owner Key | Cleared | Preserved | Cleared (mutually exclusive) |
3240+| 16 | MDK | Cleared | Cleared | Preserved |
3241+| 17–21 | Unused OCP range | Cleared | Cleared | Cleared |
3242+| 22 | HEK seed | Cleared | Cleared | Preserved |
3243+| 23 | MEK | Cleared | Cleared | Cleared (DMA-accessible) |
3244+
3245+
3246+Clearing destroys the key data and resets `dest_valid` and `last_dword` for the affected slots.
3247+
3248+#### Conditional slot preservation
3249+
3250+Two optional Caliptra features populate KV slots that must survive cold-boot transitions when the feature is active, but must be cleared when inactive. These slots are **not monitored** (no dest_valid checks, no write counters) — the monitor is exclusively for DICE keys. Only the enforcement block (slot clearing) handles them conditionally. Warm and firmware-update re-entry skip unused-slot clearing regardless of these feature enables.
3251+
3252+**Stable Owner Key (Slot 15)**
3253+
3254+The Stable Owner Root Key is conditionally derived by ROM when all three conditions are met:
3255+
3256+- `SUBSYSTEM_MODE_en` = 1 (Caliptra operating in subsystem mode)
3257+- `OCP_LOCK_MODE_en` = 0 (OCP Lock feature is not active)
3258+- `SS_FW_FEATURE_CFG.STABLE_OWNER_KEY_EN` = 1 (SoC configuration, written prior to `CPTRA_FUSE_WR_DONE`, enabling the stable owner key feature)
3259+
3260+The combined signal `stable_owner_key_en` is computed in `soc_ifc_top` and routed to the Key Vault. When active, slot 15 is excluded from `boot_flow_key_clear` at both cold-boot ROM-to-FMC and FMC-to-RT transitions. When inactive, slot 15 is cleared at those cold-boot transitions.
3261+
3262+**OCP Lock Keys (Slots 16 and 22)**
3263+
3264+OCP Lock mode is supported only when `CALIPTRA_MODE_SUBSYSTEM` is defined. In Passive mode, the incoming strap is ignored and `ocp_lock_mode_en` is forced to 0.
3265+
3266+When OCP Lock mode is enabled (`ocp_lock_mode_en` = 1 from the `ss_ocp_lock_en` strap), DOE populates slot 16 (MDK) and slot 22 (HEK seed) before ROM runs. FMC and RT firmware require these keys for EPK, VEK, and MEK derivation in OCP Lock flows.
3267+
3268+When `ocp_lock_mode_en` is active, slots 16 and 22 are excluded from clearing at both cold-boot transitions. When inactive, they are cleared at those cold-boot transitions.
3269+
3270+**Slot 23 (MEK) is always cleared at cold-boot transitions** regardless of `ocp_lock_mode_en`. This prevents early-stage key material from surviving in a DMA-accessible slot. Warm and firmware-update transitions do not clear it through this mechanism; runtime firmware remains responsible for its OCP Lock key lifecycle.
3271+
3272+Only the specific slots that ROM or FMC actually derive (16 and 22) are preserved during cold boot — not the entire OCP Lock range (16–23). Slots 17–21 and 23 are cleared on cold-boot transitions.
3273+
3274+**Mutual exclusion**: Stable Owner Key and OCP Lock are mutually exclusive by construction — `stable_owner_key_en` includes `~OCP_LOCK_MODE_en` in its definition. When OCP Lock is enabled, slot 15 is cleared at cold-boot transitions even if `SS_FW_FEATURE_CFG.STABLE_OWNER_KEY_EN` = 1.
3275+
3276+#### Error escalation
3277+
3278+Any of the following trigger all key entries to be flushed:
3279+- `boot_flow_error` = MuBi4True
3280+- `kv_monitor_alert` (dest_valid mismatch or write count violation)
3281+- `kv_multi_write_err` (existing: multiple crypto engines writing simultaneously)
3282+
3283+The error is reported as `CPTRA_HW_ERROR_FATAL.kv_error[4]`, which is unmasked and always triggers an interrupt.
3284+
3285+### DOE lockdown
3286+
3287+Once the boot flow monitor detects that execution has transitioned to FMC or RT (i.e., `boot_flow_fmc` or `boot_flow_rt` is True), the DOE command register is forcibly cleared via `doe_cmd_lock`. This prevents any new de-obfuscation commands from being issued after the DICE key derivation phase is complete, closing the window for an attacker to re-derive secrets using the obfuscation key.
3288+
3289+### Error register summary
3290+
3291+| Register | Bit | Field | Trigger |
3292+| :------- | :-- | :---- | :------ |
3293+| CPTRA_HW_ERROR_FATAL | 4 | kv_error | Boot flow error OR KV monitor alert |
3294+| CPTRA_HW_ERROR_FATAL | 5 | shadow_storage_err | ICCM region shadow register storage fault |
3295+| CPTRA_HW_ERROR_FATAL | 7 | rv_dcls_err | RISC-V dual-core lockstep (DCLS) mismatch; normal reporting enabled by `CPTRA_HW_CONFIG.DCLS_en` in both profiles |
3296+| CPTRA_HW_ERROR_FATAL | 8 | dccm_wr_readback_err | DCCM write-readback mismatch detected (store corrupted); maskable via `internal_hw_error_fatal_mask` |
3297+| CPTRA_HW_ERROR_NON_FATAL | 3 | shadow_update_err | ICCM region shadow register phase mismatch |
3298+
3299+
3300+### DICE slot assignments
3301+
3302+The following table documents the key vault slot assignments used by the DICE key derivation chain (defined in `kv_defines_pkg.sv`):
3303+
3304+| Slot | Constant | Purpose |
3305+| :--- | :------- | :------ |
3306+| 0 | KV_SLOT_SI_IDEV | Silicon IDevID private key |
3307+| 1 | KV_SLOT_SI_LDEV | Silicon LDevID private key |
3308+| 2 | KV_SLOT_KEY_LADDER | Key ladder intermediate |
3309+| 4 | KV_SLOT_RT_CDI | Runtime CDI |
3310+| 5 | KV_SLOT_RT_ECDSA | Runtime ECDSA private key |
3311+| 6 | KV_SLOT_FMC_CDI | FMC CDI (accumulates through DICE chain) |
3312+| 7 | KV_SLOT_PCR_ECDSA | PCR quote ECDSA private key |
3313+| 8 | KV_SLOT_PCR_MLDSA | PCR quote MLDSA seed |
3314+| 9 | KV_SLOT_RT_MLDSA | Runtime MLDSA private key |
3315+| 13 | KV_SLOT_FMC_ECDSA | FMC ECDSA private key |
3316+| 14 | KV_SLOT_FMC_MLDSA | FMC MLDSA seed |
3317+
3318+
3319+### Conditionally-preserved slot assignments
3320+
3321+The following slots are populated by optional features and conditionally preserved by enforcement (but not monitored):
3322+
3323+| Slot | Constant | Feature | Preserved when |
3324+| :--- | :------- | :------ | :------------- |
3325+| 15 | KV_SLOT_STABLE_OWNER | Stable Owner Root Key | `stable_owner_key_en` (subsystem mode, strap[3][0]=1, OCP Lock off) |
3326+| 16 | OCP_LOCK_RT_OBF_KEY_KV_SLOT | MDK (runtime obfuscation key) | `ocp_lock_mode_en` |
3327+| 22 | OCP_LOCK_HEK_SEED_KV_SLOT | HEK seed | `ocp_lock_mode_en` |
3328+| 23 | OCP_LOCK_MEK_KV_SLOT | MEK (key release) | **Never** (always cleared — DMA-accessible, security risk) |
3329+
3330+
3331+### ROM programming sequence
3332+
3333+ROM must perform the following steps before jumping to FMC:
3334+
3335+1. Complete all DICE key derivations (DOE decrypt, HMAC, ECC keygen, MLDSA keygen)
3336+2. Program ICCM region registers with 2-phase writes:
3337+ - Write `INTERNAL_ICCM_FMC_START_ADDR` twice with the same value
3338+ - Write `INTERNAL_ICCM_FMC_END_ADDR` twice with the same value
3339+ - Write `INTERNAL_ICCM_RT_START_ADDR` twice with the same value
3340+ - Write `INTERNAL_ICCM_RT_END_ADDR` twice with the same value
3341+3. Set `INTERNAL_ICCM_REGION_LOCK` (W1S) -- this arms the boot flow monitor
3342+4. Jump to FMC entry point in ICCM
3343+
3344+The first instruction fetch from the FMC region triggers the ROM->FMC transition, at which point the KV monitor validates slot state and enforcement atomically applies locks and clears.
3345+
3346+
23973347 ## Data vault
23983348
23993349 Data vault is a set of generic scratch pad registers with specific lock functionality and clearable on cold and warm resets.
@@ -2403,6 +3353,141 @@
24033353 * 4B scratchpad registers that are lockable but cleared on cold reset (8 registers)
24043354 * 4B scratchpad registers that are lockable but cleared on warm reset (10 registers)
24053355 * 4B scratchpad registers that are cleared on warm reset (8 registers)
3356+
3357+
3358+## OCP LOCK Hardware Architecture
3359+
3360+### Overview
3361+The following hardware and ROM/FW enhancements support the OCP L.O.C.K. (a.k.a. **OCP LOCK**) flows defined for SSD applications. The specification is available here:
3362+[OCP LOCK Spec](https://chipsalliance.github.io/Caliptra/ocp-lock/specification/HEAD)
3363+
3364+---
3365+
3366+### Additional Registers, Straps, and Macros for OCP LOCK
3367+
3368+- **`SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS`**
3369+ A status/control bit used to enforce the new key Vvult (KV) rules required by OCP LOCK. Write-1-to-set, meaning that, once-enabled, OCP LOCK functionality will persist until the register is cleared by a cold reset. See the dedicated section below for details on the behaviors this register enables.
3370+
3371+- **`ss_ocp_lock_en`** (constant-value input strap) with a corresponding bit in **`CPTRA_HW_CONFIG`** register named **`OCP_LOCK_MODE_en`**:
3372+ - Enables Caliptra ROM to perform OCP LOCK operations (e.g., using DOE for HEK seed de-obfuscation, Key Release via AXI DMA).
3373+ - Allows the ROM to set `SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS`.
3374+ - `ss_ocp_lock_en` is a strap pin and **must be driven with a constant value by the integrator**.
3375+ - `CPTRA_HW_CONFIG` register samples this strap and store its value in `OCP_LOCK_MODE_en` bit
3376+ - This bit is only reflected in CPTRA_HW_CONFIG if CALIPTRA_MODE_SUBSYSTEM is defined
3377+
3378+- **HEK seed fuse register**
3379+ Holds the **obfuscated HEK seed**. ROM is responsible for performing the operation to de-obfuscate the HEK seed.
3380+
3381+- **Key release address and size straps**
3382+ Writable until `FUSE_WR_DONE`, then locked (same as fuses and other subsystem-mode straps).
3383+ - **Address strap** (`strap_ss_key_release_base_addr`): full destination address for key release; in OCP LOCK this is the destination for the MEK to be written. Firmware can derive the SFR base from this value as needed.
3384+ - **Size strap** (`strap_ss_key_release_key_size`): byte-count (dword-aligned count is required by HW) of the key to program to the destination address via the key release operation. Strap input values are forced to a dword value by hardware. If control firmware updates this value (prior to FUSE_WR_DONE being set), it must use a dword-aligned value.
3385+
3386+Refer to the [Caliptra Integration Spec](https://github.com/chipsalliance/caliptra-rtl/blob/main/docs/CaliptraIntegrationSpecification.md) for more details about macros and strap pins.
3387+
3388+---
3389+
3390+### `SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS` Register Bit
3391+
3392+**When/How it is set**
3393+- Set by **Caliptra ROM** after performing OCP LOCK-related derivations (HEK, MDK, etc.).
3394+- Can be set **iff** (`ss_ocp_lock_en` is set to 1 **AND** `CALIPTRA_MODE_SUBSYSTEM` is defined).
3395+ - Once set, a value of 1 persists until the register is cleared by cold reset.
3396+
3397+**Enforcements/Effects**
3398+- Reserves **key vault slots 0–15** for *standard* use-cases.
3399+- Reserves **key vault slots 16–23** for *OCP LOCK* use-cases.
3400+ - Key Vault slot 16 (KV16) is reserved for holding the MDK
3401+ - Key Vault slot 23 (KV23) is reserved for holding the MEK
3402+- Blocks interactions between *standard* slots and *LOCK* slots. This means that any crypto operation that uses a Key Vault input value (e.g. for Key, Block, Seed inputs) may not write the output to a Key Vault from a different region. E.g., When `SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS` is set, HMAC may not perform an operation that uses Key Vault slot 8 as BLOCK input and writes the output TAG to Key Vault slot 17.
3403+- Enables **Key Release via AXI DMA**.
3404+- Enables **AES engine to write output to Key Vault, which must use KV23**.
3405+
3406+> **Note:** If `SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS` is `1`, it also implies `ss_ocp_lock_en` and `CALIPTRA_MODE_SUBSYSTEM` are also `1`.
3407+
3408+---
3409+
3410+### AES Write Path
3411+
3412+- **MEK** is the final OCP LOCK key. It is **decrypted and stored in KV23**. After decryption, MEK may be transferred to its destination (as specified by the input strap) **via AXI DMA**.
3413+- OCP LOCK requires both the **AES write path** and a **DMA path** to the MEK destination.
3414+- **Hardware enforcement:** MEK is written to **KV23**. Hardware recognizes the MEK generation request if there is an **AES-ECB decrypt** operation with **KV16 (MDK)** as the AES-ECB key and routes the result accordingly. In this case, output of the decrypted plaintext via the AES dataout register API is blocked. Any Key Vault write operation requested for the AES output that does not meet these requirements results in a Key Vault write failure status.
3415+
3416+---
3417+
3418+### Key Vault Access Rules & Filtering (when `LOCK_IN_PROGRESS` is set)
3419+
3420+- **KV23 (MEK destination)**: **write-restricted to AES only**.
3421+- **KV22 (HEK)**: **locked for writes until warm reset** (ROM requirement).
3422+- **KV16 (MDK)**: **locked for writes until warm reset** (ROM requirement).
3423+- If OCP LOCK mode is enabled:
3424+ - **KV23 must not be used** as input to other crypto operations—**only** as a **Key Release** source.
3425+ - **AES-ECB decrypt** with **key = KV16** **must** have **dest = KV23**; otherwise the destination is **FW**.
3426+ *Rationale:* Prevents malicious FW from writing known values into other KV slots via AES.
3427+- **Additional KV behaviors**
3428+ - On write, hardware validates that the **destination** is legal for the **source/read**. If not valid, the Key Vault write operation returns a failing status.
3429+ - **No parallel crypto operations** permitted for cryptographic blocks with access to Key Vault. KV does not track this; Caliptra enforces this rule by evaluating each block's busy status indicator and signaling violations through the [CPTRA_HW_ERROR_FATAL](https://chipsalliance.github.io/caliptra-rtl/main/internal-regs/?p=clp.soc_ifc_reg.CPTRA_HW_ERROR_FATAL) register and corresponding interrupt at Caliptra top level design.
3430+
3431+---
3432+
3433+### HEK Seed De‑obfuscation
3434+
3435+- Executed by **Caliptra ROM**. The DOE supports a HEK deobfuscation command that may be executed only once during a boot cycle. If Caliptra ROM does not run this flow to produce the HEK seed, it should run the flow with a dummy Key Vault slot to lock against future erroneous uses.
3436+- **Hardware-supported HEK seed Deobfuscation Path:** Ratchet Fuse Register (**obfuscated HEK seed**) → **DOE** (with `OBF_KEY`) → **KV slot 22** (de-obfuscated seed).
3437+- Caliptra ROM shall lock **KV22** for writes immediately it has derived the **HEK** into that slot.
3438+
3439+---
3440+
3441+### Key Release
3442+
3443+Caliptra's AXI DMA supports a hardware path to write **KV23 (MEK)** to the SoC via the AXI manager interface. The following rules constrain this operation:
3444+- Allowed **only** when `SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS` (sticky **W1SET**) is set by Caliptra ROM.
3445+- Destination and size must match the values from the straps:
3446+ - `strap_ss_key_release_base_addr`
3447+ - `strap_ss_key_release_key_size`
3448+
3449+---
3450+
3451+### Additional Security Hardening Specific to OCP LOCK Enhancements
3452+
3453+**Scan/Debug Protections**
3454+- Flush **DMA FIFOs** to prevent leakage of secrets via scan chain.
3455+- Flush **AES ↔ KV** interface.
3456+
3457+**AES/KV/DMA Robustness**
3458+- **AES → KV write path:** The key can't be written to key vault unless key_size bytes are decrypted by AES.
3459+- Validate **DMA `key_size`**; **error** if `key_size > 512b`.
3460+- Avoid hangs when **`key_size` != KV read DWORD count**:
3461+ - On KV reads, if `key_size` is **smaller** than the KV entry, **drop extra data** (do not push to FIFO).
3462+- **DMA KV read error**: Raised on the **first transfer cycle** from KV to DMA; DMA transitions immediately to **`DMA_ERROR`** without issuing an AXI transfer.
3463+- **KV write enable sourced from AES** (during OCP LOCK) so it **cannot** be modified mid-transfer.
3464+- **Enable AES ↔ KV write path** only if `SS_OCP_LOCK_CTRL.LOCK_IN_PROGRESS` is set.
3465+
3466+
3467+
3468+## Fatal hardware errors
3469+
3470+The `CPTRA_HW_ERROR_FATAL` register aggregates all fatal hardware error conditions. Assertion of any bit drives the SoC `cptra_error_fatal` interrupt pin (unless the bit is masked by `internal_hw_error_fatal_mask`). Once the interrupt is asserted, clearing the register bit does **not** deassert the interrupt — only a Caliptra reset clears a fatal error interrupt. All fields are sticky (RW1C by Caliptra and SoC).
3471+
3472+| Bit | Field | Maskable | Trigger |
3473+| :-- | :---- | :------- | :------ |
3474+| 0 | iccm_ecc_unc | Yes (`mask_iccm_ecc_unc`) | Uncorrectable double-bit ECC error in ICCM |
3475+| 1 | dccm_ecc_unc | Yes (`mask_dccm_ecc_unc`) | Uncorrectable double-bit ECC error in DCCM |
3476+| 2 | nmi_pin | Yes (`mask_nmi_pin`) | NMI asserted by WDT Timer2 timeout |
3477+| 3 | crypto_err | No | Multiple concurrent cryptographic operations using the Key Vault |
3478+| 4 | kv_error | No | Inactive: boot-flow monitoring is hard-disabled |
3479+| 5 | shadow_storage_err | No | Inactive: ICCM boot-flow region fault reporting is disabled |
3480+| 6 | fsm_error | No | Sparse-encoded security FSM entered an invalid/illegal state (fault-injection/glitch detection) |
3481+| 7 | rv_dcls_err | No | RISC-V dual-core lockstep (DCLS) mismatch; normal reporting enabled by `CPTRA_HW_CONFIG.DCLS_en` in both profiles |
3482+| 8 | dccm_wr_readback_err | Yes (`mask_dccm_wr_readback_err`) | DCCM write-readback mismatch — data read back after a store did not match what was written |
3483+| 31:9 | rsvd | — | Reserved |
3484+
3485+
3486+**Masking behavior:** Only `iccm_ecc_unc`, `dccm_ecc_unc`, and `nmi_pin` are maskable via the writable fields of `internal_hw_error_fatal_mask`. The remaining fields (`crypto_err`, `kv_error`, `shadow_storage_err`, `fsm_error`) are unmaskable; their corresponding mask bits are read-only zero. Firmware cannot suppress an already-triggered fatal interrupt by setting a mask bit.
3487+
3488+**`fsm_error` — sparse-FSM glitch detection:** Security-critical FSMs (for example, the mailbox FSM) are sparse-encoded with Hamming-distance-separated state values. If a fault-injection/glitch drives an FSM into an unused encoding, the sparse-FSM guard forces the machine to its error state and asserts `fsm_error`. This is an unmaskable, reset-only fatal error.
3489+
3490+The recoverable counterpart, `CPTRA_HW_ERROR_NON_FATAL`, aggregates non-fatal conditions including mailbox protocol violations and mailbox uncorrectable ECC; firmware may deassert `cptra_error_non_fatal` by clearing or masking all set non-fatal bits. The ICCM region `shadow_update_err` source is inactive while boot-flow monitoring is disabled.
24063491
24073492 ## Cryptographic blocks fatal and non-fatal errors
24083493
@@ -2485,10 +3570,11 @@
24853570 9. Coron, J.-S.: Resistance against differential power analysis for elliptic curve cryptosystems. In: Ko¸c, C¸ .K., Paar, C. (eds.) CHES 1999. LNCS, vol. 1717, pp. 292–302.
24863571 10. Schindler, W., Wiemers, A.: Efficient side-channel attacks on scalar blinding on elliptic curves with special structure. In: NISTWorkshop on ECC Standards (2015).
24873572 11. National Institute of Standards and Technology, "Digital Signature Standard (DSS)", Federal Information Processing Standards Publication (FIPS PUB) 186-4, July 2013.
2488-12. NIST SP 800-90A, Rev 1: "Recommendation for Random Number Generation Using Deterministic Random Bit Generators", 2012. |
3573+12. NIST SP 800-90A, Rev 1: "Recommendation for Random Number Generation Using Deterministic Random Bit Generators", 2012.
24893574 13. CHIPS Alliance, “RISC-V VeeR EL2 Programmer’s Reference Manual” \[Online\] Available at https://github.com/chipsalliance/Cores-VeeR-EL2/blob/main/docs/RISC-V_VeeR_EL2_PRM.pdf.
24903575 14. “The RISC-V Instruction Set Manual, Volume I: User-Level ISA, Document Version 20191213”, Editors Andrew Waterman and Krste Asanovi ́c, RISC-V Foundation, December 2019. Available at https://riscv.org/technical/specifications/.
24913576 15. “The RISC-V Instruction Set Manual, Volume II: Privileged Architecture, Document Version 20211203”, Editors Andrew Waterman, Krste Asanovi ́c, and John Hauser, RISC-V International, December 2021. Available at https://riscv.org/technical/specifications/.
2492-16. NIST SP 800-56A, Rev 3: "Recommendation for Pair-Wise Key-Establishment Schemes Using Discrete Logarithm Cryptography", 2018, |
3577+16. NIST SP 800-56A, Rev 3: "Recommendation for Pair-Wise Key-Establishment Schemes Using Discrete Logarithm Cryptography", 2018.
3578+17. NIST FIPS 202: "SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions", 2015. Available at: [https://csrc.nist.gov/pubs/fips/202/final](https://doi.org/10.6028/NIST.FIPS.202).
24933579
24943580 <sup>[1]</sup> _Caliptra.** **Spanish for “root cap” and describes the deepest part of the root_

Image Changes

v2.0: Caliptra_boot_fsm.png

Image not present in this version

v2.1: Caliptra_boot_fsm.png

New version

v2.0: Crypto-2p0.png

Old version

v2.1: Crypto-2p0.png

Image not present in this version

v2.0: HW_mbox_boot_fsm.png

Old version

v2.1: HW_mbox_boot_fsm.png

Image not present in this version

v2.0: dual_entropy.png

Image not present in this version

v2.1: dual_entropy.png

New version

v2.0: entropy_source_block.png

Old version

v2.1: entropy_source_block.png

New version

v2.0: kv_monitor.png

Image not present in this version

v2.1: kv_monitor.png

New version

v2.0: mbox_boot_fsm_FW_update_reset.png

Old version

v2.1: mbox_boot_fsm_FW_update_reset.png

Image not present in this version