aboutsummaryrefslogtreecommitdiffstats
path: root/modules/sha_x86/sha1core.S
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-08-12 18:34:52 +0000
committerlloyd <[email protected]>2006-08-12 18:34:52 +0000
commitbae2a1447f6620d44a977e38587779b8e47be665 (patch)
treebb72acd9ebdd7b0411a7332093fee783d916ce0e /modules/sha_x86/sha1core.S
parentb9f901807d9c6e2bd1e1d52d64fe327c9478acb9 (diff)
Entire SHA-1 compression function now implemented in assembly, just needs
instruction scheduling and code cleanup.
Diffstat (limited to 'modules/sha_x86/sha1core.S')
-rw-r--r--modules/sha_x86/sha1core.S56
1 files changed, 44 insertions, 12 deletions
diff --git a/modules/sha_x86/sha1core.S b/modules/sha_x86/sha1core.S
index 17352688d..acba9fb8d 100644
--- a/modules/sha_x86/sha1core.S
+++ b/modules/sha_x86/sha1core.S
@@ -54,7 +54,9 @@ sha160_core:
#define MAGIC1 $0x5A827999
#define MAGIC2 $0x6ED9EBA1
-
+#define MAGIC3 $0x8F1BBCDC
+#define MAGIC4 $0xCA62C1D6
+
#define FUNC1(B, C, D, TEMP) \
movl C, TEMP ; \
xorl D, TEMP ; \
@@ -66,16 +68,29 @@ sha160_core:
xorl C, TEMP ; \
xorl D, TEMP
+#define FUNC3(B, C, D, TEMP) \
+ movl B, TEMP ; \
+ orl C, TEMP ; \
+ andl D, TEMP ; \
+ movl B, (%edi) ; \
+ andl C, (%edi) ; \
+ orl (%edi), TEMP
+
+#define FUNC4(B, C, D, TEMP) \
+ movl B, TEMP ; \
+ xorl C, TEMP ; \
+ xorl D, TEMP
+
#define F(A, B, C, D, E, TEMP, MAGIC, FUNC) \
+ addl (%edi), E ; \
FUNC(B, C, D, TEMP) ; \
- addl 0(%edi), E ; \
addl $4, %edi ; \
addl TEMP, E ; \
addl MAGIC, E ; \
roll $5, A ; \
addl A, E ; \
rorl $5, A ; \
- roll $30, B
+ roll $30, B ;
#define F1(A, B, C, D, E, TEMP) \
F(A, B, C, D, E, TEMP, MAGIC1, FUNC1)
@@ -83,11 +98,17 @@ sha160_core:
#define F2(A, B, C, D, E, TEMP) \
F(A, B, C, D, E, TEMP, MAGIC2, FUNC2)
+#define F3(A, B, C, D, E, TEMP) \
+ F(A, B, C, D, E, TEMP, MAGIC3, FUNC3)
+
+#define F4(A, B, C, D, E, TEMP) \
+ F(A, B, C, D, E, TEMP, MAGIC4, FUNC4)
+
#define F_BLOCK(F) \
- F(%eax, %ebx, %ecx, %edx, %esi, %ebp) ; \
- F(%esi, %eax, %ebx, %ecx, %edx, %ebp) ; \
- F(%edx, %esi, %eax, %ebx, %ecx, %ebp) ; \
- F(%ecx, %edx, %esi, %eax, %ebx, %ebp) ; \
+ F(%eax, %ebx, %ecx, %edx, %esi, %ebp) \
+ F(%esi, %eax, %ebx, %ecx, %edx, %ebp) \
+ F(%edx, %esi, %eax, %ebx, %ecx, %ebp) \
+ F(%ecx, %edx, %esi, %eax, %ebx, %ebp) \
F(%ebx, %ecx, %edx, %esi, %eax, %ebp)
/*
F1(%eax, %ebx, %ecx, %edx, %esi, %ebp)
@@ -96,6 +117,7 @@ sha160_core:
F1(%ecx, %edx, %esi, %eax, %ebx, %ebp)
F1(%ebx, %ecx, %edx, %esi, %eax, %ebp)
*/
+
F_BLOCK(F1)
F_BLOCK(F1)
F_BLOCK(F1)
@@ -106,12 +128,22 @@ sha160_core:
F_BLOCK(F2)
F_BLOCK(F2)
+ F_BLOCK(F3)
+ F_BLOCK(F3)
+ F_BLOCK(F3)
+ F_BLOCK(F3)
+
+ F_BLOCK(F4)
+ F_BLOCK(F4)
+ F_BLOCK(F4)
+ F_BLOCK(F4)
+
movl 20(%esp), %ebp
- movl %eax, 0(%ebp)
- movl %ebx, 4(%ebp)
- movl %ecx, 8(%ebp)
- movl %edx, 12(%ebp)
- movl %esi, 16(%ebp)
+ addl %eax, 0(%ebp)
+ addl %ebx, 4(%ebp)
+ addl %ecx, 8(%ebp)
+ addl %edx, 12(%ebp)
+ addl %esi, 16(%ebp)
popl %ebx
popl %esi