@@ -80,18 +80,24 @@ void Os::Test::FileTest::Tester::shadow_flush() {
8080}
8181
8282void Os::Test::FileTest::Tester::shadow_crc (U32& crc) {
83+ Utils::Hash hash;
84+ hash.setHashValue (U32 (~this ->m_independent_crc ));
85+ hash.update (this ->m_crc_buffer , size);
86+
8387 crc = this ->m_independent_crc ;
8488 SyntheticFileData& data = *reinterpret_cast <SyntheticFileData*>(this ->m_shadow .getHandle ());
8589
8690 // Calculate CRC on full file starting at m_pointer
8791 for (FwSizeType i = data.m_pointer ; i < data.m_data .size ();
8892 i++, this ->m_shadow .seek (1 , Os::File::SeekType::RELATIVE)) {
89- // FIXME: Use Utils::Hash wrapper instead of directly using CRC-32 implementation
9093 U8 byte = data.m_data .at (i);
91- crc = Utils::crc32_ieee802_3_update (&byte, sizeof (byte), crc );
94+ hash. update (&byte, sizeof (byte));
9295 }
9396 // Update tracking variables
94- this ->m_independent_crc = Os::File::INITIAL_CRC;
97+ U32 crcFinal;
98+ hash.finalize (crcFinal);
99+ crc = ~crcFinal;
100+ this ->m_independent_crc = crc;
95101}
96102
97103void Os::Test::FileTest::Tester::shadow_partial_crc (FwSizeType& size) {
@@ -102,9 +108,16 @@ void Os::Test::FileTest::Tester::shadow_partial_crc(FwSizeType& size) {
102108 std::min (static_cast <FwSizeType>(data.m_pointer ) + size, static_cast <FwSizeType>(data.m_data .size ()));
103109 size = (data.m_pointer >= bound) ? 0 : static_cast <FwSizeType>(bound - data.m_pointer );
104110 for (FwSizeType i = data.m_pointer ; i < bound; i++) {
105- // FIXME: Use Utils::Hash wrapper instead of directly using CRC-32 implementation
106111 U8 byte = data.m_data .at (i);
107- this ->m_independent_crc = Utils::crc32_ieee802_3_update (&byte, sizeof (byte), this ->m_independent_crc );
112+
113+ Utils::Hash hash;
114+ hash.setHashValue (U32 (~this ->m_independent_crc ));
115+ hash.update (&byte, sizeof (byte));
116+
117+ U32 crcFinal;
118+ hash.finalize (crcFinal);
119+ this ->m_independent_crc = ~crcFinal;
120+
108121 this ->m_shadow .seek (1 , Os::File::SeekType::RELATIVE);
109122 }
110123}
0 commit comments