/* 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 */
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;
typedef unsigned int uint32_t;
#endif
+#define MD5LENGTH 16
+
struct MD5Context {
uint32_t buf[4];
uint32_t bits[2];
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]);
/*
* 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;
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 */
}
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);
{
size_t i;
struct MD5Context ctx;
- unsigned char digest[16];
+ unsigned char digest[MD5LENGTH];
unsigned char buf[BUFFERSIZE];
int fd;
int c;
}
MD5Final(digest, &ctx);
- for (i = 0; i < 16; i++)
+ for (i = 0; i < MD5LENGTH; i++)
printf("%02x", digest[i]);
putchar('\n');
{
int i, ret;
struct MD5Context ctx;
- unsigned char digest[16];
+ unsigned char digest[MD5LENGTH];
unsigned char buf[BUFSIZ];
MD5Init( &ctx );
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;