summaryrefslogtreecommitdiff
path: root/libavutil/md5.c
diff options
context:
space:
mode:
authorGiorgio Vazzana <mywing81@gmail.com>2012-06-15 17:21:36 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-06-16 12:47:46 +0200
commitc78cf00bd8329dd339d2f73d1b43c366d0f46837 (patch)
treef59babae65188cb5e0314bfe4eaf09e5f5c04214 /libavutil/md5.c
parentc7bdfbe79f00eaa1ee9e34db1a38db1e15bbda8e (diff)
md5: consistently use uint32_t instead of unsigned int
Basically to make code clearer and adherent to the standard. RFC 1321, on page 2 states Let the symbol "+" denote addition of words (i.e., modulo-2^32 addition). Let X <<< s denote the 32-bit value obtained by circularly shifting (rotating) X left by s bit positions. on page 3, section 3.3 states: A four-word buffer (A,B,C,D) is used to compute the message digest. Here each of A, B, C, D is a 32-bit register. so the algorithm needs to work with integers that are exactly 32bits in length. And indeed in struct AVMD5 the MD buffer is declared as "uint32_t ABCD[4];", while in the function that performs the block transformation the state variables were "unsigned int"s. On architectures where sizeof(unsigned int) != sizeof(uint32_t) this could be a problem, although I can't name such an architecture from the top of my head. On a side note, both the reference implementation in RFC 1321 and the gnulib implementation (used by md5sum program on GNU systems) use uint32_t in the transform function. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/md5.c')
-rw-r--r--libavutil/md5.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavutil/md5.c b/libavutil/md5.c
index 471a510a73..00447f92f0 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -88,12 +88,12 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32)
static void body(uint32_t ABCD[4], uint32_t X[16])
{
- int t;
int i av_unused;
- unsigned int a = ABCD[3];
- unsigned int b = ABCD[2];
- unsigned int c = ABCD[1];
- unsigned int d = ABCD[0];
+ uint32_t t;
+ uint32_t a = ABCD[3];
+ uint32_t b = ABCD[2];
+ uint32_t c = ABCD[1];
+ uint32_t d = ABCD[0];
#if HAVE_BIGENDIAN
for (i = 0; i < 16; i++)