summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha
diff options
context:
space:
mode:
authormiod <>2016-11-04 17:30:30 +0000
committermiod <>2016-11-04 17:30:30 +0000
commit723502d9588ba0e1cc08af1b12654917da74d440 (patch)
tree77b413175d422148cfb0ef7b2062340230aa5413 /src/lib/libcrypto/sha
parent391f8ce21bb7929810460a73e2fde2c80540848d (diff)
downloadopenbsd-723502d9588ba0e1cc08af1b12654917da74d440.tar.gz
openbsd-723502d9588ba0e1cc08af1b12654917da74d440.tar.bz2
openbsd-723502d9588ba0e1cc08af1b12654917da74d440.zip
Replace all uses of magic numbers when operating on OPENSSL_ia32_P[] by
meaningful constants in a private header file, so that reviewers can actually get a chance to figure out what the code is attempting to do without knowing all cpuid bits. While there, turn it from an array of two 32-bit ints into a properly aligned 64-bit int. Use of OPENSSL_ia32_P is now restricted to the assembler parts. C code will now always use OPENSSL_cpu_caps() and check for the proper bits in the whole 64-bit word it returns. i386 tests and ok jsing@
Diffstat (limited to 'src/lib/libcrypto/sha')
-rw-r--r--src/lib/libcrypto/sha/asm/sha1-586.pl10
-rwxr-xr-xsrc/lib/libcrypto/sha/asm/sha1-x86_64.pl9
-rw-r--r--src/lib/libcrypto/sha/asm/sha512-586.pl2
3 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/libcrypto/sha/asm/sha1-586.pl b/src/lib/libcrypto/sha/asm/sha1-586.pl
index 6fbea34d78..d29ed84706 100644
--- a/src/lib/libcrypto/sha/asm/sha1-586.pl
+++ b/src/lib/libcrypto/sha/asm/sha1-586.pl
@@ -303,15 +303,15 @@ if ($xmm) {
303 303
304 &mov ($A,&DWP(0,$T)); 304 &mov ($A,&DWP(0,$T));
305 &mov ($D,&DWP(4,$T)); 305 &mov ($D,&DWP(4,$T));
306 &test ($D,1<<9); # check SSSE3 bit 306 &test ($D,"\$IA32CAP_MASK1_SSSE3"); # check SSSE3 bit
307 &jz (&label("x86")); 307 &jz (&label("x86"));
308 &test ($A,1<<24); # check FXSR bit 308 &test ($A,"\$IA32CAP_MASK0_FXSR"); # check FXSR bit
309 &jz (&label("x86")); 309 &jz (&label("x86"));
310 if ($ymm) { 310 if ($ymm) {
311 &and ($D,1<<28); # mask AVX bit 311 &and ($D,"\$IA32CAP_MASK1_AVX"); # mask AVX bit
312 &and ($A,1<<30); # mask "Intel CPU" bit 312 &and ($A,"\$IA32CAP_MASK0_INTEL"); # mask "Intel CPU" bit
313 &or ($A,$D); 313 &or ($A,$D);
314 &cmp ($A,1<<28|1<<30); 314 &cmp ($A,"\$(IA32CAP_MASK1_AVX | IA32CAP_MASK0_INTEL)");
315 &je (&label("avx_shortcut")); 315 &je (&label("avx_shortcut"));
316 } 316 }
317 &jmp (&label("ssse3_shortcut")); 317 &jmp (&label("ssse3_shortcut"));
diff --git a/src/lib/libcrypto/sha/asm/sha1-x86_64.pl b/src/lib/libcrypto/sha/asm/sha1-x86_64.pl
index f15c7ec39b..147d21570b 100755
--- a/src/lib/libcrypto/sha/asm/sha1-x86_64.pl
+++ b/src/lib/libcrypto/sha/asm/sha1-x86_64.pl
@@ -216,6 +216,7 @@ unshift(@xi,pop(@xi));
216$code.=<<___; 216$code.=<<___;
217.text 217.text
218.extern OPENSSL_ia32cap_P 218.extern OPENSSL_ia32cap_P
219.hidden OPENSSL_ia32cap_P
219 220
220.globl sha1_block_data_order 221.globl sha1_block_data_order
221.type sha1_block_data_order,\@function,3 222.type sha1_block_data_order,\@function,3
@@ -223,14 +224,14 @@ $code.=<<___;
223sha1_block_data_order: 224sha1_block_data_order:
224 mov OPENSSL_ia32cap_P+0(%rip),%r9d 225 mov OPENSSL_ia32cap_P+0(%rip),%r9d
225 mov OPENSSL_ia32cap_P+4(%rip),%r8d 226 mov OPENSSL_ia32cap_P+4(%rip),%r8d
226 test \$`1<<9`,%r8d # check SSSE3 bit 227 test \$IA32CAP_MASK1_SSSE3,%r8d # check SSSE3 bit
227 jz .Lialu 228 jz .Lialu
228___ 229___
229$code.=<<___ if ($avx); 230$code.=<<___ if ($avx);
230 and \$`1<<28`,%r8d # mask AVX bit 231 and \$IA32CAP_MASK1_AVX,%r8d # mask AVX bit
231 and \$`1<<30`,%r9d # mask "Intel CPU" bit 232 and \$IA32CAP_MASK0_INTEL,%r9d # mask "Intel CPU" bit
232 or %r9d,%r8d 233 or %r9d,%r8d
233 cmp \$`1<<28|1<<30`,%r8d 234 cmp \$(IA32CAP_MASK0_INTEL | IA32CAP_MASK1_AVX),%r8d
234 je _avx_shortcut 235 je _avx_shortcut
235___ 236___
236$code.=<<___; 237$code.=<<___;
diff --git a/src/lib/libcrypto/sha/asm/sha512-586.pl b/src/lib/libcrypto/sha/asm/sha512-586.pl
index 7eab6a5b88..163361ebe9 100644
--- a/src/lib/libcrypto/sha/asm/sha512-586.pl
+++ b/src/lib/libcrypto/sha/asm/sha512-586.pl
@@ -284,7 +284,7 @@ sub BODY_00_15_x86 {
284 284
285if ($sse2) { 285if ($sse2) {
286 &picmeup("edx","OPENSSL_ia32cap_P",$K512,&label("K512")); 286 &picmeup("edx","OPENSSL_ia32cap_P",$K512,&label("K512"));
287 &bt (&DWP(0,"edx"),26); 287 &bt (&DWP(0,"edx"),"\$IA32CAP_BIT0_SSE2");
288 &jnc (&label("loop_x86")); 288 &jnc (&label("loop_x86"));
289 289
290 # load ctx->h[0-7] 290 # load ctx->h[0-7]