Changeset 208931 in webkit


Ignore:
Timestamp:
Nov 19, 2016 4:38:09 PM (7 years ago)
Author:
Antti Koivisto
Message:

Salt network cache hashes
https://bugs.webkit.org/show_bug.cgi?id=164924

Reviewed by Alex Christensen.

To enhance privacy make cache content unidentifiable from file names alone.
This is done by generating a unique persistent salt for each cache instance.
It is used when computing hashes used in file names.

The patch also replaces plain text partition directory names with salted hashes.

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::Cache::makeCacheKey):
(WebKit::NetworkCache::makeCacheKey): Deleted.

  • NetworkProcess/cache/NetworkCache.h:

Increment cache version.

  • NetworkProcess/cache/NetworkCacheBlobStorage.cpp:

(WebKit::NetworkCache::BlobStorage::BlobStorage):
(WebKit::NetworkCache::BlobStorage::add):
(WebKit::NetworkCache::BlobStorage::get):

Use salt for blob content hash.

  • NetworkProcess/cache/NetworkCacheBlobStorage.h:
  • NetworkProcess/cache/NetworkCacheData.cpp:

(WebKit::NetworkCache::computeSHA1):

For simplicity all SHA1s are now salted.

(WebKit::NetworkCache::makeSalt):
(WebKit::NetworkCache::readOrMakeSalt):

Read salt if it exists, generate and persist it otherwise.

  • NetworkProcess/cache/NetworkCacheData.h:
  • NetworkProcess/cache/NetworkCacheKey.cpp:

(WebKit::NetworkCache::Key::Key):

Remove the "No partition" string and just empty.
That was only needed to have a directory name of some sort.

(WebKit::NetworkCache::Key::computeHash):

Use salt for key hash.

(WebKit::NetworkCache::Key::computePartitionHash):

Separate hash for partition.

  • NetworkProcess/cache/NetworkCacheKey.h:
  • NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:

(WebKit::NetworkCache::makeSubresourcesKey):
(WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::saveToDiskIfReady):
(WebKit::NetworkCache::SpeculativeLoadManager::retrieveSubresourcesEntry):

  • NetworkProcess/cache/NetworkCacheStorage.cpp:

(WebKit::NetworkCache::makeSaltFilePath):
(WebKit::NetworkCache::Storage::open):

Cache can't be opened if we can't read or persist a salt.

(WebKit::NetworkCache::traverseRecordsFiles):
(WebKit::NetworkCache::Storage::Storage):
(WebKit::NetworkCache::Storage::synchronize):
(WebKit::NetworkCache::Storage::recordDirectoryPathForKey):

Use the partition hash in the directory name instead of a plain text name.

(WebKit::NetworkCache::decodeRecordHeader):
(WebKit::NetworkCache::Storage::readRecord):
(WebKit::NetworkCache::Storage::encodeRecord):
(WebKit::NetworkCache::Storage::traverse):
(WebKit::NetworkCache::Storage::clear):

  • NetworkProcess/cache/NetworkCacheStorage.h:

(WebKit::NetworkCache::Storage::salt):

