summaryrefslogtreecommitdiffstats
path: root/chrome/browser/visitedlink_master.cc
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-21 21:29:01 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-21 21:29:01 +0000
commit314a2fb194bef628ead6730449caabe3d3ee0503 (patch)
treec5eb519a846b9697cb0693428de1ea5f17f76938 /chrome/browser/visitedlink_master.cc
parent01593319d061fa65811a30c0d37fff1755f9db62 (diff)
downloadchromium_src-314a2fb194bef628ead6730449caabe3d3ee0503.zip
chromium_src-314a2fb194bef628ead6730449caabe3d3ee0503.tar.gz
chromium_src-314a2fb194bef628ead6730449caabe3d3ee0503.tar.bz2
Don't use UuidCreate as a source of randomness, and it's not portable. This removes chrome.dll's dependence on rpcrt4.dll (although it will still likely be loaded later). If the change is fine, I will also remove it from the depends list and the build configuration files.
Review URL: http://codereview.chromium.org/7818 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/visitedlink_master.cc')
-rw-r--r--chrome/browser/visitedlink_master.cc26
1 files changed, 5 insertions, 21 deletions
diff --git a/chrome/browser/visitedlink_master.cc b/chrome/browser/visitedlink_master.cc
index ae307ab..ae63204 100644
--- a/chrome/browser/visitedlink_master.cc
+++ b/chrome/browser/visitedlink_master.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/rand_util.h"
#include "base/stack_container.h"
#include "base/string_util.h"
#include "chrome/browser/browser_process.h"
@@ -18,10 +19,6 @@
#include "chrome/browser/profile.h"
#include "chrome/common/win_util.h"
-#ifdef _WIN32
-#pragma comment(lib, "rpcrt4.lib") // for UuidCreate().
-#endif
-
const int32 VisitedLinkMaster::kFileHeaderSignatureOffset = 0;
const int32 VisitedLinkMaster::kFileHeaderVersionOffset = 4;
const int32 VisitedLinkMaster::kFileHeaderLengthOffset = 8;
@@ -44,24 +41,12 @@ const int32 VisitedLinkMaster::kBigDeleteThreshold = 64;
namespace {
// Fills the given salt structure with some quasi-random values
-// Fills some salt values into the given buffer, we ask the system to generate
-// a UUID for us, and we use some of the bytes out of that. It is not necessary
-// to generate a cryptographically strong random string, only that it be
-// reasonably different for different users. Here, we use every-other byte of
-// the 16-byte UUID.
+// It is not necessary to generate a cryptographically strong random string,
+// only that it be reasonably different for different users.
void GenerateSalt(uint8 salt[LINK_SALT_LENGTH]) {
- UUID uuid;
- UuidCreate(&uuid);
-
DCHECK_EQ(LINK_SALT_LENGTH, 8) << "This code assumes the length of the salt";
- salt[0] = static_cast<uint8>(uuid.Data1 & 0xFF);
- salt[1] = static_cast<uint8>((uuid.Data1 >> 8) & 0xFF);
- salt[2] = static_cast<uint8>(uuid.Data2 & 0xFF);
- salt[3] = static_cast<uint8>(uuid.Data3 & 0xFF);
- salt[4] = uuid.Data4[0];
- salt[5] = uuid.Data4[2];
- salt[6] = uuid.Data4[4];
- salt[7] = uuid.Data4[6];
+ uint64 randval = base::RandUInt64();
+ memcpy(salt, &randval, 8);
}
// AsyncWriter ----------------------------------------------------------------
@@ -1024,4 +1009,3 @@ void VisitedLinkMaster::TableBuilder::OnCompleteMainThread() {
// VisitedLinkMaster::RebuildTableFromHistory.
Release();
}
-