| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/net/sqlite_persistent_cookie_store.h" | 5 #include "content/browser/net/sqlite_persistent_cookie_store.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 const base::FilePath::CharType kCookieFilename[] = FILE_PATH_LITERAL("Cookies"); | 38 const base::FilePath::CharType kCookieFilename[] = FILE_PATH_LITERAL("Cookies"); |
| 39 | 39 |
| 40 class CookieCryptor : public content::CookieCryptoDelegate { | 40 class CookieCryptor : public content::CookieCryptoDelegate { |
| 41 public: | 41 public: |
| 42 CookieCryptor(); | 42 CookieCryptor(); |
| 43 virtual bool EncryptString(const std::string& plaintext, | 43 bool EncryptString(const std::string& plaintext, |
| 44 std::string* ciphertext) override; | 44 std::string* ciphertext) override; |
| 45 virtual bool DecryptString(const std::string& ciphertext, | 45 bool DecryptString(const std::string& ciphertext, |
| 46 std::string* plaintext) override; | 46 std::string* plaintext) override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 scoped_ptr<crypto::SymmetricKey> key_; | 49 scoped_ptr<crypto::SymmetricKey> key_; |
| 50 crypto::Encryptor encryptor_; | 50 crypto::Encryptor encryptor_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 CookieCryptor::CookieCryptor() : key_( | 53 CookieCryptor::CookieCryptor() : key_( |
| 54 crypto::SymmetricKey::DeriveKeyFromPassword( | 54 crypto::SymmetricKey::DeriveKeyFromPassword( |
| 55 crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256)) { | 55 crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256)) { |
| 56 std::string iv("the iv: 16 bytes"); | 56 std::string iv("the iv: 16 bytes"); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 EXPECT_EQ(2, resultcount); | 599 EXPECT_EQ(2, resultcount); |
| 600 | 600 |
| 601 // Verify that "encrypted_value" is NOT visible in the file. | 601 // Verify that "encrypted_value" is NOT visible in the file. |
| 602 contents = ReadRawDBContents(); | 602 contents = ReadRawDBContents(); |
| 603 EXPECT_NE(0U, contents.length()); | 603 EXPECT_NE(0U, contents.length()); |
| 604 EXPECT_EQ(contents.find("encrypted_value123XYZ"), std::string::npos); | 604 EXPECT_EQ(contents.find("encrypted_value123XYZ"), std::string::npos); |
| 605 EXPECT_EQ(contents.find("something456ABC"), std::string::npos); | 605 EXPECT_EQ(contents.find("something456ABC"), std::string::npos); |
| 606 } | 606 } |
| 607 | 607 |
| 608 } // namespace content | 608 } // namespace content |
| OLD | NEW |