Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: net/quic/test_tools/quic_test_utils.cc

Issue 2590313003: Use SHA-1 functions from BoringSSL directly. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/quic_test_utils_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/quic_test_utils.cc
diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc
index b7306f90ab09a3caf8e74756dfe5a7d53f5c7932..df74207a43a55d895cafaff15ec0511d38a0829e 100644
--- a/net/quic/test_tools/quic_test_utils.cc
+++ b/net/quic/test_tools/quic_test_utils.cc
@@ -7,7 +7,6 @@
#include <memory>
#include "base/memory/ptr_util.h"
-#include "base/sha1.h"
#include "base/strings/string_number_conversions.h"
#include "net/quic/core/crypto/crypto_framer.h"
#include "net/quic/core/crypto/crypto_handshake.h"
@@ -23,6 +22,7 @@
#include "net/quic/test_tools/quic_connection_peer.h"
#include "net/spdy/spdy_frame_builder.h"
#include "net/tools/quic/quic_per_connection_packet_writer.h"
+#include "third_party/boringssl/src/include/openssl/sha.h"
using base::StringPiece;
using std::string;
@@ -98,11 +98,18 @@ QuicFlagSaver::~QuicFlagSaver() {
#undef QUIC_FLAG
}
+string Sha1Hash(StringPiece data) {
+ char buffer[SHA_DIGEST_LENGTH];
+ SHA1(reinterpret_cast<const uint8_t*>(data.data()), data.size(),
+ reinterpret_cast<uint8_t*>(buffer));
+ return string(buffer, arraysize(buffer));
+}
+
uint64_t SimpleRandom::RandUint64() {
- unsigned char hash[base::kSHA1Length];
- base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_),
- hash);
- memcpy(&seed_, hash, sizeof(seed_));
+ string hash =
+ Sha1Hash(StringPiece(reinterpret_cast<char*>(&seed_), sizeof(seed_)));
+ DCHECK_EQ(static_cast<size_t>(SHA_DIGEST_LENGTH), hash.length());
+ memcpy(&seed_, hash.data(), sizeof(seed_));
return seed_;
}
« no previous file with comments | « net/quic/test_tools/quic_test_utils.h ('k') | net/quic/test_tools/quic_test_utils_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698