Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: net/ssl/ssl_platform_key_mac_unittest.cc

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: removed no longer needed forward declaration Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ssl/ssl_platform_key_mac.cc ('k') | net/ssl/ssl_platform_key_nss.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_mac.h" 5 #include "net/ssl/ssl_platform_key_mac.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 ASSERT_TRUE(scoped_keychain.Initialize()); 62 ASSERT_TRUE(scoped_keychain.Initialize());
63 SecKeychainRef keychain = scoped_keychain.keychain(); 63 SecKeychainRef keychain = scoped_keychain.keychain();
64 64
65 // Import cert and key to the keychain. 65 // Import cert and key to the keychain.
66 base::ScopedCFTypeRef<SecIdentityRef> sec_identity( 66 base::ScopedCFTypeRef<SecIdentityRef> sec_identity(
67 ImportCertAndKeyToKeychain(cert.get(), pkcs8, keychain)); 67 ImportCertAndKeyToKeychain(cert.get(), pkcs8, keychain));
68 ASSERT_TRUE(sec_identity); 68 ASSERT_TRUE(sec_identity);
69 69
70 // Finally, test the code to look up the key. 70 // Finally, test the code to look up the key.
71 scoped_refptr<SSLPrivateKey> key = 71 scoped_refptr<SSLPrivateKey> key =
72 FetchClientCertPrivateKeyFromKeychain(cert.get(), keychain); 72 CreateSSLPrivateKeyForSecIdentity(cert.get(), sec_identity.get());
73 ASSERT_TRUE(key); 73 ASSERT_TRUE(key);
74 74
75 // All Mac keys are expected to have the same hash preferences. 75 // All Mac keys are expected to have the same hash preferences.
76 std::vector<SSLPrivateKey::Hash> expected_hashes = { 76 std::vector<SSLPrivateKey::Hash> expected_hashes = {
77 SSLPrivateKey::Hash::SHA512, SSLPrivateKey::Hash::SHA384, 77 SSLPrivateKey::Hash::SHA512, SSLPrivateKey::Hash::SHA384,
78 SSLPrivateKey::Hash::SHA256, SSLPrivateKey::Hash::SHA1, 78 SSLPrivateKey::Hash::SHA256, SSLPrivateKey::Hash::SHA1,
79 }; 79 };
80 EXPECT_EQ(expected_hashes, key->GetDigestPreferences()); 80 EXPECT_EQ(expected_hashes, key->GetDigestPreferences());
81 81
82 TestSSLPrivateKeyMatches(key.get(), pkcs8); 82 TestSSLPrivateKeyMatches(key.get(), pkcs8);
83 } 83 }
84 84
85 INSTANTIATE_TEST_CASE_P(, 85 INSTANTIATE_TEST_CASE_P(,
86 SSLPlatformKeyMacTest, 86 SSLPlatformKeyMacTest,
87 testing::ValuesIn(kTestKeys), 87 testing::ValuesIn(kTestKeys),
88 TestKeyToString); 88 TestKeyToString);
89 89
90 } // namespace net 90 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/ssl_platform_key_mac.cc ('k') | net/ssl/ssl_platform_key_nss.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698