From cd67cc31882d39982b2638fb43ac2ce4fca85f99 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 10 Aug 2023 07:15:23 +0000 Subject: [PATCH] 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@ --- lib/libcrypto/md32_common.h | 34 +--------------------------------- lib/libcrypto/md4/md4.c | 6 +++--- lib/libcrypto/md5/md5.c | 6 +++--- lib/libcrypto/ripemd/ripemd.c | 8 ++++---- lib/libcrypto/sha/sha1.c | 6 +++--- lib/libcrypto/sha/sha256.c | 4 ++-- 6 files changed, 16 insertions(+), 48 deletions(-) diff --git a/lib/libcrypto/md32_common.h b/lib/libcrypto/md32_common.h index ccd6db53fb3..f61c49f03cc 100644 --- a/lib/libcrypto/md32_common.h +++ b/lib/libcrypto/md32_common.h @@ -1,4 +1,4 @@ -/* $OpenBSD: md32_common.h,v 1.25 2023/05/27 18:33:34 jsing Exp $ */ +/* $OpenBSD: md32_common.h,v 1.26 2023/08/10 07:15:23 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. * @@ -307,35 +307,3 @@ int HASH_FINAL (unsigned char *md, HASH_CTX *c) return 1; } #endif - -#ifndef MD32_REG_T -#if defined(__alpha) || defined(__sparcv9) || defined(__mips) -#define MD32_REG_T long -/* - * This comment was originally written for MD5, which is why it - * discusses A-D. But it basically applies to all 32-bit digests, - * which is why it was moved to common header file. - * - * In case you wonder why A-D are declared as long and not - * as MD5_LONG. Doing so results in slight performance - * boost on LP64 architectures. The catch is we don't - * really care if 32 MSBs of a 64-bit register get polluted - * with eventual overflows as we *save* only 32 LSBs in - * *either* case. Now declaring 'em long excuses the compiler - * from keeping 32 MSBs zeroed resulting in 13% performance - * improvement under SPARC Solaris7/64 and 5% under AlphaLinux. - * Well, to be honest it should say that this *prevents* - * performance degradation. - * - */ -#else -/* - * Above is not absolute and there are LP64 compilers that - * generate better code if MD32_REG_T is defined int. The above - * pre-processor condition reflects the circumstances under which - * the conclusion was made and is subject to further extension. - * - */ -#define MD32_REG_T int -#endif -#endif diff --git a/lib/libcrypto/md4/md4.c b/lib/libcrypto/md4/md4.c index a60196e5b92..d05d5ace0d3 100644 --- a/lib/libcrypto/md4/md4.c +++ b/lib/libcrypto/md4/md4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md4.c,v 1.5 2023/07/28 11:04:41 jsing Exp $ */ +/* $OpenBSD: md4.c,v 1.6 2023/08/10 07:15:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -146,8 +146,8 @@ void md4_block_data_order(MD4_CTX *c, const void *data_, size_t num) { const unsigned char *data = data_; - unsigned MD32_REG_T A, B, C, D, l; - unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, + unsigned int A, B, C, D, l; + unsigned int X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; A = c->A; diff --git a/lib/libcrypto/md5/md5.c b/lib/libcrypto/md5/md5.c index 06516781a16..ea8d1791754 100644 --- a/lib/libcrypto/md5/md5.c +++ b/lib/libcrypto/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.6 2023/07/28 11:06:28 jsing Exp $ */ +/* $OpenBSD: md5.c,v 1.7 2023/08/10 07:15:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -166,8 +166,8 @@ void md5_block_data_order(MD5_CTX *c, const void *data_, size_t num) { const unsigned char *data = data_; - unsigned MD32_REG_T A, B, C, D, l; - unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, + unsigned int A, B, C, D, l; + unsigned int X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; A = c->A; diff --git a/lib/libcrypto/ripemd/ripemd.c b/lib/libcrypto/ripemd/ripemd.c index 4edf3de4d31..5cf197c8315 100644 --- a/lib/libcrypto/ripemd/ripemd.c +++ b/lib/libcrypto/ripemd/ripemd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripemd.c,v 1.1 2023/07/28 11:08:01 jsing Exp $ */ +/* $OpenBSD: ripemd.c,v 1.2 2023/08/10 07:15:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -179,11 +179,11 @@ void ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num) { const unsigned char *data = p; - unsigned MD32_REG_T A, B,C, D, E; - unsigned MD32_REG_T a, b,c, d,e, l; + unsigned int A, B, C, D, E; + unsigned int a, b, c, d, e, l; #ifndef MD32_XARRAY /* See comment in crypto/sha/sha_locl.h for details. */ - unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, + unsigned int XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15; # define X(i) XX##i #else diff --git a/lib/libcrypto/sha/sha1.c b/lib/libcrypto/sha/sha1.c index 6e35d797b5c..4b48653bdb1 100644 --- a/lib/libcrypto/sha/sha1.c +++ b/lib/libcrypto/sha/sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha1.c,v 1.11 2023/07/08 12:24:10 beck Exp $ */ +/* $OpenBSD: sha1.c,v 1.12 2023/08/10 07:15:23 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -141,8 +141,8 @@ static void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num) { const unsigned char *data = p; - unsigned MD32_REG_T A, B, C, D, E, T, l; - unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7, + unsigned int A, B, C, D, E, T, l; + unsigned int X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; A = c->h0; diff --git a/lib/libcrypto/sha/sha256.c b/lib/libcrypto/sha/sha256.c index 0d0c4231ef6..231a5a058c2 100644 --- a/lib/libcrypto/sha/sha256.c +++ b/lib/libcrypto/sha/sha256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha256.c,v 1.27 2023/07/08 12:24:10 beck Exp $ */ +/* $OpenBSD: sha256.c,v 1.28 2023/08/10 07:15:23 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * @@ -135,7 +135,7 @@ sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num) { const uint8_t *in = _in; const SHA_LONG *in32; - unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1; + unsigned int a, b, c, d, e, f, g, h, s0, s1, T1; SHA_LONG X[16]; int i; -- 2.20.1