Top Qs
Timeline
Chat
Perspective

List of x86 cryptographic instructions

From Wikipedia, the free encyclopedia

Remove ads

Instructions that have been added to the x86 instruction set in order to assist efficient calculation of cryptographic primitives, such as e.g. AES encryption, SHA hash calculation and random number generation.

Intel AES instructions

Summarize
Perspective

6 new instructions.

More information Instruction, Encoding ...
  1. The SubBytes and ShiftRows steps of an AES encryption round may be performed in either order - the result of the instruction is the same either way.[1] (Intel documentation describes the ShiftRows step as being performed first, while AMD documentation describes SubBytes as being performed first.) This also applies to the InvShiftRows/InvSubBytes steps of an AES decryption round.
  2. For the intended AES decode flow under AES-NI (a series of AESDEC instructions followed by an AESDECLAST), the AESDEC instruction performs the InvMixColumns and AddRoundKey steps in the opposite order of what the AES specification (FIPS 197) indicates.
    As a result of this, the AES round key provided as the second source argument to AESDEC cannot just be taken from the Rijndael key schedule directly, but instead has to be postprocessed by performing an InvMixColumn on the round key after the key schedule and before it's used with AESDEC[1] (this can be done with the AESIMC instruction or by doing an AESENCLAST+AESDEC sequence with the round key set to 0.)
    This issue is specific to (V)AESDEC and does not apply to round keys used with the AESENC, AESENCLAST or AESDECLAST instructions.
Remove ads

CLMUL instructions

More information Instruction, Opcode ...
Remove ads

RDRAND and RDSEED

More information Instruction, Encoding ...
  1. The RDRAND and RDSEED instructions may fail to obtain and return a random number if the CPU's random number generators cannot keep up with the issuing of these instructions – if this happens, then software may retry the instructions (although the number of retries should be limited, in order to ensure forward progress[2]). The instructions set EFLAGS.CF to 1 if a random number was successfully obtained and 0 otherwise. For RDSEED, failure to obtain a random number will also set the instruction's destination register to 0.

Intel SHA and SM3 instructions

Summarize
Perspective

These instructions provide support for cryptographic hash functions such as SHA-1, SHA-256, SHA-512 and SM3. Each of these hash functions works on fixed-size data blocks, where the processing of each data-block mostly consists of two major phases:[3]

  • First expand the data-block using a message schedule (that is specific to each hash function)
  • Then perform a series of rounds of a compression function to combine the expanded data into a hash state.

For each of the supported hash functions, separate instructions are provided to help compute the message schedule (instructions with "MSG" in their names) and to help perform the compression function rounds (instructions with "RND" in their names).

More information Hash function extension, Instructions ...
  1. Under Intel APX, none of the SHA-NI/SHA512/SM3 instructions can be encoded with the EVEX prefix - this prevents the use of the r16-r31 and xmm16-xmm31 registers with these instructions.
  2. Assemblers may accept SHA256RNDS2 with or without XMM0 as a third argument.
Remove ads

Intel Key Locker instructions

Summarize
Perspective

These instructions, available in Tiger Lake and later Intel processors, are designed to enable encryption/decryption with an AES key without having access to any unencrypted copies of the key during the actual encryption/decryption process.

More information Key Locker subset, Instruction ...
  1. Under Intel APX, none of the Key Locker instructions can be encoded with the EVEX prefix - this prevents the use of the r16-r31 and xmm16-xmm31 registers with these instructions.
  2. The flags available for the LOADIWKEY instruction in the EAX register are:
    More information Bits, Flags ...
  3. The handle restrictions available for the explicit source argument to ENCODEKEY128 and ENCODEKEY256 are:
    More information Bits, Flags ...
  4. All of the AES Key Locker encode/decode instructions will check whether the handle is valid for the current IWKey and encode/decode data only if the handle is valid. These instructions will set the ZF flag to indicate whether the provided handle was valid (ZF=0) or not (ZF=1).
Remove ads

VIA/Zhaoxin PadLock instructions

Summarize
Perspective

The VIA/Zhaoxin PadLock instructions are instructions designed to apply cryptographic primitives in bulk, similar to the 8086 repeated string instructions. As such, unless otherwise specified, they take, as applicable, pointers to source data in ES:rSI and destination data in ES:rDI, and a data-size or count in rCX. Like the old string instructions, they are all designed to be interruptible.[4][5]

