Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
832eebcc
Commit
832eebcc
authored
Sep 13, 2008
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further micro optimizations.
Rev: nettle/x86/aes.m4:1.4
parent
d7b85b91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
35 deletions
+25
-35
x86/aes.m4
x86/aes.m4
+25
-35
No files found.
x86/aes.m4
View file @
832eebcc
dnl
BYTE
REG(reg) gives the 8-bit register corresponding to the given 32-bit register.
dnl
L
REG(reg) gives the 8-bit register corresponding to the given 32-bit register.
dnl Use in AES_SUBST_BYTE below, and is used by both the x86 and the x86_64 assembler.
define(<
BYTE
REG>,<ifelse(
define(<
L
REG>,<ifelse(
$1, %eax, %al,
$1, %ebx, %bl,
$1, %ecx, %cl,
$1, %edx, %dl,
dnl The rest are x86_64 only
$1, %esi, %sil,
$1, %edi, %dil,
$1, %ebp, %bpl,
$1, %esp, %spl,
$1, %r8d, %r8b,
$1, %r9d, %r9b,
$1, %r10d, %r10b,
$1, %r11d, %r11b,
$1, %r12d, %r12b,
$1, %r13d, %r13b,
$1, %r14d, %r14b,
$1, %r15d, %r15b)>)dnl
$1, %edx, %dl)>)dnl
define(<HREG>,<ifelse(
$1, %eax, %ah,
$1, %ebx, %bh,
$1, %ecx, %ch,
$1, %edx, %dh)>)dnl
dnl AES_LOAD(a, b, c, d, src, key)
dnl Loads the next block of data from src, and add the subkey pointed
...
...
@@ -51,20 +44,18 @@ define(<AES_STORE>, <
movl $3,8($6)
movl $4,12($6)>)dnl
dnl AES_ROUND(table,a,b,c,d,out,
tmp
)
dnl AES_ROUND(table,a,b,c,d,out,
ptr
)
dnl Computes one word of the AES round. Leaves result in $6.
define(<AES_ROUND>, <
movzbl BYTEREG($2), $7
movl AES_TABLE0 ($1, $7,4),$6
movl $3, $7
shrl <$>8,$7
andl <$>0xff,$7
movzbl LREG($2), $7
movl AES_TABLE0 ($1, $7, 4),$6
movzbl HREG($3), $7
xorl AES_TABLE1 ($1, $7, 4),$6
movl $4,$7
C third one
movl $4,$7
shrl <$>16,$7
andl <$>0xff,$7
xorl AES_TABLE2 ($1, $7, 4),$6
movl $5,$7
C fourth one
movl $5,$7
shrl <$>24,$7
xorl AES_TABLE3 ($1, $7, 4),$6>)dnl
...
...
@@ -74,8 +65,7 @@ dnl Note that we have to quote $ in constants.
define(<AES_FINAL_ROUND>, <
C FIXME: Perform substitution on least significant byte here,
C to save work later.
movl $1,$5
andl <$>0x000000ff,$5
movzbl LREG($1),$5
movl $2,$6
andl <$>0x0000ff00,$6
orl $6, $5
...
...
@@ -86,24 +76,24 @@ define(<AES_FINAL_ROUND>, <
andl <$>0xff000000,$6
orl $6, $5>)dnl
dnl AES_SUBST_BYTE(A, B, C, D, table,
tmp
)
dnl AES_SUBST_BYTE(A, B, C, D, table,
ptr
)
dnl Substitutes the least significant byte of
dnl each of eax, ebx, ecx and edx, and also rotates
dnl the words one byte to the left.
dnl Uses that AES_SBOX == 0
define(<AES_SUBST_BYTE>, <
movzbl
BYTE
REG($1),$6
movb ($5, $6),
BYTE
REG($1)
movzbl
L
REG($1),$6
movb ($5, $6),
L
REG($1)
roll <$>8,$1
movzbl
BYTE
REG($2),$6
movb ($5, $6),
BYTE
REG($2)
movzbl
L
REG($2),$6
movb ($5, $6),
L
REG($2)
roll <$>8,$2
movzbl
BYTE
REG($3),$6
movb ($5, $6),
BYTE
REG($3)
movzbl
L
REG($3),$6
movb ($5, $6),
L
REG($3)
roll <$>8,$3
movzbl
BYTE
REG($4),$6
movb ($5, $6),
BYTE
REG($4)
movzbl
L
REG($4),$6
movb ($5, $6),
L
REG($4)
roll <$>8,$4>)dnl
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment