S
Steven T. Hatton
I am looking at the C++ MD5 implementation found on this site:
http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html. I'm a bit unsure as to
the necessity and/or effect of the various casts appearing in the
following:
typedef unsigned int uint4;
uint4 count[2]; // number of *bits*, mod 2^64
void MD5::update (uint1 *input, uint4 input_length) {
uint4 input_index, buffer_index;
uint4 buffer_space; // how much space is left in buffer
/...
// Compute number of bytes mod 64
buffer_index = (unsigned int)((count[0]>>3) & 0x3F);
// Update number of bits
if ((count[0]+=((uint4)input_length<<3)) < ((uint4)input_length<<3))
count[1]++;
count[1] += ((uint4)input_length >> 29);
//etc...
}
Firstly, I'm wondering if there could be any functional advantage to not
using the typedef in the first cast.
buffer_index = (unsigned int)((count[0]>>3) & 0x3F);
My guess is the programmer simply overlooked it when converting from using
builtin names to using the typedef.
More significantly, I'm unsure of what those typedefs might accomplish, or
the consequences -if any- of omitting them. Does anybody see functional
value in having them in the code? What might that be?
http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html. I'm a bit unsure as to
the necessity and/or effect of the various casts appearing in the
following:
typedef unsigned int uint4;
uint4 count[2]; // number of *bits*, mod 2^64
void MD5::update (uint1 *input, uint4 input_length) {
uint4 input_index, buffer_index;
uint4 buffer_space; // how much space is left in buffer
/...
// Compute number of bytes mod 64
buffer_index = (unsigned int)((count[0]>>3) & 0x3F);
// Update number of bits
if ((count[0]+=((uint4)input_length<<3)) < ((uint4)input_length<<3))
count[1]++;
count[1] += ((uint4)input_length >> 29);
//etc...
}
Firstly, I'm wondering if there could be any functional advantage to not
using the typedef in the first cast.
buffer_index = (unsigned int)((count[0]>>3) & 0x3F);
My guess is the programmer simply overlooked it when converting from using
builtin names to using the typedef.
More significantly, I'm unsure of what those typedefs might accomplish, or
the consequences -if any- of omitting them. Does anybody see functional
value in having them in the code? What might that be?