[go: nahoru, domu]

Convert crypto to std::unique_ptr

BUG=554298
TBR=sdefresne

Review URL: https://codereview.chromium.org/1870233002

Cr-Commit-Position: refs/heads/master@{#386228}
diff --git a/chrome/browser/internal_auth.cc b/chrome/browser/internal_auth.cc
index 33fed11..a520add 100644
--- a/chrome/browser/internal_auth.cc
+++ b/chrome/browser/internal_auth.cc
@@ -14,6 +14,7 @@
 #include "base/base64.h"
 #include "base/lazy_instance.h"
 #include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
 #include "base/rand_util.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_split.h"
diff --git a/components/nacl/loader/nacl_validation_query_unittest.cc b/components/nacl/loader/nacl_validation_query_unittest.cc
index 948268e7..b1d7d514 100644
--- a/components/nacl/loader/nacl_validation_query_unittest.cc
+++ b/components/nacl/loader/nacl_validation_query_unittest.cc
@@ -4,6 +4,7 @@
 
 #include <stdint.h>
 
+#include "base/memory/scoped_ptr.h"
 #include "components/nacl/loader/nacl_validation_db.h"
 #include "components/nacl/loader/nacl_validation_query.h"
 #include "testing/gtest/include/gtest/gtest.h"
diff --git a/components/user_prefs/tracked/pref_hash_calculator.cc b/components/user_prefs/tracked/pref_hash_calculator.cc
index 9e7a0d0d..2099121b 100644
--- a/components/user_prefs/tracked/pref_hash_calculator.cc
+++ b/components/user_prefs/tracked/pref_hash_calculator.cc
@@ -11,6 +11,7 @@
 #include "base/bind.h"
 #include "base/json/json_string_value_serializer.h"
 #include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "base/values.h"
diff --git a/crypto/ec_private_key_nss.cc b/crypto/ec_private_key_nss.cc
index 989b7ad..8ca8f25ec 100644
--- a/crypto/ec_private_key_nss.cc
+++ b/crypto/ec_private_key_nss.cc
@@ -17,8 +17,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/nss_util.h"
 #include "crypto/nss_util_internal.h"
 #include "crypto/scoped_nss_types.h"
@@ -61,7 +62,7 @@
   if (!slot)
     return nullptr;
 
-  scoped_ptr<ECPrivateKey> result(new ECPrivateKey);
+  std::unique_ptr<ECPrivateKey> result(new ECPrivateKey);
 
   SECOidData* oid_data = SECOID_FindOIDByTag(SEC_OID_SECG_EC_SECP256R1);
   if (!oid_data) {
@@ -111,7 +112,7 @@
   if (!slot)
     return nullptr;
 
-  scoped_ptr<ECPrivateKey> result(new ECPrivateKey);
+  std::unique_ptr<ECPrivateKey> result(new ECPrivateKey);
 
   SECItem encoded_spki = {
     siBuffer,
@@ -224,7 +225,7 @@
 }
 
 ECPrivateKey* ECPrivateKey::Copy() const {
-  scoped_ptr<ECPrivateKey> copy(new ECPrivateKey);
+  std::unique_ptr<ECPrivateKey> copy(new ECPrivateKey);
   if (key_) {
     copy->key_ = SECKEY_CopyPrivateKey(key_);
     if (!copy->key_)
diff --git a/crypto/ec_private_key_openssl.cc b/crypto/ec_private_key_openssl.cc
index 1b6588b..5e8d054 100644
--- a/crypto/ec_private_key_openssl.cc
+++ b/crypto/ec_private_key_openssl.cc
@@ -13,8 +13,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/auto_cbb.h"
 #include "crypto/openssl_util.h"
 #include "crypto/scoped_openssl_types.h"
@@ -65,7 +66,7 @@
 }
 
 ECPrivateKey* ECPrivateKey::Copy() const {
-  scoped_ptr<ECPrivateKey> copy(new ECPrivateKey);
+  std::unique_ptr<ECPrivateKey> copy(new ECPrivateKey);
   if (key_)
     copy->key_ = EVP_PKEY_up_ref(key_);
   return copy.release();
@@ -79,7 +80,7 @@
   if (!ec_key.get() || !EC_KEY_generate_key(ec_key.get()))
     return NULL;
 
-  scoped_ptr<ECPrivateKey> result(new ECPrivateKey());
+  std::unique_ptr<ECPrivateKey> result(new ECPrivateKey());
   result->key_ = EVP_PKEY_new();
   if (!result->key_ || !EVP_PKEY_set1_EC_KEY(result->key_, ec_key.get()))
     return NULL;
@@ -128,7 +129,7 @@
     return NULL;
 
   // Create a new EVP_PKEY for it.
-  scoped_ptr<ECPrivateKey> result(new ECPrivateKey);
+  std::unique_ptr<ECPrivateKey> result(new ECPrivateKey);
   result->key_ = EVP_PKCS82PKEY(p8_decrypted.get());
   if (!result->key_ || EVP_PKEY_type(result->key_->type) != EVP_PKEY_EC)
     return NULL;
diff --git a/crypto/ec_private_key_unittest.cc b/crypto/ec_private_key_unittest.cc
index 27d5ecb..0fa8c8c 100644
--- a/crypto/ec_private_key_unittest.cc
+++ b/crypto/ec_private_key_unittest.cc
@@ -6,10 +6,10 @@
 
 #include <stdint.h>
 
+#include <memory>
 #include <vector>
 
 #include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 // Generate random private keys. Export, then re-import. We should get
@@ -19,8 +19,10 @@
   const std::string password1;
   const std::string password2 = "test";
 
-  scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create());
-  scoped_ptr<crypto::ECPrivateKey> keypair2(crypto::ECPrivateKey::Create());
+  std::unique_ptr<crypto::ECPrivateKey> keypair1(
+      crypto::ECPrivateKey::Create());
+  std::unique_ptr<crypto::ECPrivateKey> keypair2(
+      crypto::ECPrivateKey::Create());
   ASSERT_TRUE(keypair1.get());
   ASSERT_TRUE(keypair2.get());
 
@@ -42,10 +44,10 @@
   EXPECT_TRUE(keypair1->ExportRawPublicKey(&raw_pubkey1));
   EXPECT_TRUE(keypair2->ExportRawPublicKey(&raw_pubkey2));
 
-  scoped_ptr<crypto::ECPrivateKey> keypair3(
+  std::unique_ptr<crypto::ECPrivateKey> keypair3(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           password1, privkey1, pubkey1));
-  scoped_ptr<crypto::ECPrivateKey> keypair4(
+  std::unique_ptr<crypto::ECPrivateKey> keypair4(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           password2, privkey2, pubkey2));
   ASSERT_TRUE(keypair3.get());
@@ -75,8 +77,9 @@
 }
 
 TEST(ECPrivateKeyUnitTest, Copy) {
-  scoped_ptr<crypto::ECPrivateKey> keypair1(crypto::ECPrivateKey::Create());
-  scoped_ptr<crypto::ECPrivateKey> keypair2(keypair1->Copy());
+  std::unique_ptr<crypto::ECPrivateKey> keypair1(
+      crypto::ECPrivateKey::Create());
+  std::unique_ptr<crypto::ECPrivateKey> keypair2(keypair1->Copy());
   ASSERT_TRUE(keypair1.get());
   ASSERT_TRUE(keypair2.get());
 
@@ -103,7 +106,7 @@
   const std::string password1;
   const std::string password2 = "test";
 
-  scoped_ptr<crypto::ECPrivateKey> keypair1(
+  std::unique_ptr<crypto::ECPrivateKey> keypair1(
       crypto::ECPrivateKey::Create());
   ASSERT_TRUE(keypair1.get());
 
@@ -113,7 +116,7 @@
       password1, 1, &privkey1));
   ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1));
 
