Commit 457e30aeec5b0fe979ffb7ffc9e69db52a19fbfc

Guillem Jover 2023-04-09T00:14:30

Sync RMD160 changes from OpenBSD

diff --git a/include/rmd160.h b/include/rmd160.h
index f8a7afa..697a808 100644
--- a/include/rmd160.h
+++ b/include/rmd160.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: rmd160.h,v 1.15 2004/05/03 17:30:14 millert Exp $	*/
+/*	$OpenBSD: rmd160.h,v 1.17 2012/12/05 23:19:57 deraadt Exp $	*/
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
  *
diff --git a/src/rmd160.c b/src/rmd160.c
index e0904f9..8a44f47 100644
--- a/src/rmd160.c
+++ b/src/rmd160.c
@@ -29,8 +29,8 @@
 
 #include <config.h>
 
-#include <string.h>
 #include <sys/types.h>
+#include <string.h>
 #include <rmd160.h>
 
 #define PUT_64BIT_LE(cp, value) do {                                    \
@@ -84,7 +84,7 @@
 
 #define X(i)	x[i]
 
-static uint8_t PADDING[RMD160_BLOCK_LENGTH] = {
+static const uint8_t PADDING[RMD160_BLOCK_LENGTH] = {
 	0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -153,11 +153,9 @@ RMD160Final(uint8_t digest[RMD160_DIGEST_LENGTH], RMD160_CTX *ctx)
 	int i;
 
 	RMD160Pad(ctx);
-	if (digest != NULL) {
-		for (i = 0; i < 5; i++)
-			PUT_32BIT_LE(digest + i*4, ctx->state[i]);
-		memset(ctx, 0, sizeof (*ctx));
-	}
+	for (i = 0; i < 5; i++)
+		PUT_32BIT_LE(digest + i*4, ctx->state[i]);
+	memset(ctx, 0, sizeof (*ctx));
 }
 
 void