Sync RMD160 changes from OpenBSD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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