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

Side by Side Diff: crypto/rsa_private_key_unittest.cc

Issue 881213004: Support building BoringSSL with NSS certificates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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 | « crypto/rsa_private_key_nss_unittest.cc ('k') | net/BUILD.gn » ('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 (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/rsa_private_key.h" 5 #include "crypto/rsa_private_key.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace { 10 namespace {
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 ASSERT_TRUE(keypair2->ExportPrivateKey(&output2)); 438 ASSERT_TRUE(keypair2->ExportPrivateKey(&output2));
439 439
440 ASSERT_EQ(input1.size(), output1.size()); 440 ASSERT_EQ(input1.size(), output1.size());
441 ASSERT_EQ(input2.size(), output2.size()); 441 ASSERT_EQ(input2.size(), output2.size());
442 ASSERT_TRUE(0 == memcmp(&output1.front(), &input1.front(), 442 ASSERT_TRUE(0 == memcmp(&output1.front(), &input1.front(),
443 input1.size())); 443 input1.size()));
444 ASSERT_TRUE(0 == memcmp(&output2.front(), &input2.front(), 444 ASSERT_TRUE(0 == memcmp(&output2.front(), &input2.front(),
445 input2.size())); 445 input2.size()));
446 } 446 }
447 447
448 // The following test can run if either USE_NSS_CERTS or USE_OPENSSL is defined,
449 // but not otherwise (since it uses crypto::RSAPrivateKey::CreateFromKey).
450 #if defined(USE_NSS_CERTS) || defined(USE_OPENSSL)
451 TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) { 448 TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) {
452 scoped_ptr<crypto::RSAPrivateKey> key_pair( 449 scoped_ptr<crypto::RSAPrivateKey> key_pair(
453 crypto::RSAPrivateKey::Create(256)); 450 crypto::RSAPrivateKey::Create(256));
454 451
455 scoped_ptr<crypto::RSAPrivateKey> key_copy( 452 scoped_ptr<crypto::RSAPrivateKey> key_copy(
456 crypto::RSAPrivateKey::CreateFromKey(key_pair->key())); 453 crypto::RSAPrivateKey::CreateFromKey(key_pair->key()));
457 ASSERT_TRUE(key_copy.get()); 454 ASSERT_TRUE(key_copy.get());
458 455
459 std::vector<uint8> privkey; 456 std::vector<uint8> privkey;
460 std::vector<uint8> pubkey; 457 std::vector<uint8> pubkey;
461 ASSERT_TRUE(key_pair->ExportPrivateKey(&privkey)); 458 ASSERT_TRUE(key_pair->ExportPrivateKey(&privkey));
462 ASSERT_TRUE(key_pair->ExportPublicKey(&pubkey)); 459 ASSERT_TRUE(key_pair->ExportPublicKey(&pubkey));
463 460
464 std::vector<uint8> privkey_copy; 461 std::vector<uint8> privkey_copy;
465 std::vector<uint8> pubkey_copy; 462 std::vector<uint8> pubkey_copy;
466 ASSERT_TRUE(key_copy->ExportPrivateKey(&privkey_copy)); 463 ASSERT_TRUE(key_copy->ExportPrivateKey(&privkey_copy));
467 ASSERT_TRUE(key_copy->ExportPublicKey(&pubkey_copy)); 464 ASSERT_TRUE(key_copy->ExportPublicKey(&pubkey_copy));
468 465
469 ASSERT_EQ(privkey, privkey_copy); 466 ASSERT_EQ(privkey, privkey_copy);
470 ASSERT_EQ(pubkey, pubkey_copy); 467 ASSERT_EQ(pubkey, pubkey_copy);
471 } 468 }
472 #endif
473 469
OLDNEW
« no previous file with comments | « crypto/rsa_private_key_nss_unittest.cc ('k') | net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698