Instruction
ENCODEKEY128
Wraps the 128-bit AES key in XMM0 into a Key Locker handle in XMM0 to XMM2, so that software can discard the key itself.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
Forms
| Instruction | Encoding | Requires |
|---|---|---|
ENCODEKEY128 r32, r32
ENCODEKEY128_GPR32u8_GPR32u8 | F3 0F 38 FA /r | KL + KLENABLED |
Latency and throughput
| Model | r32, r32 |
|---|---|
| Alder Lake | 100 / 0.25p0156 |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
if not cr4 >> 19 & 1: # CR4.KL; clear without Key Locker
fault(UD)
if not cpuid_leaf(0x19, 0)[1] & 1:
fault(UD) # AESKLE: the AES instructions of
# Key Locker not enabled
if cr0 >> 2 & 1 or not cr4 >> 9 & 1:
fault(UD) # CR0.EM set, CR4.OSFXSR clear
if cr0 >> 3 & 1:
fault(NM) # CR0.TS
r = src.read() # restrictions in bits 2:0: CPL 0
# only, no encrypting, no decrypting
can = cpuid_leaf(0x19, 0)[0] & 7 # those the processor supports
if r & ~can:
fault(GP, 0) # any other bit set
h = wrap_key(xmm[0], r) # metadata: r, key type 0 (AES-128)
# in bits 27:24
dest.write(iwkey >> 384 & 0x1F) # NoBackup in bit 0, KeySource 4:1
xmm[0] = r # the handle: the metadata,
xmm[1] = low(h, 128) # the integrity tag,
xmm[2] = h >> 128 # the encrypted key
xmm[4] = 0 # bits 127:0 of each; the manual
xmm[5] = 0 # says nothing of the bits above
xmm[6] = 0
of = sf = zf = af = pf = cf = 0Run on AMD Zen 5 (EPYC 9645): 2 cases. Its cases ran where CPUID reported no Key Locker, and every one raised an exception.
Operands
| Operand | Kind | Action |
|---|---|---|
ENCODEKEY128 r32, r32 | ||
r32 | explicit | write |
r32 | explicit | read |
XMM0 | implicit | read, write |
XMM1 | implicit | write |
XMM2 | implicit | write |
XMM4 | implicit | write |
XMM5 | implicit | write |
XMM6 | implicit | write |
RFLAGS | implicit | write |
Flags
| OF | SF | ZF | AF | PF | CF |
|---|---|---|---|---|---|
| All forms | |||||
| 0 | 0 | 0 | 0 | 0 | 0 |
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 |
|---|---|---|
KEYLOCKER | KL + KLENABLED | Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Sierra Forest, Clearwater Forest |
More Key Locker instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-283 (ENCODEKEY128)
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 timings come from LLVM's scheduling models, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.