| 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> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 // Generate random private keys. Export, then re-import. We should get | 15 // Generate random private keys. Export, then re-import. We should get |
| 16 // 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 |
| 17 // value and elliptic curve params. | 17 // value and elliptic curve params. |
| 18 TEST(ECPrivateKeyUnitTest, InitRandomTest) { | 18 TEST(ECPrivateKeyUnitTest, InitRandomTest) { |
| 19 const std::string password1; | 19 const std::string password1; |
| 20 const std::string password2 = "test"; | 20 const std::string password2 = "test"; |
| 21 | 21 |
| 22 scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create()); | 22 std::unique_ptr<crypto::ECPrivateKey> keypair1( |
| 23 scoped_ptr<crypto::ECPrivateKey> keypair2(crypto::ECPrivateKey::Create()); | 23 crypto::ECPrivateKey::Create()); |
| 24 std::unique_ptr<crypto::ECPrivateKey> keypair2( |
| 25 crypto::ECPrivateKey::Create()); |
| 24 ASSERT_TRUE(keypair1.get()); | 26 ASSERT_TRUE(keypair1.get()); |
| 25 ASSERT_TRUE(keypair2.get()); | 27 ASSERT_TRUE(keypair2.get()); |
| 26 | 28 |
| 27 std::vector<uint8_t> key1value; | 29 std::vector<uint8_t> key1value; |
| 28 std::vector<uint8_t> key2value; | 30 std::vector<uint8_t> key2value; |
| 29 EXPECT_TRUE(keypair1->ExportValueForTesting(&key1value)); | 31 EXPECT_TRUE(keypair1->ExportValueForTesting(&key1value)); |
| 30 EXPECT_TRUE(keypair2->ExportValueForTesting(&key2value)); | 32 EXPECT_TRUE(keypair2->ExportValueForTesting(&key2value)); |
| 31 | 33 |
| 32 std::vector<uint8_t> privkey1; | 34 std::vector<uint8_t> privkey1; |
| 33 std::vector<uint8_t> privkey2; | 35 std::vector<uint8_t> privkey2; |
| 34 std::vector<uint8_t> pubkey1; | 36 std::vector<uint8_t> pubkey1; |
| 35 std::vector<uint8_t> pubkey2; | 37 std::vector<uint8_t> pubkey2; |
| 36 std::string raw_pubkey1; | 38 std::string raw_pubkey1; |
| 37 std::string raw_pubkey2; | 39 std::string raw_pubkey2; |
| 38 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(password1, 1, &privkey1)); | 40 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey(password1, 1, &privkey1)); |
| 39 ASSERT_TRUE(keypair2->ExportEncryptedPrivateKey(password2, 1, &privkey2)); | 41 ASSERT_TRUE(keypair2->ExportEncryptedPrivateKey(password2, 1, &privkey2)); |
| 40 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); | 42 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); |
| 41 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); | 43 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); |
| 42 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); | 44 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); |
| 43 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); | 45 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); |
| 44 | 46 |
| 45 scoped_ptr<crypto::ECPrivateKey> keypair3( | 47 std::unique_ptr<crypto::ECPrivateKey> keypair3( |
| 46 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 48 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 47 password1, privkey1, pubkey1)); | 49 password1, privkey1, pubkey1)); |
| 48 scoped_ptr<crypto::ECPrivateKey> keypair4( | 50 std::unique_ptr<crypto::ECPrivateKey> keypair4( |
| 49 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 51 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 50 password2, privkey2, pubkey2)); | 52 password2, privkey2, pubkey2)); |
| 51 ASSERT_TRUE(keypair3.get()); | 53 ASSERT_TRUE(keypair3.get()); |
| 52 ASSERT_TRUE(keypair4.get()); | 54 ASSERT_TRUE(keypair4.get()); |
| 53 | 55 |
| 54 std::vector<uint8_t> key3value; | 56 std::vector<uint8_t> key3value; |
| 55 std::vector<uint8_t> key4value; | 57 std::vector<uint8_t> key4value; |
| 56 EXPECT_TRUE(keypair3->ExportValueForTesting(&key3value)); | 58 EXPECT_TRUE(keypair3->ExportValueForTesting(&key3value)); |
| 57 EXPECT_TRUE(keypair4->ExportValueForTesting(&key4value)); | 59 EXPECT_TRUE(keypair4->ExportValueForTesting(&key4value)); |
| 58 | 60 |
| 59 EXPECT_EQ(key1value, key3value); | 61 EXPECT_EQ(key1value, key3value); |
| 60 EXPECT_EQ(key2value, key4value); | 62 EXPECT_EQ(key2value, key4value); |
| 61 | 63 |
| 62 std::vector<uint8_t> pubkey3; | 64 std::vector<uint8_t> pubkey3; |
| 63 std::vector<uint8_t> pubkey4; | 65 std::vector<uint8_t> pubkey4; |
| 64 std::string raw_pubkey3; | 66 std::string raw_pubkey3; |
| 65 std::string raw_pubkey4; | 67 std::string raw_pubkey4; |
| 66 EXPECT_TRUE(keypair3->ExportPublicKey(&pubkey3)); | 68 EXPECT_TRUE(keypair3->ExportPublicKey(&pubkey3)); |
| 67 EXPECT_TRUE(keypair4->ExportPublicKey(&pubkey4)); | 69 EXPECT_TRUE(keypair4->ExportPublicKey(&pubkey4)); |
| 68 EXPECT_TRUE(keypair3->ExportRawPublicKey(&raw_pubkey3)); | 70 EXPECT_TRUE(keypair3->ExportRawPublicKey(&raw_pubkey3)); |
| 69 EXPECT_TRUE(keypair4->ExportRawPublicKey(&raw_pubkey4)); | 71 EXPECT_TRUE(keypair4->ExportRawPublicKey(&raw_pubkey4)); |
| 70 | 72 |
| 71 EXPECT_EQ(pubkey1, pubkey3); | 73 EXPECT_EQ(pubkey1, pubkey3); |
| 72 EXPECT_EQ(pubkey2, pubkey4); | 74 EXPECT_EQ(pubkey2, pubkey4); |
| 73 EXPECT_EQ(raw_pubkey1, raw_pubkey3); | 75 EXPECT_EQ(raw_pubkey1, raw_pubkey3); |
| 74 EXPECT_EQ(raw_pubkey2, raw_pubkey4); | 76 EXPECT_EQ(raw_pubkey2, raw_pubkey4); |
| 75 } | 77 } |
| 76 | 78 |
| 77 TEST(ECPrivateKeyUnitTest, Copy) { | 79 TEST(ECPrivateKeyUnitTest, Copy) { |
| 78 scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create()); | 80 std::unique_ptr<crypto::ECPrivateKey> keypair1( |
| 79 scoped_ptr<crypto::ECPrivateKey> keypair2(keypair1->Copy()); | 81 crypto::ECPrivateKey::Create()); |
| 82 std::unique_ptr<crypto::ECPrivateKey> keypair2(keypair1->Copy()); |
| 80 ASSERT_TRUE(keypair1.get()); | 83 ASSERT_TRUE(keypair1.get()); |
| 81 ASSERT_TRUE(keypair2.get()); | 84 ASSERT_TRUE(keypair2.get()); |
| 82 | 85 |
| 83 std::vector<uint8_t> key1value; | 86 std::vector<uint8_t> key1value; |
| 84 std::vector<uint8_t> key2value; | 87 std::vector<uint8_t> key2value; |
| 85 EXPECT_TRUE(keypair1->ExportValueForTesting(&key1value)); | 88 EXPECT_TRUE(keypair1->ExportValueForTesting(&key1value)); |
| 86 EXPECT_TRUE(keypair2->ExportValueForTesting(&key2value)); | 89 EXPECT_TRUE(keypair2->ExportValueForTesting(&key2value)); |
| 87 EXPECT_EQ(key1value, key2value); | 90 EXPECT_EQ(key1value, key2value); |
| 88 | 91 |
| 89 std::vector<uint8_t> pubkey1; | 92 std::vector<uint8_t> pubkey1; |
| 90 std::vector<uint8_t> pubkey2; | 93 std::vector<uint8_t> pubkey2; |
| 91 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); | 94 EXPECT_TRUE(keypair1->ExportPublicKey(&pubkey1)); |
| 92 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); | 95 EXPECT_TRUE(keypair2->ExportPublicKey(&pubkey2)); |
| 93 EXPECT_EQ(pubkey1, pubkey2); | 96 EXPECT_EQ(pubkey1, pubkey2); |
| 94 | 97 |
| 95 std::string raw_pubkey1; | 98 std::string raw_pubkey1; |
| 96 std::string raw_pubkey2; | 99 std::string raw_pubkey2; |
| 97 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); | 100 EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1)); |
| 98 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); | 101 EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2)); |
| 99 EXPECT_EQ(raw_pubkey1, raw_pubkey2); | 102 EXPECT_EQ(raw_pubkey1, raw_pubkey2); |
| 100 } | 103 } |
| 101 | 104 |
| 102 TEST(ECPrivateKeyUnitTest, BadPasswordTest) { | 105 TEST(ECPrivateKeyUnitTest, BadPasswordTest) { |
| 103 const std::string password1; | 106 const std::string password1; |
| 104 const std::string password2 = "test"; | 107 const std::string password2 = "test"; |
| 105 | 108 |
| 106 scoped_ptr<crypto::ECPrivateKey> keypair1( | 109 std::unique_ptr<crypto::ECPrivateKey> keypair1( |
| 107 crypto::ECPrivateKey::Create()); | 110 crypto::ECPrivateKey::Create()); |
| 108 ASSERT_TRUE(keypair1.get()); | 111 ASSERT_TRUE(keypair1.get()); |
| 109 | 112 |
| 110 std::vector<uint8_t> privkey1; | 113 std::vector<uint8_t> privkey1; |
| 111 std::vector<uint8_t> pubkey1; | 114 std::vector<uint8_t> pubkey1; |
| 112 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey( | 115 ASSERT_TRUE(keypair1->ExportEncryptedPrivateKey( |
| 113 password1, 1, &privkey1)); | 116 password1, 1, &privkey1)); |
| 114 ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1)); | 117 ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1)); |
| 115 | 118 |
| 116 scoped_ptr<crypto::ECPrivateKey> keypair2( | 119 std::unique_ptr<crypto::ECPrivateKey> keypair2( |
| 117 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 120 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 118 password2, privkey1, pubkey1)); | 121 password2, privkey1, pubkey1)); |
| 119 ASSERT_FALSE(keypair2.get()); | 122 ASSERT_FALSE(keypair2.get()); |
| 120 } | 123 } |
| 121 | 124 |
| 122 TEST(ECPrivateKeyUnitTest, LoadNSSKeyTest) { | 125 TEST(ECPrivateKeyUnitTest, LoadNSSKeyTest) { |
| 123 static const uint8_t kNSSKey[] = { | 126 static const uint8_t kNSSKey[] = { |
| 124 0x30, 0x81, 0xb8, 0x30, 0x23, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, | 127 0x30, 0x81, 0xb8, 0x30, 0x23, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf7, |
| 125 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30, 0x15, 0x04, 0x10, 0x3f, 0xac, 0xe9, | 128 0x0d, 0x01, 0x0c, 0x01, 0x03, 0x30, 0x15, 0x04, 0x10, 0x3f, 0xac, 0xe9, |
| 126 0x38, 0xdb, 0x40, 0x6b, 0x26, 0x89, 0x09, 0x73, 0x18, 0x8d, 0x7f, 0x1c, | 129 0x38, 0xdb, 0x40, 0x6b, 0x26, 0x89, 0x09, 0x73, 0x18, 0x8d, 0x7f, 0x1c, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 142 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, | 145 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, |
| 143 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, | 146 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, |
| 144 0x42, 0x00, 0x04, 0x85, 0x92, 0x9e, 0x95, 0x5c, 0x6b, 0x9e, 0xd6, 0x1e, | 147 0x42, 0x00, 0x04, 0x85, 0x92, 0x9e, 0x95, 0x5c, 0x6b, 0x9e, 0xd6, 0x1e, |
| 145 0xb8, 0x64, 0xea, 0xc2, 0xb3, 0xef, 0x18, 0xed, 0x3a, 0x5e, 0xc4, 0x5c, | 148 0xb8, 0x64, 0xea, 0xc2, 0xb3, 0xef, 0x18, 0xed, 0x3a, 0x5e, 0xc4, 0x5c, |
| 146 0x15, 0x37, 0x6a, 0xe9, 0xaa, 0x0b, 0x34, 0x03, 0xfd, 0xca, 0x83, 0x0f, | 149 0x15, 0x37, 0x6a, 0xe9, 0xaa, 0x0b, 0x34, 0x03, 0xfd, 0xca, 0x83, 0x0f, |
| 147 0xd7, 0x5c, 0x5d, 0xc5, 0x53, 0x6e, 0xe5, 0xa9, 0x33, 0xd5, 0xcc, 0xab, | 150 0xd7, 0x5c, 0x5d, 0xc5, 0x53, 0x6e, 0xe5, 0xa9, 0x33, 0xd5, 0xcc, 0xab, |
| 148 0x53, 0x78, 0xdd, 0xd6, 0x12, 0x3a, 0x5e, 0xeb, 0xbf, 0xdf, 0x16, 0xd3, | 151 0x53, 0x78, 0xdd, 0xd6, 0x12, 0x3a, 0x5e, 0xeb, 0xbf, 0xdf, 0x16, 0xd3, |
| 149 0x2c, 0x3b, 0xe8, 0xdb, 0x19, 0xfc, 0x5e, | 152 0x2c, 0x3b, 0xe8, 0xdb, 0x19, 0xfc, 0x5e, |
| 150 }; | 153 }; |
| 151 | 154 |
| 152 scoped_ptr<crypto::ECPrivateKey> keypair_nss( | 155 std::unique_ptr<crypto::ECPrivateKey> keypair_nss( |
| 153 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 156 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 154 "", std::vector<uint8_t>(std::begin(kNSSKey), std::end(kNSSKey)), | 157 "", std::vector<uint8_t>(std::begin(kNSSKey), std::end(kNSSKey)), |
| 155 std::vector<uint8_t>(std::begin(kNSSPublicKey), | 158 std::vector<uint8_t>(std::begin(kNSSPublicKey), |
| 156 std::end(kNSSPublicKey)))); | 159 std::end(kNSSPublicKey)))); |
| 157 | 160 |
| 158 EXPECT_TRUE(keypair_nss.get()); | 161 EXPECT_TRUE(keypair_nss.get()); |
| 159 } | 162 } |
| 160 | 163 |
| 161 TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) { | 164 TEST(ECPrivateKeyUnitTest, LoadOpenSSLKeyTest) { |
| 162 static const uint8_t kOpenSSLKey[] = { | 165 static const uint8_t kOpenSSLKey[] = { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 188 }; | 191 }; |
| 189 static const uint8_t kOpenSSLRawPublicKey[] = { | 192 static const uint8_t kOpenSSLRawPublicKey[] = { |
| 190 0xb9, 0xda, 0x0d, 0x71, 0x60, 0xb3, 0x63, 0x28, 0x22, 0x67, 0xe7, | 193 0xb9, 0xda, 0x0d, 0x71, 0x60, 0xb3, 0x63, 0x28, 0x22, 0x67, 0xe7, |
| 191 0xe0, 0xa3, 0xf8, 0x00, 0x8e, 0x4c, 0x89, 0xed, 0x31, 0x34, 0xf6, | 194 0xe0, 0xa3, 0xf8, 0x00, 0x8e, 0x4c, 0x89, 0xed, 0x31, 0x34, 0xf6, |
| 192 0xdb, 0xc4, 0xfe, 0x0b, 0x5d, 0xe1, 0x11, 0x39, 0x49, 0xa6, 0x50, | 195 0xdb, 0xc4, 0xfe, 0x0b, 0x5d, 0xe1, 0x11, 0x39, 0x49, 0xa6, 0x50, |
| 193 0xa8, 0xe3, 0x4a, 0xc0, 0x40, 0x88, 0xb8, 0x38, 0x3f, 0x56, 0xfb, | 196 0xa8, 0xe3, 0x4a, 0xc0, 0x40, 0x88, 0xb8, 0x38, 0x3f, 0x56, 0xfb, |
| 194 0x33, 0x8d, 0xd4, 0x64, 0x91, 0xd6, 0x15, 0x77, 0x42, 0x27, 0xc5, | 197 0x33, 0x8d, 0xd4, 0x64, 0x91, 0xd6, 0x15, 0x77, 0x42, 0x27, 0xc5, |
| 195 0xaa, 0x44, 0xff, 0xab, 0x4d, 0xb5, 0x7e, 0x25, 0x3d, | 198 0xaa, 0x44, 0xff, 0xab, 0x4d, 0xb5, 0x7e, 0x25, 0x3d, |
| 196 }; | 199 }; |
| 197 | 200 |
| 198 scoped_ptr<crypto::ECPrivateKey> keypair_openssl( | 201 std::unique_ptr<crypto::ECPrivateKey> keypair_openssl( |
| 199 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 202 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 200 "", | 203 "", |
| 201 std::vector<uint8_t>(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)), | 204 std::vector<uint8_t>(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)), |
| 202 std::vector<uint8_t>(std::begin(kOpenSSLPublicKey), | 205 std::vector<uint8_t>(std::begin(kOpenSSLPublicKey), |
| 203 std::end(kOpenSSLPublicKey)))); | 206 std::end(kOpenSSLPublicKey)))); |
| 204 | 207 |
| 205 EXPECT_TRUE(keypair_openssl.get()); | 208 EXPECT_TRUE(keypair_openssl.get()); |
| 206 | 209 |
| 207 std::vector<uint8_t> public_key; | 210 std::vector<uint8_t> public_key; |
| 208 EXPECT_TRUE(keypair_openssl->ExportPublicKey(&public_key)); | 211 EXPECT_TRUE(keypair_openssl->ExportPublicKey(&public_key)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad, | 287 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbc, 0xe6, 0xfa, 0xad, |
| 285 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51, | 288 0xa7, 0x17, 0x9e, 0x84, 0xf3, 0xb9, 0xca, 0xc2, 0xfc, 0x63, 0x25, 0x51, |
| 286 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0xde, 0x09, 0x08, 0x07, 0x03, | 289 0x02, 0x01, 0x01, 0x03, 0x42, 0x00, 0x04, 0xde, 0x09, 0x08, 0x07, 0x03, |
| 287 0x2e, 0x8f, 0x37, 0x9a, 0xd5, 0xad, 0xe5, 0xc6, 0x9d, 0xd4, 0x63, 0xc7, | 290 0x2e, 0x8f, 0x37, 0x9a, 0xd5, 0xad, 0xe5, 0xc6, 0x9d, 0xd4, 0x63, 0xc7, |
| 288 0x4a, 0xe7, 0x20, 0xcb, 0x90, 0xa0, 0x1f, 0x18, 0x18, 0x72, 0xb5, 0x21, | 291 0x4a, 0xe7, 0x20, 0xcb, 0x90, 0xa0, 0x1f, 0x18, 0x18, 0x72, 0xb5, 0x21, |
| 289 0x88, 0x38, 0xc0, 0xdb, 0xba, 0xf6, 0x99, 0xd8, 0xa5, 0x3b, 0x83, 0xe9, | 292 0x88, 0x38, 0xc0, 0xdb, 0xba, 0xf6, 0x99, 0xd8, 0xa5, 0x3b, 0x83, 0xe9, |
| 290 0xe3, 0xd5, 0x61, 0x99, 0x73, 0x42, 0xc6, 0x6c, 0xe8, 0x0a, 0x95, 0x40, | 293 0xe3, 0xd5, 0x61, 0x99, 0x73, 0x42, 0xc6, 0x6c, 0xe8, 0x0a, 0x95, 0x40, |
| 291 0x41, 0x3b, 0x0d, 0x10, 0xa7, 0x4a, 0x93, 0xdb, 0x5a, 0xe7, 0xec, | 294 0x41, 0x3b, 0x0d, 0x10, 0xa7, 0x4a, 0x93, 0xdb, 0x5a, 0xe7, 0xec, |
| 292 }; | 295 }; |
| 293 | 296 |
| 294 scoped_ptr<crypto::ECPrivateKey> keypair_openssl( | 297 std::unique_ptr<crypto::ECPrivateKey> keypair_openssl( |
| 295 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( | 298 crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo( |
| 296 "", | 299 "", |
| 297 std::vector<uint8_t>(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)), | 300 std::vector<uint8_t>(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)), |
| 298 std::vector<uint8_t>(std::begin(kOpenSSLPublicKey), | 301 std::vector<uint8_t>(std::begin(kOpenSSLPublicKey), |
| 299 std::end(kOpenSSLPublicKey)))); | 302 std::end(kOpenSSLPublicKey)))); |
| 300 | 303 |
| 301 EXPECT_TRUE(keypair_openssl.get()); | 304 EXPECT_TRUE(keypair_openssl.get()); |
| 302 } | 305 } |
| 303 #endif // defined(USE_OPENSSL) | 306 #endif // defined(USE_OPENSSL) |
| OLD | NEW |