-  scoped_ptr<crypto::ECPrivateKey> keypair2(
+  std::unique_ptr<crypto::ECPrivateKey> keypair2(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           password2, privkey1, pubkey1));
   ASSERT_FALSE(keypair2.get());
@@ -149,7 +152,7 @@
       0x2c, 0x3b, 0xe8, 0xdb, 0x19, 0xfc, 0x5e,
   };
 
-  scoped_ptr<crypto::ECPrivateKey> keypair_nss(
+  std::unique_ptr<crypto::ECPrivateKey> keypair_nss(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           "", std::vector<uint8_t>(std::begin(kNSSKey), std::end(kNSSKey)),
           std::vector<uint8_t>(std::begin(kNSSPublicKey),
@@ -195,7 +198,7 @@
       0xaa, 0x44, 0xff, 0xab, 0x4d, 0xb5, 0x7e, 0x25, 0x3d,
   };
 
-  scoped_ptr<crypto::ECPrivateKey> keypair_openssl(
+  std::unique_ptr<crypto::ECPrivateKey> keypair_openssl(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           "",
           std::vector<uint8_t>(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)),
@@ -291,7 +294,7 @@
       0x41, 0x3b, 0x0d, 0x10, 0xa7, 0x4a, 0x93, 0xdb, 0x5a, 0xe7, 0xec,
   };
 
-  scoped_ptr<crypto::ECPrivateKey> keypair_openssl(
+  std::unique_ptr<crypto::ECPrivateKey> keypair_openssl(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           "",
           std::vector<uint8_t>(std::begin(kOpenSSLKey), std::end(kOpenSSLKey)),
diff --git a/crypto/ec_signature_creator_unittest.cc b/crypto/ec_signature_creator_unittest.cc
index 5aa27f21..018ba54a 100644
--- a/crypto/ec_signature_creator_unittest.cc
+++ b/crypto/ec_signature_creator_unittest.cc
@@ -6,10 +6,10 @@
 
 #include <stdint.h>
 
+#include <memory>
 #include <string>
 #include <vector>
 
-#include "base/memory/scoped_ptr.h"
 #include "crypto/ec_private_key.h"
 #include "crypto/signature_verifier.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -19,7 +19,7 @@
 
 TEST(ECSignatureCreatorTest, BasicTest) {
   // Do a verify round trip.
-  scoped_ptr<crypto::ECPrivateKey> key_original(
+  std::unique_ptr<crypto::ECPrivateKey> key_original(
       crypto::ECPrivateKey::Create());
   ASSERT_TRUE(key_original.get());
 
@@ -29,13 +29,13 @@
   std::vector<uint8_t> pubkey_info;
   ASSERT_TRUE(key_original->ExportPublicKey(&pubkey_info));
 
-  scoped_ptr<crypto::ECPrivateKey> key(
+  std::unique_ptr<crypto::ECPrivateKey> key(
       crypto::ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
           std::string(), key_info, pubkey_info));
   ASSERT_TRUE(key.get());
   ASSERT_TRUE(key->key() != NULL);
 
-  scoped_ptr<crypto::ECSignatureCreator> signer(
+  std::unique_ptr<crypto::ECSignatureCreator> signer(
       crypto::ECSignatureCreator::Create(key.get()));
   ASSERT_TRUE(signer.get());
 
diff --git a/crypto/encryptor.h b/crypto/encryptor.h
index e07eb32..f1a478a 100644
--- a/crypto/encryptor.h
+++ b/crypto/encryptor.h
@@ -8,9 +8,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
 #include <string>
 
-#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_piece.h"
 #include "build/build_config.h"
 #include "crypto/crypto_export.h"
@@ -113,7 +113,7 @@
 
   SymmetricKey* key_;
   Mode mode_;
-  scoped_ptr<Counter> counter_;
+  std::unique_ptr<Counter> counter_;
 
 #if defined(USE_OPENSSL)
   bool Crypt(bool do_encrypt,  // Pass true to encrypt, false to decrypt.
diff --git a/crypto/encryptor_unittest.cc b/crypto/encryptor_unittest.cc
index 93355f8..547b746 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -6,16 +6,16 @@
 
 #include <stddef.h>
 
+#include <memory>
 #include <string>
 
 #include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_number_conversions.h"
 #include "crypto/symmetric_key.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 TEST(EncryptorTest, EncryptDecrypt) {
-  scoped_ptr<crypto::SymmetricKey> key(
+  std::unique_ptr<crypto::SymmetricKey> key(
       crypto::SymmetricKey::DeriveKeyFromPassword(
           crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256));
   EXPECT_TRUE(key.get());
@@ -39,29 +39,29 @@
 }
 
 TEST(EncryptorTest, DecryptWrongKey) {
-  scoped_ptr<crypto::SymmetricKey> key(
+  std::unique_ptr<crypto::SymmetricKey> key(
       crypto::SymmetricKey::DeriveKeyFromPassword(
           crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256));
   EXPECT_TRUE(key.get());
 
   // A wrong key that can be detected by implementations that validate every
   // byte in the padding.
-  scoped_ptr<crypto::SymmetricKey> wrong_key(
-        crypto::SymmetricKey::DeriveKeyFromPassword(
-            crypto::SymmetricKey::AES, "wrongword", "sweetest", 1000, 256));
+  std::unique_ptr<crypto::SymmetricKey> wrong_key(
+      crypto::SymmetricKey::DeriveKeyFromPassword(
+          crypto::SymmetricKey::AES, "wrongword", "sweetest", 1000, 256));
   EXPECT_TRUE(wrong_key.get());
 
   // A wrong key that can't be detected by any implementation.  The password
   // "wrongword;" would also work.
-  scoped_ptr<crypto::SymmetricKey> wrong_key2(
-        crypto::SymmetricKey::DeriveKeyFromPassword(
-            crypto::SymmetricKey::AES, "wrongword+", "sweetest", 1000, 256));
+  std::unique_ptr<crypto::SymmetricKey> wrong_key2(
+      crypto::SymmetricKey::DeriveKeyFromPassword(
+          crypto::SymmetricKey::AES, "wrongword+", "sweetest", 1000, 256));
   EXPECT_TRUE(wrong_key2.get());
 
   // A wrong key that can be detected by all implementations.
-  scoped_ptr<crypto::SymmetricKey> wrong_key3(
-        crypto::SymmetricKey::DeriveKeyFromPassword(
-            crypto::SymmetricKey::AES, "wrongwordx", "sweetest", 1000, 256));
+  std::unique_ptr<crypto::SymmetricKey> wrong_key3(
+      crypto::SymmetricKey::DeriveKeyFromPassword(
+          crypto::SymmetricKey::AES, "wrongwordx", "sweetest", 1000, 256));
   EXPECT_TRUE(wrong_key3.get());
 
   crypto::Encryptor encryptor;
@@ -189,8 +189,8 @@
     const unsigned char* plaintext, size_t plaintext_size,
     const unsigned char* ciphertext, size_t ciphertext_size) {
   std::string key_str(reinterpret_cast<const char*>(key), key_size);
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key_str));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key_str));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -221,8 +221,8 @@
     const unsigned char* plaintext, size_t plaintext_size,
     const unsigned char* ciphertext, size_t ciphertext_size) {
   std::string key_str(reinterpret_cast<const char*>(key), key_size);
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key_str));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key_str));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -284,7 +284,7 @@
 }
 
 TEST(EncryptorTest, EncryptDecryptCTR) {
-  scoped_ptr<crypto::SymmetricKey> key(
+  std::unique_ptr<crypto::SymmetricKey> key(
       crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 128));
 
   EXPECT_TRUE(key.get());
@@ -407,8 +407,8 @@
   };
 
   std::string key(reinterpret_cast<const char*>(kRawKey), sizeof(kRawKey));
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -440,8 +440,8 @@
       "D4A67A0BA33C30F207344D81D1E944BBE65587C3D7D9939A"
       "C070C62B9C15A3EA312EA4AD1BC7929F4D3C16B03AD5ADA8";
 
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -464,8 +464,8 @@
 TEST(EncryptorTest, UnsupportedKeySize) {
   std::string key = "7 = bad";
   std::string iv = "Sweet Sixteen IV";
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key));
   if (!sym_key.get())
     return;
 
