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 Encoding

31..20
imm[11:0]
19..15
rs1
14..12
funct3
11..7
rd
6..0
opcode

SHA256SIG0 uses opcode 0010011 (0x13), funct3 001, funct7 0001000. The rs1 field selects the source register, the 12-bit immediate provides the second operand, and rd selects the destination.

Format: I-type
opcode: 0010011 (0x13)
funct3: 001 (0x1)
funct7: 0001000 (0x08)

Instruction Behavior

sha256sig0 implements the SHA-256 σ0 function (lowercase sigma) from Zknh: σ0(x) = ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3). Reads rs1, computes σ0, writes to rd. Used in SHA-256 message schedule word expansion preprocessing.

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
  • Confirm the current instruction format is I-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

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 is a low-level step from AES, SHA, SM3, or SM4; software still combines instructions with the algorithm schedule, round constants, or round keys.