1 dnl LREG(reg) gives the 8-bit register corresponding to the given 32-bit register.
18 $1, %r15d, %r15b)>)dnl
20 define(<HREG>,<ifelse(
27 define(<XREG>,<ifelse(
45 dnl AES_LOAD(a, b, c, d, src, key)
46 dnl Loads the next block of data from src, and add the subkey pointed
48 dnl Note that x86 allows unaligned accesses.
49 dnl Would it be preferable to interleave the loads and stores?
61 dnl AES_STORE(a, b, c, d, key, dst)
62 dnl Adds the subkey to a, b, c, d,
63 dnl and stores the result in the area pointed to by dst.
64 dnl Note that x86 allows unaligned accesses.
65 dnl Would it be preferable to interleave the loads and stores?
77 dnl AES_ROUND(table,a,b,c,d,out,ptr)
78 dnl Computes one word of the AES round. Leaves result in $6.
81 movl AES_TABLE0 ($1, $7, 4),$6
82 movzb HREG($3), XREG($7)
83 xorl AES_TABLE1 ($1, $7, 4),$6
87 xorl AES_TABLE2 ($1, $7, 4),$6
90 xorl AES_TABLE3 ($1, $7, 4),$6>)dnl
92 dnl AES_FINAL_ROUND(a, b, c, d, table, out, tmp)
93 dnl Computes one word of the final round. Leaves result in $6. Also
94 dnl performs the first substitution step, on the least significant
95 dnl byte, and rotates 8 bits.
96 define(<AES_FINAL_ROUND>, <
100 andl <$>0x0000ff00,XREG($7)
103 andl <$>0x00ff0000,XREG($7)
106 andl <$>0xff000000,XREG($7)
110 dnl AES_SUBST_BYTE(A, B, C, D, table, tmp)
111 dnl Substitutes the least significant byte of
112 dnl each of eax, ebx, ecx and edx, and also rotates
113 dnl the words one byte to the left.
114 dnl Uses that AES_SBOX == 0
115 define(<AES_SUBST_BYTE>, <
117 movb ($5, $6),LREG($1)
121 movb ($5, $6),LREG($2)
125 movb ($5, $6),LREG($3)
129 movb ($5, $6),LREG($4)