Instruction
XSHA256
Hashes the data at [rSI] with SHA-256 into the state at [rDI]; rCX gives the total length and rAX the bytes already hashed; VIA PadLock.
A VIA extension: Intel and AMD processors do not have these instructions.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
Forms
| Instruction | Encoding | Requires |
|---|---|---|
REP XSHA256
REP_XSHA256 | F3 0F A6 D0 | VIA_PADLOCK_SHA + VIA_PADLOCK_SHA_EN |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
via = cpuid_leaf(0xC0000001, 0)[3]
if via >> 10 & 3 != 3:
fault(UD) # CPUID: no PHE, or it is off
if not cr4 >> 9 & 1:
fault(UD) # no SSE
h = aDI # the state: 8 doublewords, 16-
if h & 15: # byte aligned, 128 bytes at it
fault(GP, 0) # free for the engine
key_loaded = 0 # it changes the AES engine's CW
hs = load(h, 256)
n = aCX # the message's length in bytes
p = eax # bytes hashed so far: 0 at first
if p == 0xFFFFFFFF: # (Linux, VIA Nano) rCX blocks of
for i in range(n): # 64 bytes, no padding
w = load(aSI + 64 * i, 512)
hs = sha256_block(hs, w)
aSI = aSI + 64 * n
eax = UNDEFINED # no document says what EAX and
aCX = UNDEFINED # rCX hold after
else:
rest = n - p
for i in range(rest // 64): # whole blocks
w = load(aSI + 64 * i, 512)
hs = sha256_block(hs, w)
r = rest % 64 # the last bytes, a 1 bit, zeros,
t = load(aSI + rest - r, 8 * r) # and the length in bits,
t |= 0x80 << 8 * r # 64 bits big-endian, at the end
b = 1 if r < 56 else 2 # of 1 or 2 blocks
for j in range(8):
x = 8 * n >> 56 - 8 * j & 0xFF
t |= x << 8 * (64 * b - 8 + j)
for i in range(b):
hs = sha256_block(hs, t >> 512 * i)
aSI = aSI + rest # rDI and rCX do not change
eax = n # all bytes hashed
store(h, 256, hs) # the hash, each doubleword in the
# processor's order: byte-swap them
# for SHA-256's digest. The initial state is FIPS 180-4's H(0), in
# memory the same way. After each 64 bytes the engine writes the
# state and EAX, so that an interrupt resumes itRun on AMD Zen 5 (EPYC 9645): 1 case. It ran where CPUID reported no PadLock PHE, and raised an exception.
Operands
| Operand | Kind | Action |
|---|---|---|
REP XSHA256 | ||
rAX | implicit | read, conditional write |
rCX | implicit | read, conditional write |
m8 at ES:[rSI] | implicit | write |
rSI | implicit | read, write |
m8 at ES:[rDI] | implicit | read |
rDI | implicit | read |
Flags
None: XED records no flag that the forms test or change.
Attributes
What else XED records about the forms. How to read.
- All forms
- repeated: count in rCX
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
| ISA set | CPUID | Processors |
|---|---|---|
VIA_PADLOCK_SHA | VIA_PADLOCK_SHA + VIA_PADLOCK_SHA_EN | None in XED’s model. |
More VIA PadLock instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - Linux 7.3: drivers/crypto/padlock-aes.c and padlock-sha.c (VIA PadLock AES and SHA)
- Linux 7.3: drivers/char/hw_random/via-rng.c (VIA PadLock random number generator)
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The text is our own.