Commit c418db02 authored by Niels Möller's avatar Niels Möller
Browse files

* x86/aes-encrypt-internal.asm: Replaced pushl and popl in the

loop with movl.	Eliminated redundant movl.
* x86/aes-decrypt-internal.asm: Likewise.

Rev: nettle/x86/aes-decrypt-internal.asm:1.5
Rev: nettle/x86/aes-encrypt-internal.asm:1.5
parent f2dec308
...@@ -33,14 +33,17 @@ define(<T>,<%ebp>) ...@@ -33,14 +33,17 @@ define(<T>,<%ebp>)
define(<TMP>,<%edi>) define(<TMP>,<%edi>)
define(<KEY>,<%esi>) define(<KEY>,<%esi>)
define(<FRAME_CTX>, <28(%esp)>) define(<FRAME_CTX>, <40(%esp)>)
define(<FRAME_TABLE>, <32(%esp)>) define(<FRAME_TABLE>, <44(%esp)>)
define(<FRAME_LENGTH>, <36(%esp)>) define(<FRAME_LENGTH>, <48(%esp)>)
define(<FRAME_DST>, <40(%esp)>) define(<FRAME_DST>, <52(%esp)>)
define(<FRAME_SRC>, <44(%esp)>) define(<FRAME_SRC>, <56(%esp)>)
define(<FRAME_KEY>, <4(%esp)>) define(<FRAME_KEY>, <16(%esp)>)
define(<FRAME_COUNT>, <(%esp)>) define(<FRAME_COUNT>, <12(%esp)>)
define(<TA>, <8(%esp)>)
define(<TB>, <4(%esp)>)
define(<TC>, <(%esp)>)
C The aes state is kept in %eax, %ebx, %ecx and %edx C The aes state is kept in %eax, %ebx, %ecx and %edx
C C
...@@ -66,7 +69,7 @@ PROLOGUE(_nettle_aes_decrypt) ...@@ -66,7 +69,7 @@ PROLOGUE(_nettle_aes_decrypt)
pushl %esi C 12(%esp) pushl %esi C 12(%esp)
pushl %edi C 8(%esp) pushl %edi C 8(%esp)
subl $8, %esp C loop counter and save area for the key pointer subl $20, %esp C loop counter and save area for the key pointer
movl FRAME_LENGTH, %ebp movl FRAME_LENGTH, %ebp
testl %ebp,%ebp testl %ebp,%ebp
...@@ -95,20 +98,19 @@ PROLOGUE(_nettle_aes_decrypt) ...@@ -95,20 +98,19 @@ PROLOGUE(_nettle_aes_decrypt)
ALIGN(4) ALIGN(4)
.Lround_loop: .Lround_loop:
AES_ROUND(T, SA,SD,SC,SB, TMP, KEY) AES_ROUND(T, SA,SD,SC,SB, TMP, KEY)
pushl TMP movl TMP, TA
AES_ROUND(T, SB,SA,SD,SC, TMP, KEY) AES_ROUND(T, SB,SA,SD,SC, TMP, KEY)
pushl TMP movl TMP, TB
AES_ROUND(T, SC,SB,SA,SD, TMP, KEY) AES_ROUND(T, SC,SB,SA,SD, TMP, KEY)
pushl TMP movl TMP, TC
AES_ROUND(T, SD,SC,SB,SA, TMP, KEY) AES_ROUND(T, SD,SC,SB,SA, SD, KEY)
movl TMP,SD movl TA, SA
popl SC movl TB, SB
popl SB movl TC, SC
popl SA
movl FRAME_KEY, KEY movl FRAME_KEY, KEY
...@@ -123,20 +125,19 @@ PROLOGUE(_nettle_aes_decrypt) ...@@ -123,20 +125,19 @@ PROLOGUE(_nettle_aes_decrypt)
C last round C last round
AES_FINAL_ROUND(SA,SD,SC,SB,T, TMP, KEY) AES_FINAL_ROUND(SA,SD,SC,SB,T, TMP, KEY)
pushl TMP movl TMP, TA
AES_FINAL_ROUND(SB,SA,SD,SC,T, TMP, KEY) AES_FINAL_ROUND(SB,SA,SD,SC,T, TMP, KEY)
pushl TMP movl TMP, TB
AES_FINAL_ROUND(SC,SB,SA,SD,T, TMP, KEY) AES_FINAL_ROUND(SC,SB,SA,SD,T, TMP, KEY)
pushl TMP movl TMP, TC
AES_FINAL_ROUND(SD,SC,SB,SA,T, TMP, KEY) AES_FINAL_ROUND(SD,SC,SB,SA,T, SD, KEY)
movl TMP,SD movl TA, SA
popl SC movl TB, SB
popl SB movl TC, SC
popl SA
C Inverse S-box substitution C Inverse S-box substitution
mov $3,TMP mov $3,TMP
...@@ -157,7 +158,7 @@ PROLOGUE(_nettle_aes_decrypt) ...@@ -157,7 +158,7 @@ PROLOGUE(_nettle_aes_decrypt)
jnz .Lblock_loop jnz .Lblock_loop
.Lend: .Lend:
addl $8, %esp addl $20, %esp
popl %edi popl %edi
popl %esi popl %esi
popl %ebp popl %ebp
......
...@@ -33,14 +33,17 @@ define(<T>,<%ebp>) ...@@ -33,14 +33,17 @@ define(<T>,<%ebp>)
define(<TMP>,<%edi>) define(<TMP>,<%edi>)
define(<KEY>,<%esi>) define(<KEY>,<%esi>)
define(<FRAME_CTX>, <28(%esp)>) define(<FRAME_CTX>, <40(%esp)>)
define(<FRAME_TABLE>, <32(%esp)>) define(<FRAME_TABLE>, <44(%esp)>)
define(<FRAME_LENGTH>, <36(%esp)>) define(<FRAME_LENGTH>, <48(%esp)>)
define(<FRAME_DST>, <40(%esp)>) define(<FRAME_DST>, <52(%esp)>)
define(<FRAME_SRC>, <44(%esp)>) define(<FRAME_SRC>, <56(%esp)>)
define(<FRAME_KEY>, <4(%esp)>) define(<FRAME_KEY>, <16(%esp)>)
define(<FRAME_COUNT>, <(%esp)>) define(<FRAME_COUNT>, <12(%esp)>)
define(<TA>, <8(%esp)>)
define(<TB>, <4(%esp)>)
define(<TC>, <(%esp)>)
C The aes state is kept in %eax, %ebx, %ecx and %edx C The aes state is kept in %eax, %ebx, %ecx and %edx
C C
...@@ -66,7 +69,7 @@ PROLOGUE(_nettle_aes_encrypt) ...@@ -66,7 +69,7 @@ PROLOGUE(_nettle_aes_encrypt)
pushl %esi C 12(%esp) pushl %esi C 12(%esp)
pushl %edi C 8(%esp) pushl %edi C 8(%esp)
subl $8, %esp C loop counter and save area for the key pointer subl $20, %esp C loop counter and save area for the key pointer
movl FRAME_LENGTH, %ebp movl FRAME_LENGTH, %ebp
testl %ebp,%ebp testl %ebp,%ebp
...@@ -94,20 +97,19 @@ PROLOGUE(_nettle_aes_encrypt) ...@@ -94,20 +97,19 @@ PROLOGUE(_nettle_aes_encrypt)
ALIGN(4) ALIGN(4)
.Lround_loop: .Lround_loop:
AES_ROUND(T, SA,SB,SC,SD, TMP, KEY) AES_ROUND(T, SA,SB,SC,SD, TMP, KEY)
pushl TMP movl TMP, TA
AES_ROUND(T, SB,SC,SD,SA, TMP, KEY) AES_ROUND(T, SB,SC,SD,SA, TMP, KEY)
pushl TMP movl TMP, TB
AES_ROUND(T, SC,SD,SA,SB, TMP, KEY) AES_ROUND(T, SC,SD,SA,SB, TMP, KEY)
pushl TMP movl TMP, TC
AES_ROUND(T, SD,SA,SB,SC, TMP, KEY) AES_ROUND(T, SD,SA,SB,SC, SD, KEY)
movl TMP,SD movl TA, SA
popl SC movl TB, SB
popl SB movl TC, SC
popl SA
movl FRAME_KEY, KEY movl FRAME_KEY, KEY
...@@ -122,20 +124,19 @@ PROLOGUE(_nettle_aes_encrypt) ...@@ -122,20 +124,19 @@ PROLOGUE(_nettle_aes_encrypt)
C last round C last round
AES_FINAL_ROUND(SA,SB,SC,SD, T, TMP, KEY) AES_FINAL_ROUND(SA,SB,SC,SD, T, TMP, KEY)
pushl TMP movl TMP, TA
AES_FINAL_ROUND(SB,SC,SD,SA, T, TMP, KEY) AES_FINAL_ROUND(SB,SC,SD,SA, T, TMP, KEY)
pushl TMP movl TMP, TB
AES_FINAL_ROUND(SC,SD,SA,SB, T, TMP, KEY) AES_FINAL_ROUND(SC,SD,SA,SB, T, TMP, KEY)
pushl TMP movl TMP, TC
AES_FINAL_ROUND(SD,SA,SB,SC, T, TMP, KEY) AES_FINAL_ROUND(SD,SA,SB,SC, T, SD, KEY)
movl TMP,SD movl TA, SA
popl SC movl TB, SB
popl SB movl TC, SC
popl SA
C S-box substitution C S-box substitution
mov $3,TMP mov $3,TMP
...@@ -156,7 +157,7 @@ PROLOGUE(_nettle_aes_encrypt) ...@@ -156,7 +157,7 @@ PROLOGUE(_nettle_aes_encrypt)
jnz .Lblock_loop jnz .Lblock_loop
.Lend: .Lend:
addl $8, %esp addl $20, %esp
popl %edi popl %edi
popl %esi popl %esi
popl %ebp popl %ebp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment