diff --git a/src/ripple/protocol/Serializer.h b/src/ripple/protocol/Serializer.h index 9bf86b686..159a1dba9 100644 --- a/src/ripple/protocol/Serializer.h +++ b/src/ripple/protocol/Serializer.h @@ -166,10 +166,8 @@ public: return addFieldID (static_cast (type), name); } - // normal hash functions - uint160 getRIPEMD160 (int size = -1) const; - uint256 getSHA256 (int size = -1) const; - uint256 getSHA512Half (int size = -1) const; + // DEPRECATED + uint256 getSHA512Half() const; // prefix hash functions static uint256 getPrefixHash (std::uint32_t prefix, const unsigned char* data, int len); diff --git a/src/ripple/protocol/UInt160.h b/src/ripple/protocol/UInt160.h index eb6e32773..ecde8294f 100644 --- a/src/ripple/protocol/UInt160.h +++ b/src/ripple/protocol/UInt160.h @@ -35,6 +35,7 @@ namespace ripple { template uint256 to256 (base_uint<160, Tag> const& a) { + // VFALCO This assumes uint256 is zero-initialized uint256 m; memcpy (m.begin (), a.begin (), a.size ()); return m; diff --git a/src/ripple/protocol/impl/Serializer.cpp b/src/ripple/protocol/impl/Serializer.cpp index 7e1a7afc7..90b628d36 100644 --- a/src/ripple/protocol/impl/Serializer.cpp +++ b/src/ripple/protocol/impl/Serializer.cpp @@ -296,36 +296,9 @@ Blob Serializer::getRaw (int offset, int length) const return o; } -uint160 Serializer::getRIPEMD160 (int size) const +uint256 Serializer::getSHA512Half () const { - uint160 ret; - - if ((size < 0) || (size > mData.size ())) size = mData.size (); - - RIPEMD160 (& (mData.front ()), size, (unsigned char*) &ret); - return ret; -} - -uint256 Serializer::getSHA256 (int size) const -{ - uint256 ret; - - if ((size < 0) || (size > mData.size ())) size = mData.size (); - - SHA256 (& (mData.front ()), size, (unsigned char*) &ret); - return ret; -} - -uint256 Serializer::getSHA512Half (int size) const -{ - assert (size != 0); - if (size == 0) - return uint256(); - if (size < 0 || size > mData.size()) - return ripple::getSHA512Half (mData); - - return ripple::getSHA512Half ( - mData.data(), size); + return ripple::getSHA512Half (mData); } uint256 Serializer::getPrefixHash (std::uint32_t prefix, const unsigned char* data, int len) diff --git a/src/ripple/shamap/tests/FetchPack.test.cpp b/src/ripple/shamap/tests/FetchPack.test.cpp index 4c8300753..08e0c0699 100644 --- a/src/ripple/shamap/tests/FetchPack.test.cpp +++ b/src/ripple/shamap/tests/FetchPack.test.cpp @@ -89,7 +89,7 @@ public: for (int d = 0; d < 3; ++d) s.add32 (r.nextInt ()); return std::make_shared ( - to256(s.getRIPEMD160()), s.peekData ()); + s.getSHA512Half(), s.peekData ()); } void diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index f22d591e4..84affb4bf 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -43,7 +43,8 @@ public: for (int d = 0; d < 3; ++d) s.add32 (rand ()); - return std::make_shared (to256 (s.getRIPEMD160 ()), s.peekData ()); + return std::make_shared( + s.getSHA512Half(), s.peekData ()); } bool confuseMap (SHAMap& map, int count)