You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
6.9 KiB

From 23ecc2149133fa0cf369f53b5d7d28e78815bca3 Mon Sep 17 00:00:00 2001
From: Hidehiko Abe <hidehiko@chromium.org>
Date: Thu, 13 Jun 2019 22:27:41 +0900
Subject: [PATCH] libchrome: Update crypto.
libchrome uses OpenSSH, instead of BoringSSH, although its support
was dropped in Chrome already.
To lengthen its lifetime, this patch adds minor fix.
- Use base::data() instead of base::string_as_array().
The method was removed. cf) crrev.com/c/1056014.
- Use base::PostTaskAndReply instead of base::WorkerPool.
The class was removed. cf) crrev.com/c/650368
- tracked_object::Location is renamed to base::Location.
cf) crbug.com/763556
- base::Location::Write was removed. Use ToString().
cf) crrev.com/c/707310
- base::MakeUnique was removed. Use std::make_unique.
cf) crrev.com/c/944048
BUG=chromium:909719
TEST=Built locally.
Change-Id: I2ba45db7592ea9addc2df230b977ffb950f0b342
---
crypto/nss_util.cc | 37 ++++++++++++++-----------------------
crypto/openssl_util.cc | 6 ++----
crypto/openssl_util.h | 7 +++----
crypto/sha2.cc | 2 +-
4 files changed, 20 insertions(+), 32 deletions(-)
diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
index a7752d3..f9c6373 100644
--- a/crypto/nss_util.cc
+++ b/crypto/nss_util.cc
@@ -38,14 +38,13 @@
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
-#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "base/native_library.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_restrictions.h"
-#include "base/threading/worker_pool.h"
#include "build/build_config.h"
#if !defined(OS_CHROMEOS)
@@ -380,22 +379,16 @@ class NSSInitSingleton {
std::unique_ptr<TPMModuleAndSlot> tpm_args(
new TPMModuleAndSlot(chaps_module_));
TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
- if (base::WorkerPool::PostTaskAndReply(
- FROM_HERE,
- base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
- system_slot_id,
- tpm_args_ptr),
- base::Bind(&NSSInitSingleton::OnInitializedTPMTokenAndSystemSlot,
- base::Unretained(this), // NSSInitSingleton is leaky
- callback,
- base::Passed(&tpm_args)),
- true /* task_is_slow */
- )) {
- initializing_tpm_token_ = true;
- } else {
- base::MessageLoop::current()->task_runner()->PostTask(
- FROM_HERE, base::Bind(callback, false));
- }
+ base::PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
+ system_slot_id,
+ tpm_args_ptr),
+ base::Bind(&NSSInitSingleton::OnInitializedTPMTokenAndSystemSlot,
+ base::Unretained(this), // NSSInitSingleton is leaky
+ callback,
+ base::Passed(&tpm_args)));
+ initializing_tpm_token_ = true;
}
static void InitializeTPMTokenOnWorkerThread(CK_SLOT_ID token_slot_id,
@@ -508,7 +501,7 @@ class NSSInitSingleton {
"%s %s", kUserNSSDatabaseName, username_hash.c_str());
ScopedPK11Slot public_slot(OpenPersistentNSSDBForPath(db_name, path));
chromeos_user_map_[username_hash] =
- base::MakeUnique<ChromeOSUserData>(std::move(public_slot));
+ std::make_unique<ChromeOSUserData>(std::move(public_slot));
return true;
}
@@ -543,7 +536,7 @@ class NSSInitSingleton {
std::unique_ptr<TPMModuleAndSlot> tpm_args(
new TPMModuleAndSlot(chaps_module_));
TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
- base::WorkerPool::PostTaskAndReply(
+ base::PostTaskAndReply(
FROM_HERE,
base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
slot_id,
@@ -551,9 +544,7 @@ class NSSInitSingleton {
base::Bind(&NSSInitSingleton::OnInitializedTPMForChromeOSUser,
base::Unretained(this), // NSSInitSingleton is leaky
username_hash,
- base::Passed(&tpm_args)),
- true /* task_is_slow */
- );
+ base::Passed(&tpm_args)));
}
void OnInitializedTPMForChromeOSUser(
diff --git a/crypto/openssl_util.cc b/crypto/openssl_util.cc
index c1b7a90..b671eab 100644
--- a/crypto/openssl_util.cc
+++ b/crypto/openssl_util.cc
@@ -46,15 +46,13 @@ void EnsureOpenSSLInit() {
#endif
}
-void ClearOpenSSLERRStack(const tracked_objects::Location& location) {
+void ClearOpenSSLERRStack(const base::Location& location) {
if (DCHECK_IS_ON() && VLOG_IS_ON(1)) {
uint32_t error_num = ERR_peek_error();
if (error_num == 0)
return;
- std::string message;
- location.Write(true, true, &message);
- DVLOG(1) << "OpenSSL ERR_get_error stack from " << message;
+ DVLOG(1) << "OpenSSL ERR_get_error stack from " << location.ToString();
ERR_print_errors_cb(&OpenSSLErrorCallback, NULL);
} else {
ERR_clear_error();
diff --git a/crypto/openssl_util.h b/crypto/openssl_util.h
index d608cde..c3d6cc9 100644
--- a/crypto/openssl_util.h
+++ b/crypto/openssl_util.h
@@ -63,8 +63,7 @@ CRYPTO_EXPORT void EnsureOpenSSLInit();
// Drains the OpenSSL ERR_get_error stack. On a debug build the error codes
// are send to VLOG(1), on a release build they are disregarded. In most
// cases you should pass FROM_HERE as the |location|.
-CRYPTO_EXPORT void ClearOpenSSLERRStack(
- const tracked_objects::Location& location);
+CRYPTO_EXPORT void ClearOpenSSLERRStack(const base::Location& location);
// Place an instance of this class on the call stack to automatically clear
// the OpenSSL error stack on function exit.
@@ -73,7 +72,7 @@ class OpenSSLErrStackTracer {
// Pass FROM_HERE as |location|, to help track the source of OpenSSL error
// messages. Note any diagnostic emitted will be tagged with the location of
// the constructor call as it's not possible to trace a destructor's callsite.
- explicit OpenSSLErrStackTracer(const tracked_objects::Location& location)
+ explicit OpenSSLErrStackTracer(const base::Location& location)
: location_(location) {
EnsureOpenSSLInit();
}
@@ -82,7 +81,7 @@ class OpenSSLErrStackTracer {
}
private:
- const tracked_objects::Location location_;
+ const base::Location location_;
DISALLOW_IMPLICIT_CONSTRUCTORS(OpenSSLErrStackTracer);
};
diff --git a/crypto/sha2.cc b/crypto/sha2.cc
index 1b302b3..71566a9 100644
--- a/crypto/sha2.cc
+++ b/crypto/sha2.cc
@@ -21,7 +21,7 @@ void SHA256HashString(const base::StringPiece& str, void* output, size_t len) {
std::string SHA256HashString(const base::StringPiece& str) {
std::string output(kSHA256Length, 0);
- SHA256HashString(str, base::string_as_array(&output), output.size());
+ SHA256HashString(str, base::data(output), output.size());
return output;
}
--
2.22.0.rc2.383.gf4fbbf30c2-goog