AESDEC128KL: Perform Ten Rounds of AES Decryption With Key Locker

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeCPUID Feature FlagDescription
F3 0F 38 DD !(11):rrr:bbb
AESDEC128KL xmm, m384
RMInvalidValidValidAESKLEDecrypts xmm using a 128 bit AES key indicated by the handle at m384. Stores the result in xmm.

Encoding

EncodingOperand 1Operand 2
RMModRM.reg[rw]ModRM.r/m[r]

Description

The AESDEC128KL instruction performs ten rounds of AES decryption on the first operand using the 128 bit key indicated by the handle in the second operand. If a handle violation occurs, the ZF flag is set. Otherwise, the result is stored in the first operand, and the ZF flag is cleared.

Operation

This pseudo-code uses C# syntax. A list of the types used is available here.
public void AESDEC128KL(SimdU128 arg, IntPtr handleAddress)
{
  Handle handle = mem384[handleAddress];
  bool illegalHandle = (
    handle.reserved ||
    (handle.Bit[0] == 1 && CPL > 0) ||
    handle.Bit[2] == 1 ||
    handle.type != HANDLE_KEY_TYPE_AES128);

  if (illegalHandle)
  {
    ZF = 1;
  }
  else
  {
    (unwrappedKey, authentic) = UnwrapKeyAndAuthenticate384(handle, IWKey);
    if (authentic)
    {
      arg[0] = Aes128.Decrypt(arg[0], unwrappedKey)
      ZF = 0;
    }
    else
    {
      ZF = 1;
    }
  }

  OF = SF = AF = PF = CF = 0;
}

Flags Affected

CF (carry flag)
Cleared.
PF (parity flag)
Cleared.
AF (auxiliary flag)
Cleared.
ZF (zero flag)
Set if a handle violation occurs. Cleared otherwise.
SF (sign flag)
Cleared.
OF (overflow flag)
Cleared.

C Intrinsics

Exceptions

Protected Mode

#UD
If the LOCK prefix is used.
If CPUID.(EAX=00h):ECX.KL[bit 23] is 0.
If CR4.KL is 0.
If CPUID.(EAX=19h):EBX.AESKLE[bit 0] is 0.
If CR0.EM is 1.
If CR4.OSFXSR is 1.
#NM
If CR0.TS is 1.
#PF
If a page fault occurs.
#GP(0)
If a memory operand effective address is outside the CS, DS, ES, FS, or GS segment limit.
If the DS, ES, FS, or GS segment is used to access memory and it contains a NULL segment selector.
If the memory address is in non-canonical form.
#SS(0)
If a memory operand effective address is outside the SS segment limit.
If a memory address referencing the SS segment is in non-canonical form.

Real-Address Mode

Same exceptions as protected mode.

Virtual-8086 Mode

Same exceptions as protected mode.

Compatibility Mode

Same exceptions as protected mode.

Long Mode

Same exceptions as protected mode.