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

Side by Side Diff: crypto/rsa_private_key_unittest.cc

Issue 1082123003: Rename USE_NSS to USE_NSS_CERTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-nss-certs
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.cc ('k') | crypto/signature_creator.h » ('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 or USE_OPENSSL is defined, but 448 // The following test can run if either USE_NSS_CERTS or USE_OPENSSL is defined,
449 // not otherwise (since it uses crypto::RSAPrivateKey::CreateFromKey). 449 // but not otherwise (since it uses crypto::RSAPrivateKey::CreateFromKey).
450 #if defined(USE_NSS) || defined(USE_OPENSSL) 450 #if defined(USE_NSS_CERTS) || defined(USE_OPENSSL)
451 TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) { 451 TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) {
452 scoped_ptr<crypto::RSAPrivateKey> key_pair( 452 scoped_ptr<crypto::RSAPrivateKey> key_pair(
453 crypto::RSAPrivateKey::Create(256)); 453 crypto::RSAPrivateKey::Create(256));
454 454
455 scoped_ptr<crypto::RSAPrivateKey> key_copy( 455 scoped_ptr<crypto::RSAPrivateKey> key_copy(
456 crypto::RSAPrivateKey::CreateFromKey(key_pair->key())); 456 crypto::RSAPrivateKey::CreateFromKey(key_pair->key()));
457 ASSERT_TRUE(key_copy.get()); 457 ASSERT_TRUE(key_copy.get());
458 458
459 std::vector<uint8> privkey; 459 std::vector<uint8> privkey;
460 std::vector<uint8> pubkey; 460 std::vector<uint8> pubkey;
461 ASSERT_TRUE(key_pair->ExportPrivateKey(&privkey)); 461 ASSERT_TRUE(key_pair->ExportPrivateKey(&privkey));
462 ASSERT_TRUE(key_pair->ExportPublicKey(&pubkey)); 462 ASSERT_TRUE(key_pair->ExportPublicKey(&pubkey));
463 463
464 std::vector<uint8> privkey_copy; 464 std::vector<uint8> privkey_copy;
465 std::vector<uint8> pubkey_copy; 465 std::vector<uint8> pubkey_copy;
466 ASSERT_TRUE(key_copy->ExportPrivateKey(&privkey_copy)); 466 ASSERT_TRUE(key_copy->ExportPrivateKey(&privkey_copy));
467 ASSERT_TRUE(key_copy->ExportPublicKey(&pubkey_copy)); 467 ASSERT_TRUE(key_copy->ExportPublicKey(&pubkey_copy));
468 468
469 ASSERT_EQ(privkey, privkey_copy); 469 ASSERT_EQ(privkey, privkey_copy);
470 ASSERT_EQ(pubkey, pubkey_copy); 470 ASSERT_EQ(pubkey, pubkey_copy);
471 } 471 }
472 #endif 472 #endif
473 473
OLDNEW
« no previous file with comments | « crypto/rsa_private_key_nss.cc ('k') | crypto/signature_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698