aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/sha_x86/sha160.cpp15
-rw-r--r--modules/sha_x86/sha1core.S59
2 files changed, 38 insertions, 36 deletions
diff --git a/modules/sha_x86/sha160.cpp b/modules/sha_x86/sha160.cpp
index fce5c9d04..d591eb6d8 100644
--- a/modules/sha_x86/sha160.cpp
+++ b/modules/sha_x86/sha160.cpp
@@ -77,20 +77,14 @@ void SHA_160::hash(const byte input[])
#endif
/*
- F1(A,B,C,D,E,W[ 0]); F1(E,A,B,C,D,W[ 1]); F1(D,E,A,B,C,W[ 2]);
- F1(C,D,E,A,B,W[ 3]); F1(B,C,D,E,A,W[ 4]);
-
-
- F1(A,B,C,D,E,W[ 5]);
+ F1(A,B,C,D,E,W[ 0]); F1(E,A,B,C,D,W[ 1]); F1(D,E,A,B,C,W[ 2]);
+ F1(C,D,E,A,B,W[ 3]); F1(B,C,D,E,A,W[ 4]); F1(A,B,C,D,E,W[ 5]);
F1(E,A,B,C,D,W[ 6]); F1(D,E,A,B,C,W[ 7]); F1(C,D,E,A,B,W[ 8]);
- F1(B,C,D,E,A,W[ 9]);
-
- F1(A,B,C,D,E,W[10]); F1(E,A,B,C,D,W[11]);
+ F1(B,C,D,E,A,W[ 9]); F1(A,B,C,D,E,W[10]); F1(E,A,B,C,D,W[11]);
F1(D,E,A,B,C,W[12]); F1(C,D,E,A,B,W[13]); F1(B,C,D,E,A,W[14]);
-
F1(A,B,C,D,E,W[15]); F1(E,A,B,C,D,W[16]); F1(D,E,A,B,C,W[17]);
F1(C,D,E,A,B,W[18]); F1(B,C,D,E,A,W[19]);
- */
+
F2(A,B,C,D,E,W[20]); F2(E,A,B,C,D,W[21]); F2(D,E,A,B,C,W[22]);
F2(C,D,E,A,B,W[23]); F2(B,C,D,E,A,W[24]); F2(A,B,C,D,E,W[25]);
@@ -99,6 +93,7 @@ void SHA_160::hash(const byte input[])
F2(D,E,A,B,C,W[32]); F2(C,D,E,A,B,W[33]); F2(B,C,D,E,A,W[34]);
F2(A,B,C,D,E,W[35]); F2(E,A,B,C,D,W[36]); F2(D,E,A,B,C,W[37]);
F2(C,D,E,A,B,W[38]); F2(B,C,D,E,A,W[39]);
+ */
F3(A,B,C,D,E,W[40]); F3(E,A,B,C,D,W[41]); F3(D,E,A,B,C,W[42]);
F3(C,D,E,A,B,W[43]); F3(B,C,D,E,A,W[44]); F3(A,B,C,D,E,W[45]);
diff --git a/modules/sha_x86/sha1core.S b/modules/sha_x86/sha1core.S
index 5a09cb00d..17352688d 100644
--- a/modules/sha_x86/sha1core.S
+++ b/modules/sha_x86/sha1core.S
@@ -53,6 +53,7 @@ sha160_core:
movl 16(%ebp), %esi
#define MAGIC1 $0x5A827999
+#define MAGIC2 $0x6ED9EBA1
#define FUNC1(B, C, D, TEMP) \
movl C, TEMP ; \
@@ -65,9 +66,10 @@ sha160_core:
xorl C, TEMP ; \
xorl D, TEMP
-#define F(A, B, C, D, E, TEMP, MSG, MAGIC, FUNC) \
+#define F(A, B, C, D, E, TEMP, MAGIC, FUNC) \
FUNC(B, C, D, TEMP) ; \
- addl MSG, E ; \
+ addl 0(%edi), E ; \
+ addl $4, %edi ; \
addl TEMP, E ; \
addl MAGIC, E ; \
roll $5, A ; \
@@ -75,30 +77,35 @@ sha160_core:
rorl $5, A ; \
roll $30, B
- F(%eax, %ebx, %ecx, %edx, %esi, %ebp, 0(%edi), MAGIC1, FUNC1)
- F(%esi, %eax, %ebx, %ecx, %edx, %ebp, 4(%edi), MAGIC1, FUNC1)
- F(%edx, %esi, %eax, %ebx, %ecx, %ebp, 8(%edi), MAGIC1, FUNC1)
- F(%ecx, %edx, %esi, %eax, %ebx, %ebp, 12(%edi), MAGIC1, FUNC1)
- F(%ebx, %ecx, %edx, %esi, %eax, %ebp, 16(%edi), MAGIC1, FUNC1)
-
- F(%eax, %ebx, %ecx, %edx, %esi, %ebp, 20(%edi), MAGIC1, FUNC1)
- F(%esi, %eax, %ebx, %ecx, %edx, %ebp, 24(%edi), MAGIC1, FUNC1)
- F(%edx, %esi, %eax, %ebx, %ecx, %ebp, 28(%edi), MAGIC1, FUNC1)
- F(%ecx, %edx, %esi, %eax, %ebx, %ebp, 32(%edi), MAGIC1, FUNC1)
- F(%ebx, %ecx, %edx, %esi, %eax, %ebp, 36(%edi), MAGIC1, FUNC1)
-
- F(%eax, %ebx, %ecx, %edx, %esi, %ebp, 40(%edi), MAGIC1, FUNC1)
- F(%esi, %eax, %ebx, %ecx, %edx, %ebp, 44(%edi), MAGIC1, FUNC1)
- F(%edx, %esi, %eax, %ebx, %ecx, %ebp, 48(%edi), MAGIC1, FUNC1)
- F(%ecx, %edx, %esi, %eax, %ebx, %ebp, 52(%edi), MAGIC1, FUNC1)
- F(%ebx, %ecx, %edx, %esi, %eax, %ebp, 56(%edi), MAGIC1, FUNC1)
-
- F(%eax, %ebx, %ecx, %edx, %esi, %ebp, 60(%edi), MAGIC1, FUNC1)
- F(%esi, %eax, %ebx, %ecx, %edx, %ebp, 64(%edi), MAGIC1, FUNC1)
- F(%edx, %esi, %eax, %ebx, %ecx, %ebp, 68(%edi), MAGIC1, FUNC1)
- F(%ecx, %edx, %esi, %eax, %ebx, %ebp, 72(%edi), MAGIC1, FUNC1)
- F(%ebx, %ecx, %edx, %esi, %eax, %ebp, 76(%edi), MAGIC1, FUNC1)
-
+#define F1(A, B, C, D, E, TEMP) \
+ F(A, B, C, D, E, TEMP, MAGIC1, FUNC1)
+
+#define F2(A, B, C, D, E, TEMP) \
+ F(A, B, C, D, E, TEMP, MAGIC2, FUNC2)
+
+#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(%ebx, %ecx, %edx, %esi, %eax, %ebp)
+/*
+ F1(%eax, %ebx, %ecx, %edx, %esi, %ebp)
+ F1(%esi, %eax, %ebx, %ecx, %edx, %ebp)
+ F1(%edx, %esi, %eax, %ebx, %ecx, %ebp)
+ F1(%ecx, %edx, %esi, %eax, %ebx, %ebp)
+ F1(%ebx, %ecx, %edx, %esi, %eax, %ebp)
+*/
+ F_BLOCK(F1)
+ F_BLOCK(F1)
+ F_BLOCK(F1)
+ F_BLOCK(F1)
+
+ F_BLOCK(F2)
+ F_BLOCK(F2)
+ F_BLOCK(F2)
+ F_BLOCK(F2)
+
movl 20(%esp), %ebp
movl %eax, 0(%ebp)
movl %ebx, 4(%ebp)