OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "crypto/ec_private_key.h" | 5 #include "crypto/ec_private_key.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <vector> | 9 #include <vector> |
8 | 10 |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 // Generate random private keys. Export, then re-import. We should get | 15 // Generate random private keys. Export, then re-import. We should get |
14 // back the same exact public key, and the private key should have the same | 16 // back the same exact public key, and the private key should have the same |
15 // value and elliptic curve params. | 17 // value and elliptic curve params. |
16 TEST(ECPrivateKeyUnitTest, InitRandomTest) { | 18 TEST(ECPrivateKeyUnitTest, InitRandomTest) { |
17 const std::string password1; | 19 const std::string password1; |
18 const std::string password2 = "test"; | 20 const std::string password2 = "test"; |
19 | 21 |
20 scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create()); | 22 scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create()); |
21 scoped_ptr<crypto::ECPrivateKey> keypair2(crypto::ECPrivateKey::Create()); | 23 scoped_ptr<crypto::ECPrivateKey> keypair2(crypto::ECPrivateKey::Create()); |
22 ASSERT_TRUE(keypair1.get()); | 24 ASSERT_TRUE(keypair1.get()); |
23 ASSERT_TRUE(keypair2.get()); | 25 ASSERT_TRUE(keypair2.get()); |
24 | 26 |
25 std::vector<uint8> key1value; | 27 std::vector<uint8_t> key1value; |
26 std::vector<uint8> key2value; | 28 std::vector<uint8_t> key2value; |
27 std::vector<uint8> key1params; | 29 std::vector<uint8_t> key1params; |
28 std::vector<uint8> key2params; | 30 std::vector<uint8_t> key2params; |
29 EXPECT_TRUE(keypair1->ExportValue(&key1value)); | 31 EXPECT_TRUE(keypair1->ExportValue(&key1value)); |
30 EXPECT_TRUE(keypair2->ExportValue(&key2value)); | 32 EXPECT_TRUE(keypair2->ExportValue(&key2value)); |
31 EXPECT_TRUE(keypair1->ExportECParams(&key1params)); | 33 EXPECT_TRUE(keypair1->ExportECParams(&key1params)); |
32 EXPECT_TRUE(keypair2->ExportECParams(&key2params)); | 34 EXPECT_TRUE(keypair2->ExportECParams(&key2params)); |
33 | 35 |
34 std::vector<uint8> privkey1; | 36 std::vector<uint8_t> privkey1; |
35 std::vector<uint8> privkey2; | 37 std::vector<uint8_t> privkey2; |
36 std::vector<uint8> pubkey1; | 38 std::vector<uint8_t> pubkey1; |
37 std::vector<uint8> pubkey2; | 39 std::vector<uint8_t> pubkey2; |
38 std::string raw_pubkey1; | 40 std::string raw_pubkey1; |
39 std::string raw_pubkey2; | 41 std::string raw_pubkey2; |
40 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(password1, 1, &privkey1)); | 42 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(password1, 1, &privkey1)); |
41 ASSERT_TRUE(keypair2->ExportEncryptedPrivateKey(password2, 1, &privkey2)); | 43 ASSERT_TRUE(keypair2->ExportEncryptedPrivateKey(password2, 1, &privkey2)); |
42 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); | 44 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); |
43 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); | 45 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); |
44 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); | 46 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); |
45 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); | 47 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); |
46 | 48 |
47 scoped_ptr<crypto::ECPrivateKey> keypair3( | 49 scoped_ptr<crypto::ECPrivateKey> keypair3( |
48 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 50 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
49 password1, privkey1, pubkey1)); | 51 password1, privkey1, pubkey1)); |
50 scoped_ptr<crypto::ECPrivateKey> keypair4( | 52 scoped_ptr<crypto::ECPrivateKey> keypair4( |
51 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 53 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
52 password2, privkey2, pubkey2)); | 54 password2, privkey2, pubkey2)); |
53 ASSERT_TRUE(keypair3.get()); | 55 ASSERT_TRUE(keypair3.get()); |
54 ASSERT_TRUE(keypair4.get()); | 56 ASSERT_TRUE(keypair4.get()); |
55 | 57 |
56 std::vector<uint8> key3value; | 58 std::vector<uint8_t> key3value; |
57 std::vector<uint8> key4value; | 59 std::vector<uint8_t> key4value; |
58 std::vector<uint8> key3params; | 60 std::vector<uint8_t> key3params; |
59 std::vector<uint8> key4params; | 61 std::vector<uint8_t> key4params; |
60 EXPECT_TRUE(keypair3->ExportValue(&key3value)); | 62 EXPECT_TRUE(keypair3->ExportValue(&key3value)); |
61 EXPECT_TRUE(keypair4->ExportValue(&key4value)); | 63 EXPECT_TRUE(keypair4->ExportValue(&key4value)); |
62 EXPECT_TRUE(keypair3->ExportECParams(&key3params)); | 64 EXPECT_TRUE(keypair3->ExportECParams(&key3params)); |
63 EXPECT_TRUE(keypair4->ExportECParams(&key4params)); | 65 EXPECT_TRUE(keypair4->ExportECParams(&key4params)); |
64 | 66 |
65 EXPECT_EQ(key1value, key3value); | 67 EXPECT_EQ(key1value, key3value); |
66 EXPECT_EQ(key2value, key4value); | 68 EXPECT_EQ(key2value, key4value); |
67 EXPECT_EQ(key1params, key3params); | 69 EXPECT_EQ(key1params, key3params); |
68 EXPECT_EQ(key2params, key4params); | 70 EXPECT_EQ(key2params, key4params); |
69 | 71 |
70 std::vector<uint8> pubkey3; | 72 std::vector<uint8_t> pubkey3; |
71 std::vector<uint8> pubkey4; | 73 std::vector<uint8_t> pubkey4; |
72 std::string raw_pubkey3; | 74 std::string raw_pubkey3; |
73 std::string raw_pubkey4; | 75 std::string raw_pubkey4; |
74 EXPECT_TRUE(keypair3->ExportPublicKey(&pubkey3)); | 76 EXPECT_TRUE(keypair3->ExportPublicKey(&pubkey3)); |
75 EXPECT_TRUE(keypair4->ExportPublicKey(&pubkey4)); | 77 EXPECT_TRUE(keypair4->ExportPublicKey(&pubkey4)); |
76 EXPECT_TRUE(keypair3->ExportRawPublicKey(&raw_pubkey3)); | 78 EXPECT_TRUE(keypair3->ExportRawPublicKey(&raw_pubkey3)); |
77 EXPECT_TRUE(keypair4->ExportRawPublicKey(&raw_pubkey4)); | 79 EXPECT_TRUE(keypair4->ExportRawPublicKey(&raw_pubkey4)); |
78 | 80 |
79 EXPECT_EQ(pubkey1, pubkey3); | 81 EXPECT_EQ(pubkey1, pubkey3); |
80 EXPECT_EQ(pubkey2, pubkey4); | 82 EXPECT_EQ(pubkey2, pubkey4); |
81 EXPECT_EQ(raw_pubkey1, raw_pubkey3); | 83 EXPECT_EQ(raw_pubkey1, raw_pubkey3); |
82 EXPECT_EQ(raw_pubkey2, raw_pubkey4); | 84 EXPECT_EQ(raw_pubkey2, raw_pubkey4); |
83 } | 85 } |
84 | 86 |
85 TEST(ECPrivateKeyUnitTest, Copy) { | 87 TEST(ECPrivateKeyUnitTest, Copy) { |
86 scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create()); | 88 scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create()); |
87 scoped_ptr<crypto::ECPrivateKey> keypair2(keypair1->Copy()); | 89 scoped_ptr<crypto::ECPrivateKey> keypair2(keypair1->Copy()); |
88 ASSERT_TRUE(keypair1.get()); | 90 ASSERT_TRUE(keypair1.get()); |
89 ASSERT_TRUE(keypair2.get()); | 91 ASSERT_TRUE(keypair2.get()); |
90 | 92 |
91 std::vector<uint8> key1value; | 93 std::vector<uint8_t> key1value; |
92 std::vector<uint8> key2value; | 94 std::vector<uint8_t> key2value; |
93 EXPECT_TRUE(keypair1->ExportValue(&key1value)); | 95 EXPECT_TRUE(keypair1->ExportValue(&key1value)); |
94 EXPECT_TRUE(keypair2->ExportValue(&key2value)); | 96 EXPECT_TRUE(keypair2->ExportValue(&key2value)); |
95 EXPECT_EQ(key1value, key2value); | 97 EXPECT_EQ(key1value, key2value); |
96 | 98 |
97 std::vector<uint8> key1params; | 99 std::vector<uint8_t> key1params; |
98 std::vector<uint8> key2params; | 100 std::vector<uint8_t> key2params; |
99 EXPECT_TRUE(keypair1->ExportECParams(&key1params)); | 101 EXPECT_TRUE(keypair1->ExportECParams(&key1params)); |
100 EXPECT_TRUE(keypair2->ExportECParams(&key2params)); | 102 EXPECT_TRUE(keypair2->ExportECParams(&key2params)); |
101 EXPECT_EQ(key1params, key2params); | 103 EXPECT_EQ(key1params, key2params); |
102 | 104 |
103 std::vector<uint8> pubkey1; | 105 std::vector<uint8_t> pubkey1; |
104 std::vector<uint8> pubkey2; | 106 std::vector<uint8_t> pubkey2; |
105 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); | 107 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); |
106 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); | 108 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); |
107 EXPECT_EQ(pubkey1, pubkey2); | 109 EXPECT_EQ(pubkey1, pubkey2); |
108 | 110 |
109 std::string raw_pubkey1; | 111 std::string raw_pubkey1; |
110 std::string raw_pubkey2; | 112 std::string raw_pubkey2; |
111 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); | 113 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); |
112 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); | 114 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); |
113 EXPECT_EQ(raw_pubkey1, raw_pubkey2); | 115 EXPECT_EQ(raw_pubkey1, raw_pubkey2); |
114 } | 116 } |
115 | 117 |
116 TEST(ECPrivateKeyUnitTest, BadPasswordTest) { | 118 TEST(ECPrivateKeyUnitTest, BadPasswordTest) { |
117 const std::string password1; | 119 const std::string password1; |
118 const std::string password2 = "test"; | 120 const std::string password2 = "test"; |
119 | 121 |
120 scoped_ptr<crypto::ECPrivateKey> keypair1( | 122 scoped_ptr<crypto::ECPrivateKey> keypair1( |
121 crypto::ECPrivateKey::Create()); | 123 crypto::ECPrivateKey::Create()); |
122 ASSERT_TRUE(keypair1.get()); | 124 ASSERT_TRUE(keypair1.get()); |
123 | 125 |
124 std::vector<uint8> privkey1; | 126 std::vector<uint8_t> privkey1; |
125 std::vector<uint8> pubkey1; | 127 std::vector<uint8_t> pubkey1; |
126 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey( | 128 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey( |
127 password1, 1, &privkey1)); | 129 password1, 1, &privkey1)); |
128 ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1)); | 130 ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1)); |
129 | 131 |
130 scoped_ptr<crypto::ECPrivateKey> keypair2( | 132 scoped_ptr<crypto::ECPrivateKey> keypair2( |
131 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 133 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
132 password2, privkey1, pubkey1)); | 134 password2, privkey1, pubkey1)); |
133 ASSERT_FALSE(keypair2.get()); | 135 ASSERT_FALSE(keypair2.get()); |
134 } | 136 } |
135 | 137 |
(...skipping 20 matching lines...) Expand all Loading... |
156 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, | 158 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, |
157 0x42, 0x00, 0x04, 0x85, 0x92, 0x9e, 0x95, 0x5c, 0x6b, 0x9e, 0xd6, 0x1e, | 159 0x42, 0x00, 0x04, 0x85, 0x92, 0x9e, 0x95, 0x5c, 0x6b, 0x9e, 0xd6, 0x1e, |
158 0xb8, 0x64, 0xea, 0xc2, 0xb3, 0xef, 0x18, 0xed, 0x3a, 0x5e, 0xc4, 0x5c, | 160 0xb8, 0x64, 0xea, 0xc2, 0xb3, 0xef, 0x18, 0xed, 0x3a, 0x5e, 0xc4, 0x5c, |
159 0x15, 0x37, 0x6a, 0xe9, 0xaa, 0x0b, 0x34, 0x03, 0xfd, 0xca, 0x83, 0x0f, | 161 0x15, 0x37, 0x6a, 0xe9, 0xaa, 0x0b, 0x34, 0x03, 0xfd, 0xca, 0x83, 0x0f, |
160 0xd7, 0x5c, 0x5d, 0xc5, 0x53, 0x6e, 0xe5, 0xa9, 0x33, 0xd5, 0xcc, 0xab, | 162 0xd7, 0x5c, 0x5d, 0xc5, 0x53, 0x6e, 0xe5, 0xa9, 0x33, 0xd5, 0xcc, 0xab, |
161 0x53, 0x78, 0xdd, 0xd6, 0x12, 0x3a, 0x5e, 0xeb, 0xbf, 0xdf, 0x16, 0xd3, | 163 0x53, 0x78, 0xdd, 0xd6, 0x12, 0x3a, 0x5e, 0xeb, 0xbf, 0xdf, 0x16, 0xd3, |
162 0x2c, 0x3b, 0xe8, 0xdb, 0x19, 0xfc, 0x5e}; | 164 0x2c, 0x3b, 0xe8, 0xdb, 0x19, 0xfc, 0x5e}; |
163 | 165 |
164 scoped_ptr<crypto::ECPrivateKey> keypair_nss( | 166 scoped_ptr<crypto::ECPrivateKey> keypair_nss( |
165 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 167 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
166 "", | 168 "", std::vector<uint8_t>(nss_key, nss_key + arraysize(nss_key)), |
167 std::vector<uint8>(nss_key, nss_key + arraysize(nss_key)), | 169 std::vector<uint8_t>(nss_pub_key, |
168 std::vector<uint8>(nss_pub_key, | 170 nss_pub_key + arraysize(nss_pub_key)))); |
169 nss_pub_key + arraysize(nss_pub_key)))); | |
170 | 171 |
171 EXPECT_TRUE(keypair_nss.get()); | 172 EXPECT_TRUE(keypair_nss.get()); |
172 } | 173 } |
173 | 174 |
174 // Although the plan is to transition from OpenSSL to NSS, ensure NSS can import | 175 // Although the plan is to transition from OpenSSL to NSS, ensure NSS can import |
175 // OpenSSL's format so that it is possible to rollback. | 176 // OpenSSL's format so that it is possible to rollback. |
176 TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) { | 177 TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) { |
177 static const unsigned char openssl_key[] = { | 178 static const unsigned char openssl_key[] = { |
178 0x30, 0x81, 0xb0, 0x30, 0x1b, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, | 179 0x30, 0x81, 0xb0, 0x30, 0x1b, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, |
179 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30, 0x0d, 0x04, 0x08, 0xb2, 0xfe, 0x68, | 180 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30, 0x0d, 0x04, 0x08, 0xb2, 0xfe, 0x68, |
(...skipping 15 matching lines...) Expand all Loading... |
195 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, | 196 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, |
196 0x42, 0x00, 0x04, 0xb9, 0xda, 0x0d, 0x71, 0x60, 0xb3, 0x63, 0x28, 0x22, | 197 0x42, 0x00, 0x04, 0xb9, 0xda, 0x0d, 0x71, 0x60, 0xb3, 0x63, 0x28, 0x22, |
197 0x67, 0xe7, 0xe0, 0xa3, 0xf8, 0x00, 0x8e, 0x4c, 0x89, 0xed, 0x31, 0x34, | 198 0x67, 0xe7, 0xe0, 0xa3, 0xf8, 0x00, 0x8e, 0x4c, 0x89, 0xed, 0x31, 0x34, |
198 0xf6, 0xdb, 0xc4, 0xfe, 0x0b, 0x5d, 0xe1, 0x11, 0x39, 0x49, 0xa6, 0x50, | 199 0xf6, 0xdb, 0xc4, 0xfe, 0x0b, 0x5d, 0xe1, 0x11, 0x39, 0x49, 0xa6, 0x50, |
199 0xa8, 0xe3, 0x4a, 0xc0, 0x40, 0x88, 0xb8, 0x38, 0x3f, 0x56, 0xfb, 0x33, | 200 0xa8, 0xe3, 0x4a, 0xc0, 0x40, 0x88, 0xb8, 0x38, 0x3f, 0x56, 0xfb, 0x33, |
200 0x8d, 0xd4, 0x64, 0x91, 0xd6, 0x15, 0x77, 0x42, 0x27, 0xc5, 0xaa, 0x44, | 201 0x8d, 0xd4, 0x64, 0x91, 0xd6, 0x15, 0x77, 0x42, 0x27, 0xc5, 0xaa, 0x44, |
201 0xff, 0xab, 0x4d, 0xb5, 0x7e, 0x25, 0x3d}; | 202 0xff, 0xab, 0x4d, 0xb5, 0x7e, 0x25, 0x3d}; |
202 | 203 |
203 scoped_ptr<crypto::ECPrivateKey> keypair_openssl( | 204 scoped_ptr<crypto::ECPrivateKey> keypair_openssl( |
204 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 205 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
205 "", | 206 "", std::vector<uint8_t>(openssl_key, |
206 std::vector<uint8>(openssl_key, openssl_key + arraysize(openssl_key)), | 207 openssl_key + arraysize(openssl_key)), |
207 std::vector<uint8>(openssl_pub_key, | 208 std::vector<uint8_t>(openssl_pub_key, |
208 openssl_pub_key + arraysize(openssl_pub_key)))); | 209 openssl_pub_key + arraysize(openssl_pub_key)))); |
209 | 210 |
210 EXPECT_TRUE(keypair_openssl.get()); | 211 EXPECT_TRUE(keypair_openssl.get()); |
211 } | 212 } |
212 | 213 |
213 // The Android code writes out Channel IDs differently from the NSS | 214 // The Android code writes out Channel IDs differently from the NSS |
214 // implementation; the empty password is converted to "\0\0". The OpenSSL port | 215 // implementation; the empty password is converted to "\0\0". The OpenSSL port |
215 // should support either. | 216 // should support either. |
216 #if defined(USE_OPENSSL) | 217 #if defined(USE_OPENSSL) |
217 TEST(ECPrivateKeyUnitTest, LoadOldOpenSSLKeyTest) { | 218 TEST(ECPrivateKeyUnitTest, LoadOldOpenSSLKeyTest) { |
218 static const unsigned char openssl_key[] = { | 219 static const unsigned char openssl_key[] = { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51, | 278 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51, |
278 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0xde, 0x09, 0x08, 0x07, 0x03, | 279 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0xde, 0x09, 0x08, 0x07, 0x03, |
279 0x2e, 0x8f, 0x37, 0x9a, 0xd5, 0xad, 0xe5, 0xc6, 0x9d, 0xd4, 0x63, 0xc7, | 280 0x2e, 0x8f, 0x37, 0x9a, 0xd5, 0xad, 0xe5, 0xc6, 0x9d, 0xd4, 0x63, 0xc7, |
280 0x4a, 0xe7, 0x20, 0xcb, 0x90, 0xa0, 0x1f, 0x18, 0x18, 0x72, 0xb5, 0x21, | 281 0x4a, 0xe7, 0x20, 0xcb, 0x90, 0xa0, 0x1f, 0x18, 0x18, 0x72, 0xb5, 0x21, |
281 0x88, 0x38, 0xc0, 0xdb, 0xba, 0xf6, 0x99, 0xd8, 0xa5, 0x3b, 0x83, 0xe9, | 282 0x88, 0x38, 0xc0, 0xdb, 0xba, 0xf6, 0x99, 0xd8, 0xa5, 0x3b, 0x83, 0xe9, |
282 0xe3, 0xd5, 0x61, 0x99, 0x73, 0x42, 0xc6, 0x6c, 0xe8, 0x0a, 0x95, 0x40, | 283 0xe3, 0xd5, 0x61, 0x99, 0x73, 0x42, 0xc6, 0x6c, 0xe8, 0x0a, 0x95, 0x40, |
283 0x41, 0x3b, 0x0d, 0x10, 0xa7, 0x4a, 0x93, 0xdb, 0x5a, 0xe7, 0xec}; | 284 0x41, 0x3b, 0x0d, 0x10, 0xa7, 0x4a, 0x93, 0xdb, 0x5a, 0xe7, 0xec}; |
284 | 285 |
285 scoped_ptr<crypto::ECPrivateKey> keypair_openssl( | 286 scoped_ptr<crypto::ECPrivateKey> keypair_openssl( |
286 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 287 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
287 "", | 288 "", std::vector<uint8_t>(openssl_key, |
288 std::vector<uint8>(openssl_key, openssl_key + arraysize(openssl_key)), | 289 openssl_key + arraysize(openssl_key)), |
289 std::vector<uint8>(openssl_pub_key, | 290 std::vector<uint8_t>(openssl_pub_key, |
290 openssl_pub_key + arraysize(openssl_pub_key)))); | 291 openssl_pub_key + arraysize(openssl_pub_key)))); |
291 | 292 |
292 EXPECT_TRUE(keypair_openssl.get()); | 293 EXPECT_TRUE(keypair_openssl.get()); |
293 } | 294 } |
294 #endif // defined(USE_OPENSSL) | 295 #endif // defined(USE_OPENSSL) |
OLD | NEW |