Home/Instructions/SHA256 Sigma0
SHA256SIG0

RISC-V SHA256SIG0 Instruction Details

Instruction ManualI-type

SHA-256 σ0 function: ROTR(rs1,7) ^ ROTR(rs1,18) ^ SHR(rs1,3)

Instruction Syntax

sha256sig0 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

sha256sig0 implements the SHA-256 σ0 function from Zknh: σ0(x) = ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3). 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.

SHA256SIG0 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
sha256sig0
,

SHA256SIG0 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
000100000010
19..15
rs1=x11
14..12
001
11..7
rd=x10
6..0
0010011
Execution Data Path
inb
0x89ABCDEF
ror32(inb, 7)
0xDF13579B
ror32(inb, 18)
0xF37BE26A
inb >> 3
0x113579BD
result
0x3D5DCC4C
Architectural Result
a0(x10) = 0x3D5DCC4C

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

SHA256SIG0 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.

sha256sig0 performs the SHA-256 lowercase sigma message-schedule transform using the official fixed rotate-right and logical-shift 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 «sha256sig0 a0, a1».

Hash Algorithms

Understand this scenario with real code like «sha256sig0 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

Distinguish from Σ0 (sha256sum0, uppercase sigma): σ0 for message schedule, Σ0 for compression.
sha256sig0 uses logical right shift (SHR), not arithmetic.

FAQ

Does SHA256SIG0 use floating-point or vector registers?

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

Is SHA256SIG0 a complete algorithm implementation?

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