OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_android.h" | 5 #include "net/ssl/ssl_platform_key_android.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 env, reinterpret_cast<const uint8_t*>(pkcs8_key.data()), | 41 env, reinterpret_cast<const uint8_t*>(pkcs8_key.data()), |
42 pkcs8_key.size())); | 42 pkcs8_key.size())); |
43 | 43 |
44 ScopedJava key(Java_AndroidKeyStoreTestUtil_createPrivateKeyFromPKCS8( | 44 ScopedJava key(Java_AndroidKeyStoreTestUtil_createPrivateKeyFromPKCS8( |
45 env, key_type, bytes)); | 45 env, key_type, bytes)); |
46 | 46 |
47 return key; | 47 return key; |
48 } | 48 } |
49 | 49 |
50 struct TestKey { | 50 struct TestKey { |
| 51 const char* name; |
51 const char* cert_file; | 52 const char* cert_file; |
52 const char* key_file; | 53 const char* key_file; |
53 android::PrivateKeyType android_key_type; | 54 android::PrivateKeyType android_key_type; |
54 SSLPrivateKey::Type key_type; | |
55 }; | 55 }; |
56 | 56 |
57 const TestKey kTestKeys[] = { | 57 const TestKey kTestKeys[] = { |
58 {"client_1.pem", "client_1.pk8", android::PRIVATE_KEY_TYPE_RSA, | 58 {"RSA", "client_1.pem", "client_1.pk8", android::PRIVATE_KEY_TYPE_RSA}, |
59 SSLPrivateKey::Type::RSA}, | 59 {"ECDSA_P256", "client_4.pem", "client_4.pk8", |
60 {"client_4.pem", "client_4.pk8", android::PRIVATE_KEY_TYPE_ECDSA, | 60 android::PRIVATE_KEY_TYPE_ECDSA}, |
61 SSLPrivateKey::Type::ECDSA_P256}, | 61 {"ECDSA_P384", "client_5.pem", "client_5.pk8", |
62 {"client_5.pem", "client_5.pk8", android::PRIVATE_KEY_TYPE_ECDSA, | 62 android::PRIVATE_KEY_TYPE_ECDSA}, |
63 SSLPrivateKey::Type::ECDSA_P384}, | 63 {"ECDSA_P521", "client_6.pem", "client_6.pk8", |
64 {"client_6.pem", "client_6.pk8", android::PRIVATE_KEY_TYPE_ECDSA, | 64 android::PRIVATE_KEY_TYPE_ECDSA}, |
65 SSLPrivateKey::Type::ECDSA_P521}, | |
66 }; | 65 }; |
67 | 66 |
68 std::string TestKeyToString(const testing::TestParamInfo<TestKey>& params) { | 67 std::string TestKeyToString(const testing::TestParamInfo<TestKey>& params) { |
69 return SSLPrivateKeyTypeToString(params.param.key_type); | 68 return params.param.name; |
70 } | 69 } |
71 | 70 |
72 } // namespace | 71 } // namespace |
73 | 72 |
74 class SSLPlatformKeyAndroidTest : public testing::TestWithParam<TestKey> {}; | 73 class SSLPlatformKeyAndroidTest : public testing::TestWithParam<TestKey> {}; |
75 | 74 |
76 TEST_P(SSLPlatformKeyAndroidTest, Matches) { | 75 TEST_P(SSLPlatformKeyAndroidTest, Matches) { |
77 const TestKey& test_key = GetParam(); | 76 const TestKey& test_key = GetParam(); |
78 | 77 |
79 scoped_refptr<X509Certificate> cert = | 78 scoped_refptr<X509Certificate> cert = |
(...skipping 18 matching lines...) Expand all Loading... |
98 | 97 |
99 TestSSLPrivateKeyMatches(key.get(), key_bytes); | 98 TestSSLPrivateKeyMatches(key.get(), key_bytes); |
100 } | 99 } |
101 | 100 |
102 INSTANTIATE_TEST_CASE_P(, | 101 INSTANTIATE_TEST_CASE_P(, |
103 SSLPlatformKeyAndroidTest, | 102 SSLPlatformKeyAndroidTest, |
104 testing::ValuesIn(kTestKeys), | 103 testing::ValuesIn(kTestKeys), |
105 TestKeyToString); | 104 TestKeyToString); |
106 | 105 |
107 } // namespace net | 106 } // namespace net |
OLD | NEW |