[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Yet another sha1/md[45] refinement
From: |
Jim Meyering |
Subject: |
Yet another sha1/md[45] refinement |
Date: |
Thu, 31 Jan 2008 14:40:41 +0100 |
While making similar changes to sha256.c and especially sha512.c
(where the 4 would become 8) in coreutils, I found changes like
these to be essential:
Use "sizeof VAR", rather than a literal "4".
* lib/md5.c (md5_read_ctx): Use sizeof ctx->A, not 4.
* lib/md4.c (md4_read_ctx): Likewise.
* lib/sha1.c (sha1_read_ctx): Likewise.
Simon?
---
lib/md4.c | 8 ++++----
lib/md5.c | 8 ++++----
lib/sha1.c | 10 +++++-----
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lib/md4.c b/lib/md4.c
index dd1e2df..3d2c17a 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -79,10 +79,10 @@ void *
md4_read_ctx (const struct md4_ctx *ctx, void *resbuf)
{
char *r = resbuf;
- set_uint32 (r + 0*4, SWAP (ctx->A));
- set_uint32 (r + 1*4, SWAP (ctx->B));
- set_uint32 (r + 2*4, SWAP (ctx->C));
- set_uint32 (r + 3*4, SWAP (ctx->D));
+ set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
+ set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
+ set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
+ set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
return resbuf;
}
diff --git a/lib/md5.c b/lib/md5.c
index b6d307c..0c8bc24 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -95,10 +95,10 @@ void *
md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
{
char *r = resbuf;
- set_uint32 (r + 0*4, SWAP (ctx->A));
- set_uint32 (r + 1*4, SWAP (ctx->B));
- set_uint32 (r + 2*4, SWAP (ctx->C));
- set_uint32 (r + 3*4, SWAP (ctx->D));
+ set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
+ set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
+ set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
+ set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
return resbuf;
}
diff --git a/lib/sha1.c b/lib/sha1.c
index 8869d43..a955d85 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -82,11 +82,11 @@ void *
sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
{
char *r = resbuf;
- set_uint32 (r + 0*4, SWAP (ctx->A));
- set_uint32 (r + 1*4, SWAP (ctx->B));
- set_uint32 (r + 2*4, SWAP (ctx->C));
- set_uint32 (r + 3*4, SWAP (ctx->D));
- set_uint32 (r + 4*4, SWAP (ctx->E));
+ set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
+ set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
+ set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
+ set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));
+ set_uint32 (r + 4 * sizeof ctx->E, SWAP (ctx->E));
return resbuf;
}
--
1.5.4.rc5.1.ge6bfe