From 972c6c032e9d5bdf156fcd5bc3febf487967fd18 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Mon, 4 Oct 2021 16:21:14 -0500 Subject: [PATCH] ssl.c: clean up MD5->SHA refactor of wolfSSL_LH_strhash() (peer review). --- src/ssl.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 62f7a7f13..4549dce16 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -56192,20 +56192,17 @@ unsigned long wolfSSL_LH_strhash(const char *str) return 0; } - ret = 0; - do { - if (wc_ShaUpdate(&sha, (const byte *)str, (word32)strLen) != 0) { - WOLFSSL_MSG("SHA1 Update failed"); - break; - } - if (wc_ShaFinal(&sha, digest) != 0) { + ret = wc_ShaUpdate(&sha, (const byte *)str, (word32)strLen); + if (ret != 0) { + WOLFSSL_MSG("SHA1 Update failed"); + } else { + ret = wc_ShaFinal(&sha, digest); + if (ret != 0) { WOLFSSL_MSG("SHA1 Final failed"); - break; } - ret = 1; - } while (0); + } wc_ShaFree(&sha); - if (ret == 0) + if (ret != 0) return 0; /* Take first 4 bytes in small endian as unsigned long */