From 42f4c2a29b56dbdd45dc832d17c6e6072799dab2 Mon Sep 17 00:00:00 2001 From: jsing Date: Sun, 26 Mar 2023 17:52:07 +0000 Subject: [PATCH] Use multiple statements instead of comma separated expressions. No change to generated assembly. --- lib/libcrypto/sha/sha512.c | 57 ++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/libcrypto/sha/sha512.c b/lib/libcrypto/sha/sha512.c index 9fc5d97245b..b5eb56c1721 100644 --- a/lib/libcrypto/sha/sha512.c +++ b/lib/libcrypto/sha/sha512.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha512.c,v 1.18 2023/03/26 17:06:14 jsing Exp $ */ +/* $OpenBSD: sha512.c,v 1.19 2023/03/26 17:52:07 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2004 The OpenSSL Project. All rights reserved * according to the OpenSSL license [found in ../../LICENSE]. @@ -107,9 +107,11 @@ SHA512_Final(unsigned char *md, SHA512_CTX *c) p[n]=0x80; /* There always is a room for one */ n++; - if (n > (sizeof(c->u) - 16)) - memset (p + n, 0, sizeof(c->u) - n), n = 0, - sha512_block_data_order (c, p, 1); + if (n > (sizeof(c->u) - 16)) { + memset(p + n, 0, sizeof(c->u) - n); + n = 0; + sha512_block_data_order(c, p, 1); + } memset (p + n, 0, sizeof(c->u) - 16 - n); #if BYTE_ORDER == BIG_ENDIAN @@ -134,7 +136,7 @@ SHA512_Final(unsigned char *md, SHA512_CTX *c) p[sizeof(c->u) - 16] = (unsigned char)(c->Nh >> 56); #endif - sha512_block_data_order (c, p, 1); + sha512_block_data_order(c, p, 1); if (md == 0) return 0; @@ -204,34 +206,41 @@ SHA512_Update(SHA512_CTX *c, const void *_data, size_t len) size_t n = sizeof(c->u) - c->num; if (len < n) { - memcpy (p + c->num, data, len), c->num += (unsigned int)len; + memcpy(p + c->num, data, len); + c->num += (unsigned int)len; return 1; - } - else { - memcpy (p + c->num, data, n), c->num = 0; - len -= n, data += n; - sha512_block_data_order (c, p, 1); + } else{ + memcpy(p + c->num, data, n); + c->num = 0; + len -= n; + data += n; + sha512_block_data_order(c, p, 1); } } if (len >= sizeof(c->u)) { #ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA - if ((size_t)data % sizeof(c->u.d[0]) != 0) - while (len >= sizeof(c->u)) - memcpy (p, data, sizeof(c->u)), - sha512_block_data_order (c, p, 1), - len -= sizeof(c->u), - data += sizeof(c->u); - else + if ((size_t)data % sizeof(c->u.d[0]) != 0) { + while (len >= sizeof(c->u)) { + memcpy(p, data, sizeof(c->u)); + sha512_block_data_order(c, p, 1); + len -= sizeof(c->u); + data += sizeof(c->u); + } + } else #endif - sha512_block_data_order (c, data, len/sizeof(c->u)), - data += len, - len %= sizeof(c->u), - data -= len; + { + sha512_block_data_order(c, data, len/sizeof(c->u)); + data += len; + len %= sizeof(c->u); + data -= len; + } } - if (len != 0) - memcpy (p, data, len), c->num = (int)len; + if (len != 0) { + memcpy(p, data, len); + c->num = (int)len; + } return 1; } -- 2.20.1