update to use u64; u32 has undefined results

This commit is contained in:
Niko Matsakis 2012-01-20 07:43:39 -08:00
parent 556947c47a
commit de2bb2806f
1 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,9 @@
fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} {
let orig_len = vec::len(msg) * 8u;
// subtle: if orig_len is merely uint, then the code below
// which performs shifts by 32 bits or more has undefined
// results.
let orig_len: u64 = (vec::len(msg) * 8u) as u64;
// pad message
let msg = msg + [0x80u8];
let bitlen = orig_len + 8u;
@ -7,6 +11,7 @@ fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} {
msg += [0u8];
bitlen += 8u;
}
// append length
let i = 0u;
while i < 8u {