@@ -478,8 +478,8 @@
 TEST(EncryptorTest, UnsupportedIV) {
   std::string key = "128=SixteenBytes";
   std::string iv = "OnlyForteen :(";
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -492,8 +492,8 @@
   std::string plaintext;
   std::string expected_ciphertext_hex = "8518B8878D34E7185E300D0FCC426396";
 
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -511,8 +511,8 @@
   std::string key = "128=SixteenBytes";
   std::string iv = "Sweet Sixteen IV";
 
-  scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
-      crypto::SymmetricKey::AES, key));
+  std::unique_ptr<crypto::SymmetricKey> sym_key(
+      crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, key));
   ASSERT_TRUE(sym_key.get());
 
   crypto::Encryptor encryptor;
@@ -526,7 +526,7 @@
   // Otherwise when using std::string as the other tests do, accesses several
   // bytes off the end of the buffer may fall inside the reservation of
   // the string and not be detected.
-  scoped_ptr<char[]> ciphertext(new char[1]);
+  std::unique_ptr<char[]> ciphertext(new char[1]);
 
   std::string plaintext;
   EXPECT_FALSE(
diff --git a/crypto/hkdf.cc b/crypto/hkdf.cc
index 67c3921..2483e60 100644
--- a/crypto/hkdf.cc
+++ b/crypto/hkdf.cc
@@ -7,8 +7,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/hmac.h"
 
 namespace crypto {
@@ -55,7 +56,7 @@
   output_.resize(n * kSHA256HashLength);
   base::StringPiece previous;
 
-  scoped_ptr<char[]> buf(new char[kSHA256HashLength + info.size() + 1]);
+  std::unique_ptr<char[]> buf(new char[kSHA256HashLength + info.size() + 1]);
   uint8_t digest[kSHA256HashLength];
 
   HMAC hmac(HMAC::SHA256);
diff --git a/crypto/hmac.cc b/crypto/hmac.cc
index e9869b4f..333e357 100644
--- a/crypto/hmac.cc
+++ b/crypto/hmac.cc
@@ -7,6 +7,7 @@
 #include <stddef.h>
 
 #include <algorithm>
+#include <memory>
 
 #include "base/logging.h"
 #include "crypto/secure_util.h"
@@ -47,7 +48,7 @@
   if (digest.empty())
     return false;
   size_t digest_length = DigestLength();
-  scoped_ptr<unsigned char[]> computed_digest(
+  std::unique_ptr<unsigned char[]> computed_digest(
       new unsigned char[digest_length]);
   if (!Sign(data, computed_digest.get(), digest_length))
     return false;
diff --git a/crypto/hmac.h b/crypto/hmac.h
index ccdab309..ec32ed7c 100644
--- a/crypto/hmac.h
+++ b/crypto/hmac.h
@@ -10,9 +10,10 @@
 
 #include <stddef.h>
 
+#include <memory>
+
 #include "base/compiler_specific.h"
 #include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_piece.h"
 #include "crypto/crypto_export.h"
 
@@ -85,7 +86,7 @@
 
  private:
   HashAlgorithm hash_alg_;
-  scoped_ptr<HMACPlatformData> plat_;
+  std::unique_ptr<HMACPlatformData> plat_;
 
   DISALLOW_COPY_AND_ASSIGN(HMAC);
 };
diff --git a/crypto/hmac_nss.cc b/crypto/hmac_nss.cc
index 9d759b5d0..2547860 100644
--- a/crypto/hmac_nss.cc
+++ b/crypto/hmac_nss.cc
@@ -8,8 +8,9 @@
 #include <pk11pub.h>
 #include <stddef.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/nss_util.h"
 #include "crypto/scoped_nss_types.h"
 
diff --git a/crypto/hmac_openssl.cc b/crypto/hmac_openssl.cc
index 8c8c11a..d88c091 100644
--- a/crypto/hmac_openssl.cc
+++ b/crypto/hmac_openssl.cc
@@ -8,10 +8,10 @@
 #include <stddef.h>
 
 #include <algorithm>
+#include <memory>
 #include <vector>
 
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "base/stl_util.h"
 #include "crypto/openssl_util.h"
 
diff --git a/crypto/nss_key_util.cc b/crypto/nss_key_util.cc
index 3e03489..1f72667 100644
--- a/crypto/nss_key_util.cc
+++ b/crypto/nss_key_util.cc
@@ -9,6 +9,8 @@
 #include <pk11pub.h>
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/logging.h"
 #include "crypto/nss_util.h"
 
@@ -29,7 +31,7 @@
   }
 };
 
