| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "net/ssl/ssl_platform_key.h" | 5 #include "net/ssl/ssl_platform_key_nss.h" |
| 6 | 6 |
| 7 #include <keyhi.h> | 7 #include <keyhi.h> |
| 8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| 11 | 11 |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 ASSERT_TRUE(cert); | 114 ASSERT_TRUE(cert); |
| 115 ASSERT_TRUE(ImportClientCertToSlot(cert, test_db.slot())); | 115 ASSERT_TRUE(ImportClientCertToSlot(cert, test_db.slot())); |
| 116 } else { | 116 } else { |
| 117 cert = ImportClientCertAndKeyFromFile(GetTestCertsDirectory(), | 117 cert = ImportClientCertAndKeyFromFile(GetTestCertsDirectory(), |
| 118 test_key.cert_file, test_key.key_file, | 118 test_key.cert_file, test_key.key_file, |
| 119 test_db.slot()); | 119 test_db.slot()); |
| 120 ASSERT_TRUE(cert); | 120 ASSERT_TRUE(cert); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Look up the key. | 123 // Look up the key. |
| 124 scoped_refptr<SSLPrivateKey> key = FetchClientCertPrivateKey(cert.get()); | 124 scoped_refptr<SSLPrivateKey> key = |
| 125 FetchClientCertPrivateKey(cert.get(), nullptr); |
| 125 ASSERT_TRUE(key); | 126 ASSERT_TRUE(key); |
| 126 | 127 |
| 127 // All NSS keys are expected to have the same hash preferences. | 128 // All NSS keys are expected to have the same hash preferences. |
| 128 std::vector<SSLPrivateKey::Hash> expected_hashes = { | 129 std::vector<SSLPrivateKey::Hash> expected_hashes = { |
| 129 SSLPrivateKey::Hash::SHA512, SSLPrivateKey::Hash::SHA384, | 130 SSLPrivateKey::Hash::SHA512, SSLPrivateKey::Hash::SHA384, |
| 130 SSLPrivateKey::Hash::SHA256, SSLPrivateKey::Hash::SHA1, | 131 SSLPrivateKey::Hash::SHA256, SSLPrivateKey::Hash::SHA1, |
| 131 }; | 132 }; |
| 132 EXPECT_EQ(expected_hashes, key->GetDigestPreferences()); | 133 EXPECT_EQ(expected_hashes, key->GetDigestPreferences()); |
| 133 | 134 |
| 134 TestSSLPrivateKeyMatches(key.get(), pkcs8); | 135 TestSSLPrivateKeyMatches(key.get(), pkcs8); |
| 135 } | 136 } |
| 136 | 137 |
| 137 INSTANTIATE_TEST_CASE_P(, | 138 INSTANTIATE_TEST_CASE_P(, |
| 138 SSLPlatformKeyNSSTest, | 139 SSLPlatformKeyNSSTest, |
| 139 testing::ValuesIn(kTestKeys), | 140 testing::ValuesIn(kTestKeys), |
| 140 TestKeyToString); | 141 TestKeyToString); |
| 141 | 142 |
| 142 } // namespace net | 143 } // namespace net |
| OLD | NEW |