Introduction
These instructions do the core steps of common ciphers and hash functions. They use the SIMD and floating-point registers V0 to V31, nearly always as whole 128-bit values. Each algorithm has its own optional feature: FEAT_AES, FEAT_PMULL, FEAT_SHA1, FEAT_SHA256, FEAT_SHA512, FEAT_SHA3, FEAT_SM3 and FEAT_SM4.
None of these instructions changes NZCV, so the Flags column is a dash throughout.
The instructions
AES
A round of AES is the pair aese and aesmc, or
aesd and aesimc to decrypt. The round key is applied at
the start of the first instruction of the pair.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
aese | aese Vd.16b, Vn.16b | XORs Vd with the round key Vn, then applies ShiftRows and SubBytes. | – |
aesd | aesd Vd.16b, Vn.16b | XORs Vd with the round key Vn, then applies InvShiftRows and InvSubBytes. | – |
aesmc | aesmc Vd.16b, Vn.16b | Applies MixColumns to Vn and writes the result to Vd. | – |
aesimc | aesimc Vd.16b, Vn.16b | Applies InvMixColumns to Vn and writes the result to Vd. | – |
Polynomial multiply
The 8-bit forms of these mnemonics are ordinary Advanced SIMD instructions; see the Advanced SIMD page. The 64-bit forms here are used for GCM and for CRC calculations.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
pmull, pmull2 | pmull Vd.1q, Vn.1d, Vm.1d; pmull2 Vd.1q, Vn.2d, Vm.2d | Carry-less multiply of two 64-bit values, giving a 128-bit result. pmull reads the lower doublewords, pmull2 the upper. | – |
SHA-1
Each hash update does four rounds, and the three differ in the round function they use.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
sha1c | sha1c Qd, Sn, Vm.4s | Hash update using the choose function. | – |
sha1p | sha1p Qd, Sn, Vm.4s | Hash update using the parity function. | – |
sha1m | sha1m Qd, Sn, Vm.4s | Hash update using the majority function. | – |
sha1h | sha1h Sd, Sn | Rotates a 32-bit value left by 30. | – |
sha1su0, sha1su1 | sha1su0 Vd.4s, Vn.4s, Vm.4s; sha1su1 Vd.4s, Vn.4s | The two parts of the message schedule update. | – |
SHA-256
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
sha256h, sha256h2 | sha256h Qd, Qn, Vm.4s | The two parts of the hash update. Together they do four rounds: sha256h gives the new A to D words of the state, and sha256h2 the new E to H words. | – |
sha256su0, sha256su1 | sha256su0 Vd.4s, Vn.4s; sha256su1 Vd.4s, Vn.4s, Vm.4s | The two parts of the message schedule update. | – |
SHA-512
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
sha512h, sha512h2 | sha512h Qd, Qn, Vm.2d | The two parts of the hash update. Together they do two rounds. | – |
sha512su0, sha512su1 | sha512su0 Vd.2d, Vn.2d; sha512su1 Vd.2d, Vn.2d, Vm.2d | The two parts of the message schedule update. | – |
SHA-3 helpers
These are general bitwise operations chosen to suit the Keccak permutation.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
eor3 | eor3 Vd.16b, Vn.16b, Vm.16b, Va.16b | XORs three registers. | – |
bcax | bcax Vd.16b, Vn.16b, Vm.16b, Va.16b | Vn XOR (Vm AND NOT Va). | – |
rax1 | rax1 Vd.2d, Vn.2d, Vm.2d | Rotates each doubleword of Vm left by 1, then XORs with Vn. | – |
xar | xar Vd.2d, Vn.2d, Vm.2d, #imm | XORs Vn and Vm, then rotates each doubleword right by the immediate (0 to 63). | – |
SM3
SM3 is the Chinese national hash function.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
sm3ss1 | sm3ss1 Vd.4s, Vn.4s, Vm.4s, Va.4s | Computes the SS1 value of a round from the top words of the three sources: Vn rotated left by 12, plus Vm and Va, the whole rotated left by 7. The other three words of Vd are cleared. | – |
sm3tt1a, sm3tt1b | sm3tt1a Vd.4s, Vn.4s, Vm.s[i] | The TT1 half of a compression round. The a form is for rounds 0 to 15 and the b form for rounds 16 to 63. | – |
sm3tt2a, sm3tt2b | sm3tt2a Vd.4s, Vn.4s, Vm.s[i] | The TT2 half of a compression round, with the same division of rounds. | – |
sm3partw1, sm3partw2 | sm3partw1 Vd.4s, Vn.4s, Vm.4s | The two parts of the message schedule update. | – |
SM4
SM4 is the Chinese national block cipher.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
sm4e | sm4e Vd.4s, Vn.4s | Encrypts the block in Vd by four rounds, with the round keys in Vn. | – |
sm4ekey | sm4ekey Vd.4s, Vn.4s, Vm.4s | Derives four round keys from Vn and the constants in Vm. | – |
Links
Reference
- Arm A64 Instruction Set Architecture – Arm’s description of each A64 instruction
- Arm Architecture Reference Manual for A-profile – the full architecture specification