diff options
author | jsing <> | 2023-08-10 07:15:23 +0000 |
---|---|---|
committer | jsing <> | 2023-08-10 07:15:23 +0000 |
commit | 5ccf52b751e2b7dd5a5c0593f12b501074180fff (patch) | |
tree | 9ca48e5b24acc855af178267c3089d8f870623b0 | |
parent | 0c67b8136f2ccb712ba6ab0d74f8dac9b61c59e8 (diff) | |
download | openbsd-5ccf52b751e2b7dd5a5c0593f12b501074180fff.tar.gz openbsd-5ccf52b751e2b7dd5a5c0593f12b501074180fff.tar.bz2 openbsd-5ccf52b751e2b7dd5a5c0593f12b501074180fff.zip |
Remove MD32_REG_T.
This is a hack that is only enabled on a handful of 64 bit platforms, as
a workaround for poor compiler optimisation. If you're running an archiac
compiler on an archiac architecture, then you can deal with slightly lower
performance.
ok tb@
-rw-r--r-- | src/lib/libcrypto/md32_common.h | 34 | ||||
-rw-r--r-- | src/lib/libcrypto/md4/md4.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/md5/md5.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/ripemd/ripemd.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/sha/sha1.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/sha/sha256.c | 4 |
6 files changed, 16 insertions, 48 deletions
diff --git a/src/lib/libcrypto/md32_common.h b/src/lib/libcrypto/md32_common.h index ccd6db53fb..f61c49f03c 100644 --- a/src/lib/libcrypto/md32_common.h +++ b/src/lib/libcrypto/md32_common.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: md32_common.h,v 1.25 2023/05/27 18:33:34 jsing Exp $ */ | 1 | /* $OpenBSD: md32_common.h,v 1.26 2023/08/10 07:15:23 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -307,35 +307,3 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) | |||
307 | return 1; | 307 | return 1; |
308 | } | 308 | } |
309 | #endif | 309 | #endif |
310 | |||
311 | #ifndef MD32_REG_T | ||
312 | #if defined(__alpha) || defined(__sparcv9) || defined(__mips) | ||
313 | #define MD32_REG_T long | ||
314 | /* | ||
315 | * This comment was originally written for MD5, which is why it | ||
316 | * discusses A-D. But it basically applies to all 32-bit digests, | ||
317 | * which is why it was moved to common header file. | ||
318 | * | ||
319 | * In case you wonder why A-D are declared as long and not | ||
320 | * as MD5_LONG. Doing so results in slight performance | ||
321 | * boost on LP64 architectures. The catch is we don't | ||
322 | * really care if 32 MSBs of a 64-bit register get polluted | ||
323 | * with eventual overflows as we *save* only 32 LSBs in | ||
324 | * *either* case. Now declaring 'em long excuses the compiler | ||
325 | * from keeping 32 MSBs zeroed resulting in 13% performance | ||
326 | * improvement under SPARC Solaris7/64 and 5% under AlphaLinux. | ||
327 | * Well, to be honest it should say that this *prevents* | ||
328 | * performance degradation. | ||
329 | * <appro@fy.chalmers.se> | ||
330 | */ | ||
331 | #else | ||
332 | /* | ||
333 | * Above is not absolute and there are LP64 compilers that | ||
334 | * generate better code if MD32_REG_T is defined int. The above | ||
335 | * pre-processor condition reflects the circumstances under which | ||
336 | * the conclusion was made and is subject to further extension. | ||
337 | * <appro@fy.chalmers.se> | ||
338 | */ | ||
339 | #define MD32_REG_T int | ||
340 | #endif | ||
341 | #endif | ||
diff --git a/src/lib/libcrypto/md4/md4.c b/src/lib/libcrypto/md4/md4.c index a60196e5b9..d05d5ace0d 100644 --- a/src/lib/libcrypto/md4/md4.c +++ b/src/lib/libcrypto/md4/md4.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: md4.c,v 1.5 2023/07/28 11:04:41 jsing Exp $ */ | 1 | /* $OpenBSD: md4.c,v 1.6 2023/08/10 07:15:23 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -146,8 +146,8 @@ void | |||
146 | md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) | 146 | md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) |
147 | { | 147 | { |
148 | const unsigned char *data = data_; | 148 | const unsigned char *data = data_; |
149 | unsigned MD32_REG_T A, B, C, D, l; | 149 | unsigned int A, B, C, D, l; |
150 | unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, | 150 | unsigned int X0, X1, X2, X3, X4, X5, X6, X7, |
151 | X8, X9, X10, X11, X12, X13, X14, X15; | 151 | X8, X9, X10, X11, X12, X13, X14, X15; |
152 | 152 | ||
153 | A = c->A; | 153 | A = c->A; |
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c index 06516781a1..ea8d179175 100644 --- a/src/lib/libcrypto/md5/md5.c +++ b/src/lib/libcrypto/md5/md5.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: md5.c,v 1.6 2023/07/28 11:06:28 jsing Exp $ */ | 1 | /* $OpenBSD: md5.c,v 1.7 2023/08/10 07:15:23 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -166,8 +166,8 @@ void | |||
166 | md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) | 166 | md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) |
167 | { | 167 | { |
168 | const unsigned char *data = data_; | 168 | const unsigned char *data = data_; |
169 | unsigned MD32_REG_T A, B, C, D, l; | 169 | unsigned int A, B, C, D, l; |
170 | unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, | 170 | unsigned int X0, X1, X2, X3, X4, X5, X6, X7, |
171 | X8, X9, X10, X11, X12, X13, X14, X15; | 171 | X8, X9, X10, X11, X12, X13, X14, X15; |
172 | 172 | ||
173 | A = c->A; | 173 | A = c->A; |
diff --git a/src/lib/libcrypto/ripemd/ripemd.c b/src/lib/libcrypto/ripemd/ripemd.c index 4edf3de4d3..5cf197c831 100644 --- a/src/lib/libcrypto/ripemd/ripemd.c +++ b/src/lib/libcrypto/ripemd/ripemd.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ripemd.c,v 1.1 2023/07/28 11:08:01 jsing Exp $ */ | 1 | /* $OpenBSD: ripemd.c,v 1.2 2023/08/10 07:15:23 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -179,11 +179,11 @@ void | |||
179 | ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num) | 179 | ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num) |
180 | { | 180 | { |
181 | const unsigned char *data = p; | 181 | const unsigned char *data = p; |
182 | unsigned MD32_REG_T A, B,C, D, E; | 182 | unsigned int A, B, C, D, E; |
183 | unsigned MD32_REG_T a, b,c, d,e, l; | 183 | unsigned int a, b, c, d, e, l; |
184 | #ifndef MD32_XARRAY | 184 | #ifndef MD32_XARRAY |
185 | /* See comment in crypto/sha/sha_locl.h for details. */ | 185 | /* See comment in crypto/sha/sha_locl.h for details. */ |
186 | unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, | 186 | unsigned int XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, |
187 | XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; | 187 | XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; |
188 | # define X(i) XX##i | 188 | # define X(i) XX##i |
189 | #else | 189 | #else |
diff --git a/src/lib/libcrypto/sha/sha1.c b/src/lib/libcrypto/sha/sha1.c index 6e35d797b5..4b48653bdb 100644 --- a/src/lib/libcrypto/sha/sha1.c +++ b/src/lib/libcrypto/sha/sha1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sha1.c,v 1.11 2023/07/08 12:24:10 beck Exp $ */ | 1 | /* $OpenBSD: sha1.c,v 1.12 2023/08/10 07:15:23 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -141,8 +141,8 @@ static void | |||
141 | sha1_block_data_order(SHA_CTX *c, const void *p, size_t num) | 141 | sha1_block_data_order(SHA_CTX *c, const void *p, size_t num) |
142 | { | 142 | { |
143 | const unsigned char *data = p; | 143 | const unsigned char *data = p; |
144 | unsigned MD32_REG_T A, B, C, D, E, T, l; | 144 | unsigned int A, B, C, D, E, T, l; |
145 | unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, | 145 | unsigned int X0, X1, X2, X3, X4, X5, X6, X7, |
146 | X8, X9, X10, X11, X12, X13, X14, X15; | 146 | X8, X9, X10, X11, X12, X13, X14, X15; |
147 | 147 | ||
148 | A = c->h0; | 148 | A = c->h0; |
diff --git a/src/lib/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c index 0d0c4231ef..231a5a058c 100644 --- a/src/lib/libcrypto/sha/sha256.c +++ b/src/lib/libcrypto/sha/sha256.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sha256.c,v 1.27 2023/07/08 12:24:10 beck Exp $ */ | 1 | /* $OpenBSD: sha256.c,v 1.28 2023/08/10 07:15:23 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -135,7 +135,7 @@ sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num) | |||
135 | { | 135 | { |
136 | const uint8_t *in = _in; | 136 | const uint8_t *in = _in; |
137 | const SHA_LONG *in32; | 137 | const SHA_LONG *in32; |
138 | unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1; | 138 | unsigned int a, b, c, d, e, f, g, h, s0, s1, T1; |
139 | SHA_LONG X[16]; | 139 | SHA_LONG X[16]; |
140 | int i; | 140 | int i; |
141 | 141 | ||