-typedef scoped_ptr<CERTSubjectPublicKeyInfo, PublicKeyInfoDeleter>
+typedef std::unique_ptr<CERTSubjectPublicKeyInfo, PublicKeyInfoDeleter>
     ScopedPublicKeyInfo;
 
 // Decodes |input| as a SubjectPublicKeyInfo and returns a SECItem containing
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index 5bd6436..359f78f 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -11,6 +11,8 @@
 #include <prinit.h>
 #include <prtime.h>
 #include <secmod.h>
+
+#include <memory>
 #include <utility>
 
 #include "crypto/nss_util_internal.h"
@@ -37,7 +39,6 @@
 #include "base/files/file_util.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "base/message_loop/message_loop.h"
 #include "base/native_library.h"
 #include "base/path_service.h"
@@ -75,7 +76,7 @@
 std::string GetNSSErrorMessage() {
   std::string result;
   if (PR_GetErrorTextLength()) {
-    scoped_ptr<char[]> error_text(new char[PR_GetErrorTextLength() + 1]);
+    std::unique_ptr<char[]> error_text(new char[PR_GetErrorTextLength() + 1]);
     PRInt32 copied = PR_GetErrorText(error_text.get());
     result = std::string(error_text.get(), copied);
   } else {
@@ -167,7 +168,7 @@
 #endif
 
   if (db_on_nfs) {
-    scoped_ptr<base::Environment> env(base::Environment::Create());
+    std::unique_ptr<base::Environment> env(base::Environment::Create());
     static const char kUseCacheEnvVar[] = "NSS_SDB_USE_CACHE";
     if (!env->HasVar(kUseCacheEnvVar))
       env->SetVar(kUseCacheEnvVar, "yes");
@@ -372,7 +373,8 @@
 
     // Note that a reference is not taken to chaps_module_. This is safe since
     // NSSInitSingleton is Leaky, so the reference it holds is never released.
-    scoped_ptr<TPMModuleAndSlot> tpm_args(new TPMModuleAndSlot(chaps_module_));
+    std::unique_ptr<TPMModuleAndSlot> tpm_args(
+        new TPMModuleAndSlot(chaps_module_));
     TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
     if (base::WorkerPool::PostTaskAndReply(
             FROM_HERE,
@@ -418,7 +420,7 @@
 
   void OnInitializedTPMTokenAndSystemSlot(
       const base::Callback<void(bool)>& callback,
-      scoped_ptr<TPMModuleAndSlot> tpm_args) {
+      std::unique_ptr<TPMModuleAndSlot> tpm_args) {
     DCHECK(thread_checker_.CalledOnValidThread());
     DVLOG(2) << "Loaded chaps: " << !!tpm_args->chaps_module
              << ", got tpm slot: " << !!tpm_args->tpm_slot;
@@ -534,7 +536,8 @@
 
     // Note that a reference is not taken to chaps_module_. This is safe since
     // NSSInitSingleton is Leaky, so the reference it holds is never released.
-    scoped_ptr<TPMModuleAndSlot> tpm_args(new TPMModuleAndSlot(chaps_module_));
+    std::unique_ptr<TPMModuleAndSlot> tpm_args(
+        new TPMModuleAndSlot(chaps_module_));
     TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
     base::WorkerPool::PostTaskAndReply(
         FROM_HERE,
@@ -549,8 +552,9 @@
         );
   }
 
-  void OnInitializedTPMForChromeOSUser(const std::string& username_hash,
-                                       scoped_ptr<TPMModuleAndSlot> tpm_args) {
+  void OnInitializedTPMForChromeOSUser(
+      const std::string& username_hash,
+      std::unique_ptr<TPMModuleAndSlot> tpm_args) {
     DCHECK(thread_checker_.CalledOnValidThread());
     DVLOG(2) << "Got tpm slot for " << username_hash << " "
              << !!tpm_args->tpm_slot;
diff --git a/crypto/rsa_private_key_nss.cc b/crypto/rsa_private_key_nss.cc
index 7ec5ae4b..2538a723 100644
--- a/crypto/rsa_private_key_nss.cc
+++ b/crypto/rsa_private_key_nss.cc
@@ -10,10 +10,10 @@
 #include <stdint.h>
 
 #include <list>
+#include <memory>
 
 #include "base/debug/leak_annotations.h"
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_util.h"
 #include "crypto/nss_key_util.h"
 #include "crypto/nss_util.h"
diff --git a/crypto/rsa_private_key_openssl.cc b/crypto/rsa_private_key_openssl.cc
index 3e87a0a..bca4b24 100644
--- a/crypto/rsa_private_key_openssl.cc
+++ b/crypto/rsa_private_key_openssl.cc
@@ -4,15 +4,16 @@
 
 #include "crypto/rsa_private_key.h"
 
-#include <openssl/bytestring.h>
 #include <openssl/bn.h>
+#include <openssl/bytestring.h>
 #include <openssl/evp.h>
 #include <openssl/mem.h>
 #include <openssl/rsa.h>
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/auto_cbb.h"
 #include "crypto/openssl_util.h"
 #include "crypto/scoped_openssl_types.h"
@@ -31,7 +32,7 @@
   if (!RSA_generate_key_ex(rsa_key.get(), num_bits, bn.get(), NULL))
     return NULL;
 
-  scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
+  std::unique_ptr<RSAPrivateKey> result(new RSAPrivateKey);
   result->key_ = EVP_PKEY_new();
   if (!result->key_ || !EVP_PKEY_set1_RSA(result->key_, rsa_key.get()))
     return NULL;
@@ -50,7 +51,7 @@
   if (!pkey || CBS_len(&cbs) != 0 || EVP_PKEY_id(pkey.get()) != EVP_PKEY_RSA)
     return nullptr;
 
-  scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
+  std::unique_ptr<RSAPrivateKey> result(new RSAPrivateKey);
   result->key_ = pkey.release();
   return result.release();
 }
@@ -75,7 +76,7 @@
 }
 
 RSAPrivateKey* RSAPrivateKey::Copy() const {
-  scoped_ptr<RSAPrivateKey> copy(new RSAPrivateKey());
+  std::unique_ptr<RSAPrivateKey> copy(new RSAPrivateKey());
   ScopedRSA rsa(EVP_PKEY_get1_RSA(key_));
   if (!rsa)
     return NULL;
diff --git a/crypto/rsa_private_key_unittest.cc b/crypto/rsa_private_key_unittest.cc
index 1401e3d..393a24c5 100644
--- a/crypto/rsa_private_key_unittest.cc
+++ b/crypto/rsa_private_key_unittest.cc
@@ -6,7 +6,8 @@
 
 #include <stdint.h>
 
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
 #include "testing/gtest/include/gtest/gtest.h"
 
 namespace {
@@ -71,9 +72,9 @@
 // Generate random private keys with two different sizes. Reimport, then
 // export them again. We should get back the same exact bytes.
 TEST(RSAPrivateKeyUnitTest, InitRandomTest) {
-  scoped_ptr<crypto::RSAPrivateKey> keypair1(
+  std::unique_ptr<crypto::RSAPrivateKey> keypair1(
       crypto::RSAPrivateKey::Create(1024));
-  scoped_ptr<crypto::RSAPrivateKey> keypair2(
+  std::unique_ptr<crypto::RSAPrivateKey> keypair2(
       crypto::RSAPrivateKey::Create(2048));
   ASSERT_TRUE(keypair1.get());
   ASSERT_TRUE(keypair2.get());
@@ -88,9 +89,9 @@
   ASSERT_TRUE(keypair1->ExportPublicKey(&pubkey1));
   ASSERT_TRUE(keypair2->ExportPublicKey(&pubkey2));
 
-  scoped_ptr<crypto::RSAPrivateKey> keypair3(
+  std::unique_ptr<crypto::RSAPrivateKey> keypair3(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(privkey1));
-  scoped_ptr<crypto::RSAPrivateKey> keypair4(
+  std::unique_ptr<crypto::RSAPrivateKey> keypair4(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(privkey2));
   ASSERT_TRUE(keypair3.get());
   ASSERT_TRUE(keypair4.get());
@@ -113,10 +114,10 @@
   std::vector<uint8_t> input(kTestPrivateKeyInfo,
                              kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
 
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input));
 
-  scoped_ptr<crypto::RSAPrivateKey> key_copy(key->Copy());
+  std::unique_ptr<crypto::RSAPrivateKey> key_copy(key->Copy());
   ASSERT_TRUE(key_copy.get());
 
   std::vector<uint8_t> privkey_copy;
@@ -131,7 +132,7 @@
                              kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
   input.push_back(0);
 
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input));
 
   // Import should fail.
@@ -158,7 +159,7 @@
       kTestEcPrivateKeyInfo,
       kTestEcPrivateKeyInfo + sizeof(kTestEcPrivateKeyInfo));
 
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input));
 
   // Import should fail as the given PKCS8 bytes were for an EC key not RSA key.
@@ -187,7 +188,7 @@
   std::vector<uint8_t> input(kTestPrivateKeyInfo,
                              kTestPrivateKeyInfo + sizeof(kTestPrivateKeyInfo));
 
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input));
   ASSERT_TRUE(key.get());
 
@@ -334,9 +335,9 @@
   memcpy(&input2.front(), short_integer_without_high_bit,
          sizeof(short_integer_without_high_bit));
 
-  scoped_ptr<crypto::RSAPrivateKey> keypair1(
+  std::unique_ptr<crypto::RSAPrivateKey> keypair1(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input1));
-  scoped_ptr<crypto::RSAPrivateKey> keypair2(
+  std::unique_ptr<crypto::RSAPrivateKey> keypair2(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(input2));
   ASSERT_TRUE(keypair1.get());
   ASSERT_TRUE(keypair2.get());
@@ -355,11 +356,11 @@
 }
 
 TEST(RSAPrivateKeyUnitTest, CreateFromKeyTest) {
-  scoped_ptr<crypto::RSAPrivateKey> key_pair(
+  std::unique_ptr<crypto::RSAPrivateKey> key_pair(
       crypto::RSAPrivateKey::Create(512));
   ASSERT_TRUE(key_pair.get());
 
-  scoped_ptr<crypto::RSAPrivateKey> key_copy(
+  std::unique_ptr<crypto::RSAPrivateKey> key_copy(
       crypto::RSAPrivateKey::CreateFromKey(key_pair->key()));
   ASSERT_TRUE(key_copy.get());
 
diff --git a/crypto/scoped_nss_types.h b/crypto/scoped_nss_types.h
index 8e96e8d4..a739565 100644
--- a/crypto/scoped_nss_types.h
+++ b/crypto/scoped_nss_types.h
@@ -10,7 +10,7 @@
 #include <pk11pub.h>
 #include <plarena.h>
 
-#include "base/memory/scoped_ptr.h"
+#include <memory>
 
 namespace crypto {
 
@@ -29,29 +29,33 @@
 };
 
 // Define some convenient scopers around NSS pointers.
-typedef scoped_ptr<PK11Context,
-                   NSSDestroyer1<PK11Context, PK11_DestroyContext, PR_TRUE> >
+typedef std::unique_ptr<
+    PK11Context,
+    NSSDestroyer1<PK11Context, PK11_DestroyContext, PR_TRUE>>
     ScopedPK11Context;
-typedef scoped_ptr<PK11SlotInfo, NSSDestroyer<PK11SlotInfo, PK11_FreeSlot> >
+typedef std::unique_ptr<PK11SlotInfo, NSSDestroyer<PK11SlotInfo, PK11_FreeSlot>>
     ScopedPK11Slot;
-typedef scoped_ptr<PK11SlotList, NSSDestroyer<PK11SlotList, PK11_FreeSlotList> >
+typedef std::unique_ptr<PK11SlotList,
+                        NSSDestroyer<PK11SlotList, PK11_FreeSlotList>>
     ScopedPK11SlotList;
-typedef scoped_ptr<PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey> >
+typedef std::unique_ptr<PK11SymKey, NSSDestroyer<PK11SymKey, PK11_FreeSymKey>>
     ScopedPK11SymKey;
-typedef scoped_ptr<SECKEYPublicKey,
-                   NSSDestroyer<SECKEYPublicKey, SECKEY_DestroyPublicKey> >
+typedef std::unique_ptr<SECKEYPublicKey,
+                        NSSDestroyer<SECKEYPublicKey, SECKEY_DestroyPublicKey>>
     ScopedSECKEYPublicKey;
-typedef scoped_ptr<SECKEYPrivateKey,
-                   NSSDestroyer<SECKEYPrivateKey, SECKEY_DestroyPrivateKey> >
+typedef std::unique_ptr<
+    SECKEYPrivateKey,
+    NSSDestroyer<SECKEYPrivateKey, SECKEY_DestroyPrivateKey>>
     ScopedSECKEYPrivateKey;
-typedef scoped_ptr<SECAlgorithmID,
-                   NSSDestroyer1<SECAlgorithmID, SECOID_DestroyAlgorithmID,
-                                 PR_TRUE> >
+typedef std::unique_ptr<
+    SECAlgorithmID,
+    NSSDestroyer1<SECAlgorithmID, SECOID_DestroyAlgorithmID, PR_TRUE>>
     ScopedSECAlgorithmID;
-typedef scoped_ptr<SECItem, NSSDestroyer1<SECItem, SECITEM_FreeItem, PR_TRUE> >
+typedef std::unique_ptr<SECItem,
+                        NSSDestroyer1<SECItem, SECITEM_FreeItem, PR_TRUE>>
     ScopedSECItem;
-typedef scoped_ptr<PLArenaPool,
-                   NSSDestroyer1<PLArenaPool, PORT_FreeArena, PR_FALSE> >
+typedef std::unique_ptr<PLArenaPool,
+                        NSSDestroyer1<PLArenaPool, PORT_FreeArena, PR_FALSE>>
     ScopedPLArenaPool;
 
 }  // namespace crypto
diff --git a/crypto/scoped_openssl_types.h b/crypto/scoped_openssl_types.h
index 9bc5d743..76dd0f4 100644
--- a/crypto/scoped_openssl_types.h
+++ b/crypto/scoped_openssl_types.h
@@ -15,7 +15,7 @@
 #include <openssl/rsa.h>
 #include <stdint.h>
 
-#include "base/memory/scoped_ptr.h"
+#include <memory>
 
 namespace crypto {
 
@@ -29,7 +29,7 @@
 
 template <typename PointerType, void (*Destroyer)(PointerType*)>
 using ScopedOpenSSL =
-    scoped_ptr<PointerType, OpenSSLDestroyer<PointerType, Destroyer>>;
+    std::unique_ptr<PointerType, OpenSSLDestroyer<PointerType, Destroyer>>;
 
 struct OpenSSLFree {
   void operator()(uint8_t* ptr) const { OPENSSL_free(ptr); }
@@ -53,7 +53,7 @@
 using ScopedRSA = ScopedOpenSSL<RSA, RSA_free>;
 
 // The bytes must have been allocated with OPENSSL_malloc.
-using ScopedOpenSSLBytes = scoped_ptr<uint8_t, OpenSSLFree>;
+using ScopedOpenSSLBytes = std::unique_ptr<uint8_t, OpenSSLFree>;
 
 }  // namespace crypto
 
diff --git a/crypto/scoped_test_system_nss_key_slot.h b/crypto/scoped_test_system_nss_key_slot.h
index 99a269c..eb8fbc9 100644
--- a/crypto/scoped_test_system_nss_key_slot.h
+++ b/crypto/scoped_test_system_nss_key_slot.h
@@ -5,8 +5,9 @@
 #ifndef CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_
 #define CRYPTO_SCOPED_TEST_SYSTEM_NSS_KEY_SLOT_H_
 
+#include <memory>
+
 #include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/crypto_export.h"
 
 // Forward declaration, from <pk11pub.h>
@@ -33,7 +34,7 @@
   PK11SlotInfo* slot() const;
 
  private:
-  scoped_ptr<ScopedTestNSSDB> test_db_;
+  std::unique_ptr<ScopedTestNSSDB> test_db_;
 
   DISALLOW_COPY_AND_ASSIGN(ScopedTestSystemNSSKeySlot);
 };
diff --git a/crypto/secure_hash_unittest.cc b/crypto/secure_hash_unittest.cc
index 019e86f6..cb9f585 100644
--- a/crypto/secure_hash_unittest.cc
+++ b/crypto/secure_hash_unittest.cc
@@ -7,9 +7,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
 #include <string>
 
-#include "base/memory/scoped_ptr.h"
 #include "crypto/sha2.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
@@ -23,8 +23,8 @@
 
   uint8_t output3[crypto::kSHA256Length];
 
-  scoped_ptr<crypto::SecureHash> ctx(crypto::SecureHash::Create(
-      crypto::SecureHash::SHA256));
+  std::unique_ptr<crypto::SecureHash> ctx(
+      crypto::SecureHash::Create(crypto::SecureHash::SHA256));
   ctx->Update(input3.data(), input3.size());
   ctx->Update(input3.data(), input3.size());
 
@@ -50,12 +50,12 @@
   uint8_t output2[crypto::kSHA256Length];
   uint8_t output3[crypto::kSHA256Length];
 
-  scoped_ptr<crypto::SecureHash> ctx1(crypto::SecureHash::Create(
-      crypto::SecureHash::SHA256));
+  std::unique_ptr<crypto::SecureHash> ctx1(
+      crypto::SecureHash::Create(crypto::SecureHash::SHA256));
   ctx1->Update(input1.data(), input1.size());
 
-  scoped_ptr<crypto::SecureHash> ctx2(ctx1->Clone());
-  scoped_ptr<crypto::SecureHash> ctx3(ctx2->Clone());
+  std::unique_ptr<crypto::SecureHash> ctx2(ctx1->Clone());
+  std::unique_ptr<crypto::SecureHash> ctx3(ctx2->Clone());
   // At this point, ctx1, ctx2, and ctx3 are all equivalent and represent the
   // state after hashing input1.
 
@@ -76,7 +76,7 @@
 }
 
 TEST(SecureHashTest, TestLength) {
-  scoped_ptr<crypto::SecureHash> ctx(
+  std::unique_ptr<crypto::SecureHash> ctx(
       crypto::SecureHash::Create(crypto::SecureHash::SHA256));
   EXPECT_EQ(crypto::kSHA256Length, ctx->GetHashLength());
 }
diff --git a/crypto/sha2.cc b/crypto/sha2.cc
index 2646d1b..e97b8f4 100644
--- a/crypto/sha2.cc
+++ b/crypto/sha2.cc
@@ -6,14 +6,15 @@
 
 #include <stddef.h>
 
-#include "base/memory/scoped_ptr.h"
+#include <memory>
+
 #include "base/stl_util.h"
 #include "crypto/secure_hash.h"
 
 namespace crypto {
 
 void SHA256HashString(const base::StringPiece& str, void* output, size_t len) {
-  scoped_ptr<SecureHash> ctx(SecureHash::Create(SecureHash::SHA256));
+  std::unique_ptr<SecureHash> ctx(SecureHash::Create(SecureHash::SHA256));
   ctx->Update(str.data(), str.length());
   ctx->Finish(output, len);
 }
diff --git a/crypto/signature_creator_nss.cc b/crypto/signature_creator_nss.cc
index bf20413..538be93 100644
--- a/crypto/signature_creator_nss.cc
+++ b/crypto/signature_creator_nss.cc
@@ -9,8 +9,9 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/nss_util.h"
 #include "crypto/rsa_private_key.h"
 
@@ -50,7 +51,7 @@
 // static
 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key,
                                            HashAlgorithm hash_alg) {
-  scoped_ptr<SignatureCreator> result(new SignatureCreator);
+  std::unique_ptr<SignatureCreator> result(new SignatureCreator);
   result->sign_context_ = SGN_NewContext(ToNSSSigOid(hash_alg), key->key());
   if (!result->sign_context_) {
     NOTREACHED();
diff --git a/crypto/signature_creator_openssl.cc b/crypto/signature_creator_openssl.cc
index d5fc4d4..6543e63 100644
--- a/crypto/signature_creator_openssl.cc
+++ b/crypto/signature_creator_openssl.cc
@@ -9,8 +9,9 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
+
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/openssl_util.h"
 #include "crypto/rsa_private_key.h"
 #include "crypto/scoped_openssl_types.h"
@@ -45,7 +46,7 @@
 SignatureCreator* SignatureCreator::Create(RSAPrivateKey* key,
                                            HashAlgorithm hash_alg) {
   OpenSSLErrStackTracer err_tracer(FROM_HERE);
-  scoped_ptr<SignatureCreator> result(new SignatureCreator);
+  std::unique_ptr<SignatureCreator> result(new SignatureCreator);
   const EVP_MD* const digest = ToOpenSSLDigest(hash_alg);
   DCHECK(digest);
   if (!digest) {
diff --git a/crypto/signature_creator_unittest.cc b/crypto/signature_creator_unittest.cc
index fff065e5..819e663d 100644
--- a/crypto/signature_creator_unittest.cc
+++ b/crypto/signature_creator_unittest.cc
@@ -2,31 +2,32 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "crypto/signature_creator.h"
+
 #include <stdint.h>
 
+#include <memory>
 #include <vector>
 
-#include "base/memory/scoped_ptr.h"
 #include "base/sha1.h"
 #include "crypto/rsa_private_key.h"
 #include "crypto/sha2.h"
-#include "crypto/signature_creator.h"
 #include "crypto/signature_verifier.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 TEST(SignatureCreatorTest, BasicTest) {
   // Do a verify round trip.
-  scoped_ptr<crypto::RSAPrivateKey> key_original(
+  std::unique_ptr<crypto::RSAPrivateKey> key_original(
       crypto::RSAPrivateKey::Create(1024));
   ASSERT_TRUE(key_original.get());
 
   std::vector<uint8_t> key_info;
   key_original->ExportPrivateKey(&key_info);
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
   ASSERT_TRUE(key.get());
 
-  scoped_ptr<crypto::SignatureCreator> signer(
+  std::unique_ptr<crypto::SignatureCreator> signer(
       crypto::SignatureCreator::Create(key.get(),
                                        crypto::SignatureCreator::SHA1));
   ASSERT_TRUE(signer.get());
@@ -53,13 +54,13 @@
 
 TEST(SignatureCreatorTest, SignDigestTest) {
   // Do a verify round trip.
-  scoped_ptr<crypto::RSAPrivateKey> key_original(
+  std::unique_ptr<crypto::RSAPrivateKey> key_original(
       crypto::RSAPrivateKey::Create(1024));
   ASSERT_TRUE(key_original.get());
 
   std::vector<uint8_t> key_info;
   key_original->ExportPrivateKey(&key_info);
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
   ASSERT_TRUE(key.get());
 
@@ -87,13 +88,13 @@
 
 TEST(SignatureCreatorTest, SignSHA256DigestTest) {
   // Do a verify round trip.
-  scoped_ptr<crypto::RSAPrivateKey> key_original(
+  std::unique_ptr<crypto::RSAPrivateKey> key_original(
       crypto::RSAPrivateKey::Create(1024));
   ASSERT_TRUE(key_original.get());
 
   std::vector<uint8_t> key_info;
   key_original->ExportPrivateKey(&key_info);
-  scoped_ptr<crypto::RSAPrivateKey> key(
+  std::unique_ptr<crypto::RSAPrivateKey> key(
       crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_info));
   ASSERT_TRUE(key.get());
 
diff --git a/crypto/signature_verifier_openssl.cc b/crypto/signature_verifier_openssl.cc
index 495abd2..f4a3d4f0 100644
--- a/crypto/signature_verifier_openssl.cc
+++ b/crypto/signature_verifier_openssl.cc
@@ -9,10 +9,10 @@
 #include <openssl/evp.h>
 #include <stdint.h>
 
+#include <memory>
 #include <vector>
 
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "crypto/openssl_util.h"
 #include "crypto/scoped_openssl_types.h"
 
diff --git a/crypto/symmetric_key_openssl.cc b/crypto/symmetric_key_openssl.cc
index 2c5358f..5aef1d4 100644
--- a/crypto/symmetric_key_openssl.cc
+++ b/crypto/symmetric_key_openssl.cc
@@ -10,9 +10,9 @@
 #include <stdint.h>
 
 #include <algorithm>
+#include <memory>
 
 #include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_util.h"
 #include "crypto/openssl_util.h"
 
@@ -40,7 +40,7 @@
     return NULL;
 
   OpenSSLErrStackTracer err_tracer(FROM_HERE);
-  scoped_ptr<SymmetricKey> key(new SymmetricKey);
+  std::unique_ptr<SymmetricKey> key(new SymmetricKey);
   uint8_t* key_data = reinterpret_cast<uint8_t*>(
       base::WriteInto(&key->key_, key_size_in_bytes + 1));
 
@@ -71,7 +71,7 @@
     return NULL;
 
   OpenSSLErrStackTracer err_tracer(FROM_HERE);
-  scoped_ptr<SymmetricKey> key(new SymmetricKey);
+  std::unique_ptr<SymmetricKey> key(new SymmetricKey);
   uint8_t* key_data = reinterpret_cast<uint8_t*>(
       base::WriteInto(&key->key_, key_size_in_bytes + 1));
   int rv = PKCS5_PBKDF2_HMAC_SHA1(
@@ -92,7 +92,7 @@
       return NULL;
   }
 
-  scoped_ptr<SymmetricKey> key(new SymmetricKey);
+  std::unique_ptr<SymmetricKey> key(new SymmetricKey);
   key->key_ = raw_key;
   return key.release();
 }
diff --git a/crypto/symmetric_key_unittest.cc b/crypto/symmetric_key_unittest.cc
index ef8e7e1..7cd47cd 100644
--- a/crypto/symmetric_key_unittest.cc
+++ b/crypto/symmetric_key_unittest.cc
@@ -4,15 +4,15 @@
 
 #include "crypto/symmetric_key.h"
 
+#include <memory>
 #include <string>
 
-#include "base/memory/scoped_ptr.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 TEST(SymmetricKeyTest, GenerateRandomKey) {
-  scoped_ptr<crypto::SymmetricKey> key(
+  std::unique_ptr<crypto::SymmetricKey> key(
       crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
   ASSERT_TRUE(NULL != key.get());
   std::string raw_key;
@@ -21,7 +21,7 @@
 
   // Do it again and check that the keys are different.
   // (Note: this has a one-in-10^77 chance of failure!)
-  scoped_ptr<crypto::SymmetricKey> key2(
+  std::unique_ptr<crypto::SymmetricKey> key2(
       crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
   ASSERT_TRUE(NULL != key2.get());
   std::string raw_key2;
@@ -31,13 +31,13 @@
 }
 
 TEST(SymmetricKeyTest, ImportGeneratedKey) {
-  scoped_ptr<crypto::SymmetricKey> key1(
+  std::unique_ptr<crypto::SymmetricKey> key1(
       crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
   ASSERT_TRUE(NULL != key1.get());
   std::string raw_key1;
   EXPECT_TRUE(key1->GetRawKey(&raw_key1));
 
-  scoped_ptr<crypto::SymmetricKey> key2(
+  std::unique_ptr<crypto::SymmetricKey> key2(
       crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, raw_key1));
   ASSERT_TRUE(NULL != key2.get());
 
@@ -48,14 +48,14 @@
 }
 
 TEST(SymmetricKeyTest, ImportDerivedKey) {
-  scoped_ptr<crypto::SymmetricKey> key1(
+  std::unique_ptr<crypto::SymmetricKey> key1(
       crypto::SymmetricKey::DeriveKeyFromPassword(
           crypto::SymmetricKey::HMAC_SHA1, "password", "somesalt", 1024, 160));
   ASSERT_TRUE(NULL != key1.get());
   std::string raw_key1;
   EXPECT_TRUE(key1->GetRawKey(&raw_key1));
 
-  scoped_ptr<crypto::SymmetricKey> key2(
+  std::unique_ptr<crypto::SymmetricKey> key2(
       crypto::SymmetricKey::Import(crypto::SymmetricKey::HMAC_SHA1, raw_key1));
   ASSERT_TRUE(NULL != key2.get());
 
@@ -89,10 +89,9 @@
   }
 #endif  // OS_MACOSX
 
-  scoped_ptr<crypto::SymmetricKey> key(
+  std::unique_ptr<crypto::SymmetricKey> key(
       crypto::SymmetricKey::DeriveKeyFromPassword(
-          test_data.algorithm,
-          test_data.password, test_data.salt,
+          test_data.algorithm, test_data.password, test_data.salt,
           test_data.rounds, test_data.key_size_in_bits));
   ASSERT_TRUE(NULL != key.get());
 
diff --git a/crypto/symmetric_key_win.cc b/crypto/symmetric_key_win.cc
index ac8e614..1acfcd0 100644
--- a/crypto/symmetric_key_win.cc
+++ b/crypto/symmetric_key_win.cc
@@ -7,10 +7,10 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#include <memory>
 #include <vector>
 
 // TODO(wtc): replace scoped_array by std::vector.
-#include "base/memory/scoped_ptr.h"
 #include "base/sys_byteorder.h"
 
 namespace crypto {
@@ -171,7 +171,7 @@
                      ALG_ID alg,
                      ScopedHCRYPTPROV* provider,
                      ScopedHCRYPTKEY* key,
-                     scoped_ptr<BYTE[]>* raw_key) {
+                     std::unique_ptr<BYTE[]>* raw_key) {
   DCHECK(provider);
   DCHECK(key);
   DCHECK(raw_key);
@@ -188,7 +188,7 @@
     return false;
 
   DWORD key_size_in_bytes = static_cast<DWORD>(key_size_in_bits / 8);
-  scoped_ptr<BYTE[]> random(new BYTE[key_size_in_bytes]);
+  std::unique_ptr<BYTE[]> random(new BYTE[key_size_in_bytes]);
   ok = CryptGenRandom(safe_provider, key_size_in_bytes, random.get());
   if (!ok)
     return false;
@@ -323,7 +323,7 @@
   ScopedHCRYPTKEY key;
 
   bool ok = false;
-  scoped_ptr<BYTE[]> raw_key;
+  std::unique_ptr<BYTE[]> raw_key;
 
   switch (algorithm) {
     case AES:
diff --git a/net/android/keystore_openssl.cc b/net/android/keystore_openssl.cc
index 611b926..f60842c 100644
--- a/net/android/keystore_openssl.cc
+++ b/net/android/keystore_openssl.cc
@@ -17,6 +17,7 @@
 #include "base/android/scoped_java_ref.h"
 #include "base/lazy_instance.h"
 #include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
 #include "crypto/openssl_util.h"
 #include "net/android/keystore.h"
 #include "net/android/legacy_openssl.h"
diff --git a/net/cert/jwk_serializer_nss.cc b/net/cert/jwk_serializer_nss.cc
index 441a98f..426a207 100644
--- a/net/cert/jwk_serializer_nss.cc
+++ b/net/cert/jwk_serializer_nss.cc
@@ -9,6 +9,7 @@
 #include <nss.h>
 
 #include "base/base64url.h"
+#include "base/memory/scoped_ptr.h"
 #include "base/values.h"
 #include "crypto/nss_util.h"
 #include "crypto/scoped_nss_types.h"
diff --git a/net/cert/nss_cert_database.h b/net/cert/nss_cert_database.h
index de783eb4..fe267f9 100644
--- a/net/cert/nss_cert_database.h
+++ b/net/cert/nss_cert_database.h
@@ -13,6 +13,7 @@
 #include "base/callback_forward.h"
 #include "base/macros.h"
 #include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
 #include "base/memory/weak_ptr.h"
 #include "base/strings/string16.h"
 #include "crypto/scoped_nss_types.h"