AES Round Key Generation Assist

Encoding

EncodingOperand 1Operand 2Operand 3
rmiModRM.reg[w]ModRM.r/m[r]imm8

Description

The (V)AESKEYGENASSIST instruction assists in expanding the AES cipher key using an 8 bit round constant (RCON) and 128 bits of data from the source operand. The result is stored in in the destination operand.

VEX.vvvv is reserved and must be b1111 (0 inverted). Any other values will raise a #UD exception. All forms except the legacy SSE one will zero the upper (untouched) bits.

Operation

public void AESKEYGENASSIST(SimdU32 dest, SimdU32 src, byte roundConstant)
{
    U32 x0 = src[0];
    U32 x1 = src[1];
    U32 x2 = src[2];
    U32 x3 = src[3];
    U32 rcon = roundConstant;

    dest[0] = SubWord(x1);
    dest[1] = RotWord(SubWord(x1)) ^ rcon;
    dest[2] = SubWord(x3);
    dest[3] = RotWord(SubWord(x3)) ^ rcon;
    // dest[4..] is unmodified
}

public void VAESKEYGENASSIST_Vex128(SimdU32 dest, SimdU32 src, byte roundConstant)
{
    U32 x0 = src[0];
    U32 x1 = src[1];
    U32 x2 = src[2];
    U32 x3 = src[3];
    U32 rcon = roundConstant;

    dest[0] = SubWord(x1);
    dest[1] = RotWord(SubWord(x1)) ^ rcon;
    dest[2] = SubWord(x3);
    dest[3] = RotWord(SubWord(x3)) ^ rcon;
    dest[4..] = 0;
}

Intrinsics

Exceptions

SIMD Floating-Point

None.

Other Exceptions

VEX Encoded Form: See Type 4 Exception Conditions.

#UD
  • If
  • VEX.vvvv
  • is not
  • 1111b
  • .