This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to use aese and aesd instruction in aarch64

Hi all,

I want to use aes instructions for implementing AES-128 ECB algorithm. Such implementation contains several aes instructions (e.g., the aese, aesmc, aesd, aesimc).

I implement the prototype of AES encryption and AES decryption. In decryption, I use the aesimc to replace the aesmc instruction, then use aesd to replace the aese. Moreover, I select the key in decryption is the same as that in encryption.

To verify it, I encrypt one 128-bit plaintext, then decrypt it. However the result of my decryption is not the same as my plaintext.

I check my codes and find the reason: the output of one aese-aesd round will be different from the input.

Specifically, my codes are listed as follows:

ld1 {v0.16b}, [x0]  //x0 stores the plaintext

aese v0.16b, v1.16b  //v1 stores the key, and the result of aese is stored in v0

aesd v0.16b v1.16b  //v1 stores the key, and the result of aesd is stored in v0

//fetch the value in v0 and compare it with the plaintext stored in x0.

Can someone helps me?

Parents
  • I find that each 8 bit in the key register (here I use v1 as register) must be the same. If not, the output will be different from the plaintext.

    One possible code is listed as follows:

    movi v1.16b, #0x09

    here the value of v1 should be 0x0909_0909_0909_0909.

    but if I use v1.8h instead of 16b, the result will be wrong.

Reply
  • I find that each 8 bit in the key register (here I use v1 as register) must be the same. If not, the output will be different from the plaintext.

    One possible code is listed as follows:

    movi v1.16b, #0x09

    here the value of v1 should be 0x0909_0909_0909_0909.

    but if I use v1.8h instead of 16b, the result will be wrong.

Children
No data