OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/crypto/rsa_private_key.h" | 5 #include "base/crypto/rsa_private_key.h" |
6 #include "base/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 // Generate random private keys with two different sizes. Reimport, then | 9 // Generate random private keys with two different sizes. Reimport, then |
10 // export them again. We should get back the same exact bytes. | 10 // export them again. We should get back the same exact bytes. |
11 TEST(RSAPrivateKeyUnitTest, InitRandomTest) { | 11 TEST(RSAPrivateKeyUnitTest, InitRandomTest) { |
12 scoped_ptr<base::RSAPrivateKey> keypair1(base::RSAPrivateKey::Create(1024)); | 12 scoped_ptr<base::RSAPrivateKey> keypair1(base::RSAPrivateKey::Create(1024)); |
13 scoped_ptr<base::RSAPrivateKey> keypair2(base::RSAPrivateKey::Create(2048)); | 13 scoped_ptr<base::RSAPrivateKey> keypair2(base::RSAPrivateKey::Create(2048)); |
14 ASSERT_TRUE(keypair1.get()); | 14 ASSERT_TRUE(keypair1.get()); |
15 ASSERT_TRUE(keypair2.get()); | 15 ASSERT_TRUE(keypair2.get()); |
16 | 16 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 ASSERT_TRUE(keypair1->ExportPrivateKey(&output1)); | 374 ASSERT_TRUE(keypair1->ExportPrivateKey(&output1)); |
375 ASSERT_TRUE(keypair2->ExportPrivateKey(&output2)); | 375 ASSERT_TRUE(keypair2->ExportPrivateKey(&output2)); |
376 | 376 |
377 ASSERT_EQ(input1.size(), output1.size()); | 377 ASSERT_EQ(input1.size(), output1.size()); |
378 ASSERT_EQ(input2.size(), output2.size()); | 378 ASSERT_EQ(input2.size(), output2.size()); |
379 ASSERT_TRUE(0 == memcmp(&output1.front(), &input1.front(), | 379 ASSERT_TRUE(0 == memcmp(&output1.front(), &input1.front(), |
380 input1.size())); | 380 input1.size())); |
381 ASSERT_TRUE(0 == memcmp(&output2.front(), &input2.front(), | 381 ASSERT_TRUE(0 == memcmp(&output2.front(), &input2.front(), |
382 input2.size())); | 382 input2.size())); |
383 } | 383 } |
OLD | NEW |