aboutsummaryrefslogtreecommitdiffstats
path: root/modules/sha_x86
diff options
context:
space:
mode:
Diffstat (limited to 'modules/sha_x86')
-rw-r--r--modules/sha_x86/asm_macr.h8
-rw-r--r--modules/sha_x86/sha1core.S30
2 files changed, 24 insertions, 14 deletions
diff --git a/modules/sha_x86/asm_macr.h b/modules/sha_x86/asm_macr.h
index 2736c7d9a..095d656bf 100644
--- a/modules/sha_x86/asm_macr.h
+++ b/modules/sha_x86/asm_macr.h
@@ -20,6 +20,10 @@
.type func_name,@function; \
func_name:
+#define LOOP_UNTIL(REG, NUM, LABEL) \
+ cmpl NUM, REG; \
+ jne LABEL
+
#define EAX %eax
#define EBX %ebx
#define ECX %ecx
@@ -34,6 +38,10 @@ func_name:
#define ADD(FROM, TO) addl FROM, TO
+#define ARRAY(REG, NUM) 4*NUM(REG)
+
+#define BSWAP(REG) bswapl REG
+
#define IMM(VAL) $VAL
#define ZEROIZE(REG) xorl REG, REG
diff --git a/modules/sha_x86/sha1core.S b/modules/sha_x86/sha1core.S
index b1f0e4873..01c6c7c18 100644
--- a/modules/sha_x86/sha1core.S
+++ b/modules/sha_x86/sha1core.S
@@ -24,31 +24,33 @@ FUNCTION(sha160_core)
.LOAD_INPUT_LOOP:
ADD(IMM(4), ESI)
- movl 0(EBP), EAX
- movl 4(EBP), EBX
- movl 8(EBP), ECX
- bswapl EAX
- movl 12(EBP), EDX
- bswapl EBX
- addl $16, EBP
- bswapl ECX
- bswapl EDX
+ MOV(ARRAY(EBP, 0), EAX)
+ MOV(ARRAY(EBP, 1), EBX)
+ MOV(ARRAY(EBP, 2), ECX)
+ MOV(ARRAY(EBP, 3), EDX)
+
+ ADD(IMM(16), EBP)
+
+ BSWAP(EAX)
+ BSWAP(EBX)
+ BSWAP(ECX)
+ BSWAP(EDX)
movl EAX, -16(EDI,ESI,4)
movl EBX, -12(EDI,ESI,4)
movl ECX, -8(EDI,ESI,4)
movl EDX, -4(EDI,ESI,4)
- cmpl $16, ESI
- jne .LOAD_INPUT_LOOP
+ LOOP_UNTIL(ESI, IMM(16), .LOAD_INPUT_LOOP)
leal 64(EDI), EBP
ALIGN
.EXPANSION_LOOP:
- addl $4, ESI
+ ADD(IMM(4), ESI)
- ZEROIZE(EAX)
+ ZEROIZE(EAX)
+
movl -4(EBP), EBX
movl -8(EBP), ECX
movl -12(EBP), EDX
@@ -83,7 +85,7 @@ FUNCTION(sha160_core)
addl $16, EBP
cmpl $80, ESI
- jne .EXPANSION_LOOP
+ LOOP_UNTIL(ESI, IMM(80), .EXPANSION_LOOP)
movl 20(%esp), EBP
movl 0(EBP), EAX