diff --git a/src/lib/SHA1.rs b/src/lib/SHA1.rs index 93b06a518ba..6aec814c8b8 100644 --- a/src/lib/SHA1.rs +++ b/src/lib/SHA1.rs @@ -30,6 +30,7 @@ // Some unexported constants const uint digest_buf_len = 5; const uint msg_block_len = 64; +const uint work_buf_len = 80; const u32 k0 = 0x5A827999u32; const u32 k1 = 0x6ED9EBA1u32; @@ -44,7 +45,8 @@ fn mk_sha1() -> sha1 { mutable u32 len_high, vec[mutable u8] msg_block, mutable uint msg_block_idx, - mutable bool computed); + mutable bool computed, + vec[mutable u32] work_buf); fn add_input(&sha1state st, &vec[u8] msg) { // FIXME: Should be typestate precondition @@ -73,9 +75,10 @@ fn process_msg_block(&sha1state st) { // FIXME: Make precondition assert (Vec.len(st.h) == digest_buf_len); + assert (Vec.len(st.work_buf) == work_buf_len); let int t; // Loop counter - let vec[mutable u32] w = Vec.init_elt_mut[u32](0u32, 80u); + auto w = st.work_buf; // Initialize the first 16 words of the vector w t = 0; @@ -279,7 +282,8 @@ fn result_str() -> str { mutable len_high = 0u32, msg_block = Vec.init_elt_mut[u8](0u8, msg_block_len), mutable msg_block_idx = 0u, - mutable computed = false); + mutable computed = false, + work_buf = Vec.init_elt_mut[u32](0u32, work_buf_len)); auto sh = sha1(st); sh.reset(); ret sh; diff --git a/src/test/run-pass/lib-sha1.rs b/src/test/run-pass/lib-sha1.rs index 2a7e8646a63..c89eca59c71 100644 --- a/src/test/run-pass/lib-sha1.rs +++ b/src/test/run-pass/lib-sha1.rs @@ -1,5 +1,8 @@ // -*- rust -*- +// xfail-boot +// xfail-stage0 + use std; import std.SHA1; @@ -35,18 +38,13 @@ fn a_million_letter_a() -> str { 0x3Bu8, 0xD2u8, 0x6Eu8, 0xBAu8, 0xAEu8, 0x4Au8, 0xA1u8, 0xF9u8, 0x51u8, 0x29u8, 0xE5u8, 0xE5u8, 0x46u8, 0x70u8, 0xF1u8) - ) - // FIXME: This test is disabled because it takes some - // minutes to run under rustboot+valgrind. It may be - // possible to reenable once things are more optimized. - /*, + ), rec(input = a_million_letter_a(), output = vec(0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, 0xD4u8, 0xC4u8, 0xDAu8, 0xA4u8, 0xF6u8, 0x1Eu8, 0xEBu8, 0x2Bu8, 0xDBu8, 0xADu8, 0x27u8, 0x31u8, 0x65u8, 0x34u8, 0x01u8, 0x6Fu8) ) - */ ); // Examples from wikipedia