Home/Instructions/SHA256 Sum0
SHA256SUM0

RISC-V SHA256SUM0 Instruction Details

Instruction ManualI-type

SHA-256 Σ0 function (uppercase): ROTR(rs1,2) ^ ROTR(rs1,13) ^ ROTR(rs1,22)

Instruction Syntax

sha256sum0 rd, rs1
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
ZknhCrypto & Security

Instruction Behavior

sha256sum0 implements the SHA-256 compression Σ0 function: Σ0(x) = ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22). It is defined for RV32/RV64: RV32 operates on all of X(rs1), while RV64 uses X(rs1)[31:0] and sign-extends the 32-bit result before writing rd.

SHA256SUM0 Decode And Execute Animation

Bounded teaching inputs execute the official SHA-256 fixed-width bit operations; this does not model a complete algorithm or microarchitecture.

rd
rs1
sha256sum0
,

SHA256SUM0 is defined in RV32/RV64; RV64 uses X(rs1)[31:0] and sign-extends the 32-bit result to XLEN.

fixed selector
source
fixed
destination
OP-IMM
31..20
000100000000
19..15
rs1=x11
14..12
001
11..7
rd=x10
6..0
0010011
Execution Data Path
inb
0x89ABCDEF
ror32(inb, 2)
0xE26AF37B
ror32(inb, 13)
0x6F7C4D5E
ror32(inb, 22)
0xAF37BE26
result
0x22210003
Architectural Result
a0(x10) = 0x22210003

This animation shows only official ISA fields and architectural state; it does not model a complete hash algorithm, pipeline, cache, or timing implementation.

Quick Understanding & Search Notes

SHA256SUM0 is a Zknh scalar cryptography instruction for SHA-256 transform. This page is checked against the official scalar crypto extension, avoiding confusion among round functions, key schedule steps, and operand sources.

sha256sum0 performs the SHA-256 uppercase Sigma compression transform using the official fixed rotate-right combination.
Scalar crypto instructions use integer X registers, and the official spec requires the relevant crypto instructions to be implemented with data-independent execution latency.

Common Usage Scenarios

Crypto & Security

Understand this scenario with real code like «sha256sum0 a0, a1».

Hash Algorithms

Understand this scenario with real code like «sha256sum0 a0, a1».

Pre-Use Checklist

Syntax Check
  • Verify the immediate field is within the valid range.
  • Confirm source register rs1 points to the correct operand.
Semantic Check
  • Check if the immediate sign-extension matches expectations.
  • Ensure the result register rd has a clear purpose.

Pitfalls / Common Confusions

Σ0 (sum0, uppercase) for compression; σ0 (sig0, lowercase) for message schedule. Different rotate/shift amounts.

FAQ

Does SHA256SUM0 use floating-point or vector registers?

No. These scalar crypto extension instructions use integer X registers.

Is SHA256SUM0 a complete algorithm implementation?

No. It implements one SHA-2 Sigma transform; software still schedules the remaining SHA-2 computation.