summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--disk-utils/mkfs.cramfs.c4
-rw-r--r--include/md5.h4
-rw-r--r--lib/md5.c4
-rw-r--r--libblkid/src/superblocks/hfs.c6
-rw-r--r--misc-utils/mcookie.c4
-rw-r--r--tests/helpers/test_md5.c4
6 files changed, 14 insertions, 12 deletions
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 545585ad5..c1b21ade3 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -90,7 +90,7 @@ struct entry {
/* stats */
unsigned char *name;
unsigned int mode, size, uid, gid;
- unsigned char md5sum[16];
+ unsigned char md5sum[MD5LENGTH];
unsigned char flags; /* CRAMFS_EFLAG_* */
/* FS data */
@@ -247,7 +247,7 @@ static int find_identical_file(struct entry *orig, struct entry *new, loff_t *fs
if ((orig->flags & CRAMFS_EFLAG_MD5) &&
(new->flags & CRAMFS_EFLAG_MD5) &&
- !memcmp(orig->md5sum, new->md5sum, 16) &&
+ !memcmp(orig->md5sum, new->md5sum, MD5LENGTH) &&
identical_file(orig, new)) {
new->same = orig;
*fslen_ub -= new->size;
diff --git a/include/md5.h b/include/md5.h
index d598e81be..1222cf030 100644
--- a/include/md5.h
+++ b/include/md5.h
@@ -7,6 +7,8 @@
typedef unsigned int uint32_t;
#endif
+#define MD5LENGTH 16
+
struct MD5Context {
uint32_t buf[4];
uint32_t bits[2];
@@ -16,7 +18,7 @@ struct MD5Context {
void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, unsigned char const *buf,
unsigned len);
-void MD5Final(unsigned char digest[16], struct MD5Context *context);
+void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *context);
void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
/*
diff --git a/lib/md5.c b/lib/md5.c
index 071630f19..26ec4bbd8 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -107,7 +107,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, unsigned len)
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
-void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
+void MD5Final(unsigned char digest[MD5LENGTH], struct MD5Context *ctx)
{
unsigned count;
unsigned char *p;
@@ -144,7 +144,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
- memcpy(digest, ctx->buf, 16);
+ memcpy(digest, ctx->buf, MD5LENGTH);
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
diff --git a/libblkid/src/superblocks/hfs.c b/libblkid/src/superblocks/hfs.c
index e043994e3..6d960e9e7 100644
--- a/libblkid/src/superblocks/hfs.c
+++ b/libblkid/src/superblocks/hfs.c
@@ -130,17 +130,17 @@ struct hfsplus_vol_header {
static int hfs_set_uuid(blkid_probe pr, unsigned char const *hfs_info, size_t len)
{
- static unsigned char const hash_init[16] = {
+ static unsigned char const hash_init[MD5LENGTH] = {
0xb3, 0xe2, 0x0f, 0x39, 0xf2, 0x92, 0x11, 0xd6,
0x97, 0xa4, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac
};
- unsigned char uuid[16];
+ unsigned char uuid[MD5LENGTH];
struct MD5Context md5c;
if (memcmp(hfs_info, "\0\0\0\0\0\0\0\0", len) == 0)
return -1;
MD5Init(&md5c);
- MD5Update(&md5c, hash_init, 16);
+ MD5Update(&md5c, hash_init, MD5LENGTH);
MD5Update(&md5c, hfs_info, len);
MD5Final(uuid, &md5c);
uuid[6] = 0x30 | (uuid[6] & 0x0f);
diff --git a/misc-utils/mcookie.c b/misc-utils/mcookie.c
index 61896e17d..1e6b64b08 100644
--- a/misc-utils/mcookie.c
+++ b/misc-utils/mcookie.c
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
{
size_t i;
struct MD5Context ctx;
- unsigned char digest[16];
+ unsigned char digest[MD5LENGTH];
unsigned char buf[BUFFERSIZE];
int fd;
int c;
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
}
MD5Final(digest, &ctx);
- for (i = 0; i < 16; i++)
+ for (i = 0; i < MD5LENGTH; i++)
printf("%02x", digest[i]);
putchar('\n');
diff --git a/tests/helpers/test_md5.c b/tests/helpers/test_md5.c
index b99882b53..7f1e4f358 100644
--- a/tests/helpers/test_md5.c
+++ b/tests/helpers/test_md5.c
@@ -9,7 +9,7 @@ main(int argc, char *argv[])
{
int i, ret;
struct MD5Context ctx;
- unsigned char digest[16];
+ unsigned char digest[MD5LENGTH];
unsigned char buf[BUFSIZ];
MD5Init( &ctx );
@@ -23,7 +23,7 @@ main(int argc, char *argv[])
fclose(stdin);
MD5Final( digest, &ctx );
- for (i = 0; i < 16; i++)
+ for (i = 0; i < MD5LENGTH; i++)
printf( "%02x", digest[i] );
printf(" -\n");
return 0;