Location:
trunk/Source/WebKit2
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r208927 r208931  
     12016-11-19  Antti Koivisto  <antti@apple.com>
     2
     3        Salt network cache hashes
     4        https://bugs.webkit.org/show_bug.cgi?id=164924
     5
     6        Reviewed by Alex Christensen.
     7
     8        To enhance privacy make cache content unidentifiable from file names alone.
     9        This is done by generating a unique persistent salt for each cache instance.
     10        It is used when computing hashes used in file names.
     11
     12        The patch also replaces plain text partition directory names with salted hashes.
     13
     14        * NetworkProcess/cache/NetworkCache.cpp:
     15        (WebKit::NetworkCache::Cache::makeCacheKey):
     16        (WebKit::NetworkCache::makeCacheKey): Deleted.
     17        * NetworkProcess/cache/NetworkCache.h:
     18
     19            Increment cache version.
     20
     21        * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
     22        (WebKit::NetworkCache::BlobStorage::BlobStorage):
     23        (WebKit::NetworkCache::BlobStorage::add):
     24        (WebKit::NetworkCache::BlobStorage::get):
     25
     26            Use salt for blob content hash.
     27
     28        * NetworkProcess/cache/NetworkCacheBlobStorage.h:
     29        * NetworkProcess/cache/NetworkCacheData.cpp:
     30        (WebKit::NetworkCache::computeSHA1):
     31
     32            For simplicity all SHA1s are now salted.
     33
     34        (WebKit::NetworkCache::makeSalt):
     35        (WebKit::NetworkCache::readOrMakeSalt):
     36
     37            Read salt if it exists, generate and persist it otherwise.
     38
     39        * NetworkProcess/cache/NetworkCacheData.h:
     40        * NetworkProcess/cache/NetworkCacheKey.cpp:
     41        (WebKit::NetworkCache::Key::Key):
     42
     43            Remove the "No partition" string and just empty.
     44            That was only needed to have a directory name of some sort.
     45
     46        (WebKit::NetworkCache::Key::computeHash):
     47
     48            Use salt for key hash.
     49
     50        (WebKit::NetworkCache::Key::computePartitionHash):
     51
     52            Separate hash for partition.
     53
     54        * NetworkProcess/cache/NetworkCacheKey.h:
     55        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
     56        (WebKit::NetworkCache::makeSubresourcesKey):
     57        (WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::saveToDiskIfReady):
     58        (WebKit::NetworkCache::SpeculativeLoadManager::retrieveSubresourcesEntry):
     59        * NetworkProcess/cache/NetworkCacheStorage.cpp:
     60        (WebKit::NetworkCache::makeSaltFilePath):
     61        (WebKit::NetworkCache::Storage::open):
     62
     63            Cache can't be opened if we can't read or persist a salt.
     64
     65        (WebKit::NetworkCache::traverseRecordsFiles):
     66        (WebKit::NetworkCache::Storage::Storage):
     67        (WebKit::NetworkCache::Storage::synchronize):
     68        (WebKit::NetworkCache::Storage::recordDirectoryPathForKey):
     69
     70            Use the partition hash in the directory name instead of a plain text name.
     71
     72        (WebKit::NetworkCache::decodeRecordHeader):
     73        (WebKit::NetworkCache::Storage::readRecord):
     74        (WebKit::NetworkCache::Storage::encodeRecord):
     75        (WebKit::NetworkCache::Storage::traverse):
     76        (WebKit::NetworkCache::Storage::clear):
     77        * NetworkProcess/cache/NetworkCacheStorage.h:
     78        (WebKit::NetworkCache::Storage::salt):
     79
    1802016-11-19  Simon Fraser  <simon.fraser@apple.com>
    281
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

    r207330 r208931  
    115115}
    116116
    117 static Key makeCacheKey(const WebCore::ResourceRequest& request)
     117Key Cache::makeCacheKey(const WebCore::ResourceRequest& request)
    118118{
    119119#if ENABLE(CACHE_PARTITIONING)
     
    126126    // ranges so only the same exact range request will be served from the cache.
    127127    String range = request.httpHeaderField(WebCore::HTTPHeaderName::Range);
    128     return { partition, resourceType(), range, request.url().string() };
     128    return { partition, resourceType(), range, request.url().string(), m_storage->salt() };
    129129}
    130130
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h

    r202439 r208931  
    130130    ~Cache() = delete;
    131131
     132    Key makeCacheKey(const WebCore::ResourceRequest&);
     133
    132134    String dumpFilePath() const;
    133135    void deleteDumpFile();
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.cpp

    r205556 r208931  
    4141namespace NetworkCache {
    4242
    43 BlobStorage::BlobStorage(const String& blobDirectoryPath)
     43BlobStorage::BlobStorage(const String& blobDirectoryPath, Salt salt)
    4444    : m_blobDirectoryPath(blobDirectoryPath)
     45    , m_salt(salt)
    4546{
    4647}
     
    8687    ASSERT(!RunLoop::isMain());
    8788
    88     auto hash = computeSHA1(data);
     89    auto hash = computeSHA1(data, m_salt);
    8990    if (data.isEmpty())
    9091        return { data, hash };
     
    124125    auto data = mapFile(linkPath.data());
    125126
    126     return { data, computeSHA1(data) };
     127    return { data, computeSHA1(data, m_salt) };
    127128}
    128129
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.h

    r182803 r208931  
    4040    WTF_MAKE_NONCOPYABLE(BlobStorage);
    4141public:
    42     BlobStorage(const String& blobDirectoryPath);
     42    BlobStorage(const String& blobDirectoryPath, Salt);
    4343
    4444    struct Blob {
     
    6464
    6565    const String m_blobDirectoryPath;
     66    const Salt m_salt;
    6667
    6768    std::atomic<size_t> m_approximateSize { 0 };
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.cpp

    r190121 r208931  
    2929#if ENABLE(NETWORK_CACHE)
    3030
     31#include <WebCore/FileSystem.h>
    3132#include <fcntl.h>
    3233#include <sys/mman.h>
    3334#include <sys/stat.h>
     35#include <wtf/CryptographicallyRandomNumber.h>
    3436
    3537namespace WebKit {
     
    104106}
    105107
    106 SHA1::Digest computeSHA1(const Data& data)
     108SHA1::Digest computeSHA1(const Data& data, const Salt& salt)
    107109{
    108110    SHA1 sha1;
     111    sha1.addBytes(salt.data(), salt.size());
    109112    data.apply([&sha1](const uint8_t* data, size_t size) {
    110113        sha1.addBytes(data, size);
    111114        return true;
    112115    });
     116
    113117    SHA1::Digest digest;
    114118    sha1.computeHash(digest);
     
    125129}
    126130
     131static Salt makeSalt()
     132{
     133    Salt salt;
     134    static_assert(salt.size() == 8, "Salt size");
     135    *reinterpret_cast<uint32_t*>(&salt[0]) = cryptographicallyRandomNumber();
     136    *reinterpret_cast<uint32_t*>(&salt[4]) = cryptographicallyRandomNumber();
     137    return salt;
     138}
     139
     140Optional<Salt> readOrMakeSalt(const String& path)
     141{
     142    auto cpath = WebCore::fileSystemRepresentation(path);
     143    auto fd = open(cpath.data(), O_RDONLY, 0);
     144    Salt salt;
     145    auto bytesRead = read(fd, salt.data(), salt.size());
     146    close(fd);
     147    if (bytesRead != salt.size()) {
     148        salt = makeSalt();
     149
     150        unlink(cpath.data());
     151        fd = open(cpath.data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
     152        bool success = write(fd, salt.data(), salt.size()) == salt.size();
     153        close(fd);
     154        if (!success)
     155            return { };
     156    }
     157    return salt;
     158}
     159
    127160} // namespace NetworkCache
    128161} // namespace WebKit
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.h

    r203467 r208931  
    157157Data adoptAndMapFile(int fd, size_t offset, size_t);
    158158Data mapFile(const char* path);
    159 SHA1::Digest computeSHA1(const Data&);
     159
     160using Salt = std::array<uint8_t, 8>;
     161
     162Optional<Salt> readOrMakeSalt(const String& path);
     163SHA1::Digest computeSHA1(const Data&, const Salt&);
    160164
    161165}
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp

    r200275 r208931  
    3838namespace NetworkCache {
    3939
    40 static const String& noPartitionString()
    41 {
    42     static NeverDestroyed<String> noPartition(ASCIILiteral("No partition"));
    43     return noPartition;
    44 }
    45 
    4640Key::Key(const Key& o)
    4741    : m_partition(o.m_partition.isolatedCopy())
     
    5044    , m_range(o.m_range.isolatedCopy())
    5145    , m_hash(o.m_hash)
     46    , m_partitionHash(o.m_partitionHash)
    5247{
    5348}
    5449
    55 Key::Key(const String& partition, const String& type, const String& range, const String& identifier)
    56     : m_partition(partition.isEmpty() ? noPartitionString() : partition)
     50Key::Key(const String& partition, const String& type, const String& range, const String& identifier, const Salt& salt)
     51    : m_partition(partition)
    5752    , m_type(type)
    5853    , m_identifier(identifier)
    5954    , m_range(range)
    60     , m_hash(computeHash())
     55    , m_hash(computeHash(salt))
     56    , m_partitionHash(computePartitionHash(salt))
    6157{
    6258}
     
    6561    : m_identifier(WTF::HashTableDeletedValue)
    6662{
    67 }
    68 
    69 bool Key::hasPartition() const
    70 {
    71     return m_partition != noPartitionString();
    7263}
    7364
     
    9889}
    9990
    100 Key::HashType Key::computeHash() const
     91Key::HashType Key::computeHash(const Salt& salt) const
    10192{
    10293    // We don't really need a cryptographic hash. The key is always verified against the entry header.
    10394    // SHA1 just happens to be suitably sized, fast and available.
    10495    SHA1 sha1;
     96    sha1.addBytes(salt.data(), salt.size());
     97
    10598    hashString(sha1, m_partition);
    10699    hashString(sha1, m_type);
    107100    hashString(sha1, m_identifier);
    108101    hashString(sha1, m_range);
     102
    109103    SHA1::Digest hash;
    110104    sha1.computeHash(hash);
     
    112106}
    113107
    114 String Key::hashAsString() const
     108Key::HashType Key::computePartitionHash(const Salt& salt) const
     109{
     110    SHA1 sha1;
     111    sha1.addBytes(salt.data(), salt.size());
     112
     113    hashString(sha1, m_partition);
     114
     115    SHA1::Digest hash;
     116    sha1.computeHash(hash);
     117    return hash;
     118}
     119
     120String Key::hashAsString(const HashType& hash)
    115121{
    116122    StringBuilder builder;
    117123    builder.reserveCapacity(hashStringLength());
    118     for (auto byte : m_hash) {
     124    for (auto byte : hash) {
    119125        builder.append(upperNibbleToASCIIHexDigit(byte));
    120126        builder.append(lowerNibbleToASCIIHexDigit(byte));
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h

    r197879 r208931  
    2929#if ENABLE(NETWORK_CACHE)
    3030
     31#include "NetworkCacheData.h"
    3132#include <wtf/SHA1.h>
    3233#include <wtf/text/WTFString.h>
     
    4546    Key(const Key&);
    4647    Key(Key&&) = default;
    47     Key(const String& partition, const String& type, const String& range, const String& identifier);
     48    Key(const String& partition, const String& type, const String& range, const String& identifier, const Salt&);
    4849
    4950    Key& operator=(const Key&);
     
    5556    bool isNull() const { return m_identifier.isNull(); }
    5657
    57     bool hasPartition() const;
    5858    const String& partition() const { return m_partition; }
    5959    const String& identifier() const { return m_identifier; }
     
    6161    const String& range() const { return m_range; }
    6262
    63     HashType hash() const { return m_hash; }
     63    const HashType& hash() const { return m_hash; }
     64    const HashType& partitionHash() const { return m_partitionHash; }
    6465
    6566    static bool stringToHash(const String&, HashType&);
    6667
    6768    static size_t hashStringLength() { return 2 * sizeof(m_hash); }
    68     String hashAsString() const;
     69    String hashAsString() const { return hashAsString(m_hash); }
     70    String partitionHashAsString() const { return hashAsString(m_partitionHash); }
    6971
    7072    void encode(Encoder&) const;
     
    7577
    7678private:
    77     HashType computeHash() const;
     79    static String hashAsString(const HashType&);
     80    HashType computeHash(const Salt&) const;
     81    HashType computePartitionHash(const Salt&) const;
    7882
    7983    String m_partition;
     
    8286    String m_range;
    8387    HashType m_hash;
     88    HashType m_partitionHash;
    8489};
    8590
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp

    r207441 r208931  
    8080}
    8181
    82 static inline Key makeSubresourcesKey(const Key& resourceKey)
    83 {
    84     return Key(resourceKey.partition(), subresourcesType(), resourceKey.range(), resourceKey.identifier());
     82static inline Key makeSubresourcesKey(const Key& resourceKey, const Salt& salt)
     83{
     84    return Key(resourceKey.partition(), subresourcesType(), resourceKey.range(), resourceKey.identifier(), salt);
    8585}
    8686
     
    9191    revalidationRequest.setFirstPartyForCookies(subResourceInfo.firstPartyForCookies());
    9292#if ENABLE(CACHE_PARTITIONING)
    93     if (entry.key().hasPartition())
     93    if (!entry.key().partition().isEmpty())
    9494        revalidationRequest.setCachePartition(entry.key().partition());
    9595#endif
     
    227227            m_storage.store(m_existingEntry->encodeAsStorageRecord(), [](const Data&) { });
    228228        } else {
    229             SubresourcesEntry entry(makeSubresourcesKey(m_mainResourceKey), m_subresourceLoads);
     229            SubresourcesEntry entry(makeSubresourcesKey(m_mainResourceKey, m_storage.salt()), m_subresourceLoads);
    230230            m_storage.store(entry.encodeAsStorageRecord(), [](const Data&) { });
    231231        }
     
    522522{
    523523    ASSERT(storageKey.type() == "Resource");
    524     auto subresourcesStorageKey = makeSubresourcesKey(storageKey);
     524    auto subresourcesStorageKey = makeSubresourcesKey(storageKey, m_storage.salt());
    525525    m_storage.retrieve(subresourcesStorageKey, static_cast<unsigned>(ResourceLoadPriority::Medium), [completionHandler = WTFMove(completionHandler)](auto record) {
    526526        if (!record) {
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp

    r204466 r208931  
    4343namespace NetworkCache {
    4444
     45static const char saltFileName[] = "salt";
    4546static const char versionDirectoryPrefix[] = "Version ";
    4647static const char recordsDirectoryName[] = "Records";
     
    128129};
    129130
    130 std::unique_ptr<Storage> Storage::open(const String& cachePath)
    131 {
    132     ASSERT(RunLoop::isMain());
    133 
    134     if (!WebCore::makeAllDirectories(cachePath))
    135         return nullptr;
    136     return std::unique_ptr<Storage>(new Storage(cachePath));
    137 }
    138 
    139131static String makeVersionedDirectoryPath(const String& baseDirectoryPath)
    140132{
     
    153145}
    154146
    155 void traverseRecordsFiles(const String& recordsPath, const String& expectedType, const std::function<void (const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath)>& function)
    156 {
    157     traverseDirectory(recordsPath, [&recordsPath, &function, &expectedType](const String& partitionName, DirectoryEntryType entryType) {
     147static String makeSaltFilePath(const String& baseDirectoryPath)
     148{
     149    return WebCore::pathByAppendingComponent(makeVersionedDirectoryPath(baseDirectoryPath), saltFileName);
     150}
     151
     152std::unique_ptr<Storage> Storage::open(const String& cachePath)
     153{
     154    ASSERT(RunLoop::isMain());
     155
     156    if (!WebCore::makeAllDirectories(makeVersionedDirectoryPath(cachePath)))
     157        return nullptr;
     158    auto salt = readOrMakeSalt(makeSaltFilePath(cachePath));
     159    if (!salt)
     160        return nullptr;
     161    return std::unique_ptr<Storage>(new Storage(cachePath, *salt));
     162}
     163
     164void traverseRecordsFiles(const String& recordsPath, const String& expectedType, const RecordFileTraverseFunction& function)
     165{
     166    traverseDirectory(recordsPath, [&](const String& partitionName, DirectoryEntryType entryType) {
    158167        if (entryType != DirectoryEntryType::Directory)
    159168            return;
    160169        String partitionPath = WebCore::pathByAppendingComponent(recordsPath, partitionName);
    161         traverseDirectory(partitionPath, [&function, &partitionPath, &expectedType](const String& actualType, DirectoryEntryType entryType) {
     170        traverseDirectory(partitionPath, [&](const String& actualType, DirectoryEntryType entryType) {
    162171            if (entryType != DirectoryEntryType::Directory)
    163172                return;
     
    199208}
    200209
    201 Storage::Storage(const String& baseDirectoryPath)
     210Storage::Storage(const String& baseDirectoryPath, Salt salt)
    202211    : m_basePath(baseDirectoryPath)
    203212    , m_recordsPath(makeRecordsDirectoryPath(baseDirectoryPath))
     213    , m_salt(salt)
    204214    , m_readOperationTimeoutTimer(*this, &Storage::cancelAllReadOperations)
    205215    , m_writeOperationDispatchTimer(*this, &Storage::dispatchPendingWriteOperations)
     
    207217    , m_backgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.background", WorkQueue::Type::Concurrent, WorkQueue::QOS::Background))
    208218    , m_serialBackgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.serialBackground", WorkQueue::Type::Serial, WorkQueue::QOS::Background))
    209     , m_blobStorage(makeBlobDirectoryPath(baseDirectoryPath))
     219    , m_blobStorage(makeBlobDirectoryPath(baseDirectoryPath), m_salt)
    210220{
    211221    deleteOldVersions();
     
    327337String Storage::recordDirectoryPathForKey(const Key& key) const
    328338{
    329     ASSERT(!key.partition().isEmpty());
    330339    ASSERT(!key.type().isEmpty());
    331     return WebCore::pathByAppendingComponent(WebCore::pathByAppendingComponent(recordsPath(), key.partition()), key.type());
     340    return WebCore::pathByAppendingComponent(WebCore::pathByAppendingComponent(recordsPath(), key.partitionHashAsString()), key.type());
    332341}
    333342
     
    398407}
    399408
    400 static bool decodeRecordHeader(const Data& fileData, RecordMetaData& metaData, Data& headerData)
     409static bool decodeRecordHeader(const Data& fileData, RecordMetaData& metaData, Data& headerData, const Salt& salt)
    401410{
    402411    if (!decodeRecordMetaData(metaData, fileData)) {
     
    411420
    412421    headerData = fileData.subrange(metaData.headerOffset, metaData.headerSize);
    413     if (metaData.headerHash != computeSHA1(headerData)) {
     422    if (metaData.headerHash != computeSHA1(headerData, salt)) {
    414423        LOG(NetworkCacheStorage, "(NetworkProcess) header checksum mismatch");
    415424        return false;
     
    424433    RecordMetaData metaData;
    425434    Data headerData;
    426     if (!decodeRecordHeader(recordData, metaData, headerData))
     435    if (!decodeRecordHeader(recordData, metaData, headerData, m_salt))
    427436        return;
    428437
     
    441450            return;
    442451        bodyData = recordData.subrange(bodyOffset, metaData.bodySize);
    443         if (metaData.bodyHash != computeSHA1(bodyData))
     452        if (metaData.bodyHash != computeSHA1(bodyData, m_salt))
    444453            return;
    445454    }
     
    503512    RecordMetaData metaData(record.key);
    504513    metaData.epochRelativeTimeStamp = std::chrono::duration_cast<std::chrono::milliseconds>(record.timeStamp.time_since_epoch());
    505     metaData.headerHash = computeSHA1(record.header);
     514    metaData.headerHash = computeSHA1(record.header, m_salt);
    506515    metaData.headerSize = record.header.size();
    507     metaData.bodyHash = blob ? blob.value().hash : computeSHA1(record.body);
     516    metaData.bodyHash = blob ? blob.value().hash : computeSHA1(record.body, m_salt);
    508517    metaData.bodySize = record.body.size();
    509518    metaData.isBodyInline = !blob;
     
    824833                RecordMetaData metaData;
    825834                Data headerData;
    826                 if (decodeRecordHeader(fileData, metaData, headerData)) {
     835                if (decodeRecordHeader(fileData, metaData, headerData, m_salt)) {
    827836                    Record record {
    828837                        metaData.key,
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h

    r204977 r208931  
    8888    size_t approximateSize() const;
    8989
    90     static const unsigned version = 10;
     90    static const unsigned version = 11;
    9191#if PLATFORM(MAC)
    9292    /// Allow the last stable version of the cache to co-exist with the latest development one.
     
    9898    String recordsPath() const;
    9999
     100    const Salt& salt() const { return m_salt; }
     101
    100102    ~Storage();
    101103
    102104private:
    103     Storage(const String& directoryPath);
     105    Storage(const String& directoryPath, Salt);
    104106
    105107    String recordDirectoryPathForKey(const Key&) const;
     
    142144    const String m_recordsPath;
    143145
     146    const Salt m_salt;
     147
    144148    size_t m_capacity { std::numeric_limits<size_t>::max() };
    145149    size_t m_approximateRecordsSize { 0 };
     
    176180
    177181// FIXME: Remove, used by NetworkCacheStatistics only.
    178 void traverseRecordsFiles(const String& recordsPath, const String& type, const std::function<void (const String& fileName, const String& hashString, const String& type, bool isBodyBlob, const String& recordDirectoryPath)>&);
     182using RecordFileTraverseFunction = std::function<void (const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath)>;
     183void traverseRecordsFiles(const String& recordsPath, const String& type, const RecordFileTraverseFunction&);
    179184
    180185}
Note: See TracChangeset for help on using the changeset viewer.