| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 protected: | 51 protected: |
| 52 static void ReadTestKeyAndCert(std::string* key_data, | 52 static void ReadTestKeyAndCert(std::string* key_data, |
| 53 std::string* cert_data, | 53 std::string* cert_data, |
| 54 scoped_ptr<crypto::ECPrivateKey>* key) { | 54 scoped_ptr<crypto::ECPrivateKey>* key) { |
| 55 base::FilePath key_path = | 55 base::FilePath key_path = |
| 56 GetTestCertsDirectory().AppendASCII("unittest.originbound.key.der"); | 56 GetTestCertsDirectory().AppendASCII("unittest.originbound.key.der"); |
| 57 base::FilePath cert_path = | 57 base::FilePath cert_path = |
| 58 GetTestCertsDirectory().AppendASCII("unittest.originbound.der"); | 58 GetTestCertsDirectory().AppendASCII("unittest.originbound.der"); |
| 59 ASSERT_TRUE(base::ReadFileToString(key_path, key_data)); | 59 ASSERT_TRUE(base::ReadFileToString(key_path, key_data)); |
| 60 ASSERT_TRUE(base::ReadFileToString(cert_path, cert_data)); | 60 ASSERT_TRUE(base::ReadFileToString(cert_path, cert_data)); |
| 61 std::vector<uint8> private_key(key_data->size()); | 61 std::vector<uint8_t> private_key(key_data->size()); |
| 62 memcpy(private_key.data(), key_data->data(), key_data->size()); | 62 memcpy(private_key.data(), key_data->data(), key_data->size()); |
| 63 base::StringPiece spki; | 63 base::StringPiece spki; |
| 64 ASSERT_TRUE(asn1::ExtractSPKIFromDERCert(*cert_data, &spki)); | 64 ASSERT_TRUE(asn1::ExtractSPKIFromDERCert(*cert_data, &spki)); |
| 65 std::vector<uint8> public_key(spki.size()); | 65 std::vector<uint8_t> public_key(spki.size()); |
| 66 memcpy(public_key.data(), spki.data(), spki.size()); | 66 memcpy(public_key.data(), spki.data(), spki.size()); |
| 67 key->reset(crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 67 key->reset(crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 68 ChannelIDService::kEPKIPassword, private_key, public_key)); | 68 ChannelIDService::kEPKIPassword, private_key, public_key)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 static base::Time GetTestCertExpirationTime() { | 71 static base::Time GetTestCertExpirationTime() { |
| 72 // Cert expiration time from 'openssl asn1parse -inform der -in | 72 // Cert expiration time from 'openssl asn1parse -inform der -in |
| 73 // unittest.originbound.der': | 73 // unittest.originbound.der': |
| 74 // UTCTIME :160507022239Z | 74 // UTCTIME :160507022239Z |
| 75 // base::Time::FromUTCExploded can't generate values past 2038 on 32-bit | 75 // base::Time::FromUTCExploded can't generate values past 2038 on 32-bit |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 sql::Statement smt(db.GetUniqueStatement( | 533 sql::Statement smt(db.GetUniqueStatement( |
| 534 "SELECT value FROM meta WHERE key = \"version\"")); | 534 "SELECT value FROM meta WHERE key = \"version\"")); |
| 535 ASSERT_TRUE(smt.Step()); | 535 ASSERT_TRUE(smt.Step()); |
| 536 EXPECT_EQ(5, smt.ColumnInt(0)); | 536 EXPECT_EQ(5, smt.ColumnInt(0)); |
| 537 EXPECT_FALSE(smt.Step()); | 537 EXPECT_FALSE(smt.Step()); |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace net | 542 } // namespace net |
| OLD | NEW |