More information ...
Remove ads

Footnotes

  1. For instruction mnemonics that are listed with a hyphen, different VIA PadLock documents differ with respect to whether the instruction names have a hyphen or not (e.g. version 1.0 of the ACE programming guide uses the hyphens,[6] while v1.66 does not.[4]) and assemblers may accept instruction mnemonics with or without the hyphen - e.g. GNU Binutils rev 2.17 and later accepts both.
    Some assemblers may also consider the REP prefix optional for instructions other than XSTORE - with such assemblers, the PadLock instructions will be assembled with one F3 (REP) prefix byte regardless of whether the assembly instruction is written with REP or not. (The F3 prefix is mandatory for all PadLock instructions except XSTORE.)
  2. On some processors that support PadLock, the REP XSTORE instruction (but not REP XRNG2) may write not just the number of bytes specified in ECX, but up to 7 additional bytes as well.[7]
  3. For the REP XRNG2 instruction, bits 1:0 of EDX are used to indicate whether the instruction should return hardware random numbers directly (EDX[1:0]==0) or return postprocessed numbers (EDX[1:0] ≠ 0).
  4. As of 2024, the REP XRNG2, REP XSHA384, REP XSHA512, REP MONTMUL2 and REP XMODEXP instructions exist as documented instructions only on Zhaoxin processors.[5]
    A VIA-provided OpenSSL patch from 2011[8] indicates that these instructions were present on the VIA Nano, however VIA has not published documentation for these instructions.
  5. The control word for REP XCRYPT* is a 16-byte (128-bit) data structure with the following layout: If bit 5 is set in order to allow unaligned data, then the REP XCRYPT* instructions will use the 112 bytes directly after the control word as a scratchpad memory area for data realignment.
    More information Bits, Usage ...
  6. In addition to the new REP XCRYPT-CTR instruction, ACE2 also adds extra features to the other REP XCRYPT instructions: a digest mode for the CBC and CFB instructions, and the ability to use input/output data that are not 16-byte aligned for the non-ECB instructions.
  7. On VIA Nano and later processors, setting rAX to an all-1s value for the REP XSHA* instructions will enable an alternate operation mode, where rCX specifies the number of 64-byte blocks, and where the standard FIPS-180-2 length extension procedure at the end of the hash calculation is omitted. This makes for a variant more suitable for data streaming than the original EAX=0 variant.[10] This functionality also exists for CCS_HASH.
     
  8. The per-chunk calculation is identical for SHA-384 and SHA-512 - as a result of this, the REP XSHA384 and REP XSHA512 instructions perform identical operations.
  9. The REP MONTMUL instruction is only supported with an AddressSize of 32 bits - for this reason, the address-size override prefix (67h) is required in 16-bit and 64-bit modes, but disallowed in 32-bit mode.
  10. The data structure to REP MONTMUL contains six 32-bit elements, where the first one is a negated modular inverse of the bottom 32 bits of the modulus and the remaining 5 are pointers to various memory buffers (each of which uses the ES segment and must be 16-byte aligned):
    More information Offset, Data item ...
  11. For REP MONTMUL2 and REP XMODEXP, the modulus is required to be greater than both and , and is also required to be odd. The instructions will produce a #GP exception if this is not the case.
  12. Given a bignum size of N bits, the scratchpad memory area pointed to by ES:rSI for the REP MONTMUL2 and REP XMODEXP must have a size of at least bytes (e.g. for a 2048-bit bignum size, the scratchpad must be at least 808 bytes). Also, before starting either of these instructions, the 8 first bytes of this scratchpad must be zeroed out and the bignum size given in ECX must also be written as a 64-bit integer to the next 8 bytes.
  13. The CCS instructions are listed with different mnemonics in different Zhaoxin sources - e.g. the CCS_SM3/CCS_SM4 mnemomics are used in a 2019 article,[13] while CCS_HASH/CCS_ENCRYPT are used in a 2020 article.[11]
  14. The CCS_ENCRYPT control word in rAX has the following format: Remaining bits in rAX must be set to all-0s. Of bits 10:6 in rAX (block mode selection), exactly one bit must be set, or else behavior is undefined.
    More information Bits, Usage ...
  15. The supported functions in bits 5:0 of EDX for the SM2 instruction are:
    More information Value, Meaning ...
Remove ads

References

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads