Skip to main content

Module sha_ring

Module sha_ring 

Source
Expand description

Three-context interleaved SHA-512 ring.

One SHA-512 round is split into three registered stages, and three independent compression contexts circulate through them, so the round logic completes one round every cycle (one block per ~80 cycles). A single-context three-phase unit would finish one round every three cycles; the ring triples throughput for the same round datapath.

The message schedule is a 16-word shift register with fixed taps, so no word is ever selected by a dynamic index. A job may request a second, constant padding block (used for the 128-byte challenge R || A || M).

§Stages

  x ──A──> y ──B──> z ──C──> x
  • A reads context x and forms the round’s partial sums (h + K[t] + W[t], Σ1(e) + Ch, Σ0(a) + Maj) and the two halves of the next schedule word.
  • B adds them into T1, T2 and W[t+16].
  • C commits the round to the working variables and shifts the schedule. After round 79 it adds the chaining value (feed-forward) and then starts the padding block, emits the digest, or parks.

Each stage boundary is a register, so a context completes a round every three cycles and each adder chain is at most two 64-bit additions deep.

§Output and parking

A finished digest goes to a single output register that the consumer drains with out_ready. If that register is full when a context finishes, the context parks: it keeps its slot in the ring, does no more rounds, and retries each time it passes stage C. A parked context blocks its slot, so a slow consumer throttles admission instead of losing a digest.

Structs§

ShaDone
Completed digest; held until out_ready.
ShaJob
Compression job: one message of one block, or of exactly 128 bytes.
ShaRing
Interleaved SHA-512 compression ring.
ShaRingIn
Ring inputs.
ShaRingOut
Ring outputs.

Functions§

pad_block_128
Padding block that ends a message of exactly 128 bytes.
sha512_iv
SHA-512 initial chaining value H(0) (FIPS 180-4 section 5.3.5).
sha_ring_kernel
State transition for ShaRing.