_mm_sha1rnds4_epu32
Classification
Other, Cryptography, CPUID Test: SHA
Header File
immintrin.h
Instruction
SHA1RNDS4 xmm, xmm, imm8
Synopsis
 _mm_sha1rnds4_epu32(__m128i a, __m128i b, const int func);
Description
Perform four rounds of SHA1 operation using an initial SHA1 state (A,B,C,D) from "a" and some pre-computed sum of the next 4 round message values (unsigned 32-bit integers), and state variable E from "b", and store the updated SHA1 state (A,B,C,D) in "dst". "func" contains the logic functions and round constants.
Operation
IF (func[1:0] == 0)
	f := f0()
	K := K0
ELSE IF (func[1:0] == 1)
	f := f1()
	K := K1
ELSE IF (func[1:0] == 2)
	f := f2()
	K := K2
ELSE IF (func[1:0] == 3)
	f := f3()
	K := K3
FI
A := a[127:96]
B := a[95:64]
C := a[63:32]
D := a[31:0]
W[0] := b[127:96]
W[1] := b[95:64]
W[2] := b[63:32]
W[3] := b[31:0]
A[1] := f(B, C, D) + (A <<< 5) + W[0] + K
B[1] := A
C[1] := B <<< 30
D[1] := C
E[1] := D
FOR i := 1 to 3
	A[i+1] := f(B[i], C[i], D[i]) + (A[i] <<< 5) + W[i] + E[i] + K
	B[i+1] := A[i]
	C[i+1] := B[i] <<< 30
	D[i+1] := C[i]
	E[i+1] := D[i]
ENDFOR
dst[127:96] := A[4]
dst[95:64] := B[4]
dst[63:32] := C[4]
dst[31:0] := D[4]