• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 23ecc2149133fa0cf369f53b5d7d28e78815bca3 Mon Sep 17 00:00:00 2001
2From: Hidehiko Abe <hidehiko@chromium.org>
3Date: Thu, 13 Jun 2019 22:27:41 +0900
4Subject: [PATCH] libchrome: Update crypto.
5
6libchrome uses OpenSSH, instead of BoringSSH, although its support
7was dropped in Chrome already.
8To lengthen its lifetime, this patch adds minor fix.
9- Use base::data() instead of base::string_as_array().
10  The method was removed. cf) crrev.com/c/1056014.
11- Use base::PostTaskAndReply instead of base::WorkerPool.
12  The class was removed. cf) crrev.com/c/650368
13- tracked_object::Location is renamed to base::Location.
14  cf) crbug.com/763556
15- base::Location::Write was removed. Use ToString().
16  cf) crrev.com/c/707310
17- base::MakeUnique was removed. Use std::make_unique.
18  cf) crrev.com/c/944048
19
20BUG=chromium:909719
21TEST=Built locally.
22
23Change-Id: I2ba45db7592ea9addc2df230b977ffb950f0b342
24---
25 crypto/nss_util.cc     | 37 ++++++++++++++-----------------------
26 crypto/openssl_util.cc |  6 ++----
27 crypto/openssl_util.h  |  7 +++----
28 crypto/sha2.cc         |  2 +-
29 4 files changed, 20 insertions(+), 32 deletions(-)
30
31diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc
32index a7752d3..f9c6373 100644
33--- a/crypto/nss_util.cc
34+++ b/crypto/nss_util.cc
35@@ -38,14 +38,13 @@
36 #include "base/files/file_util.h"
37 #include "base/lazy_instance.h"
38 #include "base/logging.h"
39-#include "base/memory/ptr_util.h"
40 #include "base/message_loop/message_loop.h"
41 #include "base/native_library.h"
42 #include "base/stl_util.h"
43 #include "base/strings/stringprintf.h"
44+#include "base/task_scheduler/post_task.h"
45 #include "base/threading/thread_checker.h"
46 #include "base/threading/thread_restrictions.h"
47-#include "base/threading/worker_pool.h"
48 #include "build/build_config.h"
49
50 #if !defined(OS_CHROMEOS)
51@@ -380,22 +379,16 @@ class NSSInitSingleton {
52     std::unique_ptr<TPMModuleAndSlot> tpm_args(
53         new TPMModuleAndSlot(chaps_module_));
54     TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
55-    if (base::WorkerPool::PostTaskAndReply(
56-            FROM_HERE,
57-            base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
58-                       system_slot_id,
59-                       tpm_args_ptr),
60-            base::Bind(&NSSInitSingleton::OnInitializedTPMTokenAndSystemSlot,
61-                       base::Unretained(this),  // NSSInitSingleton is leaky
62-                       callback,
63-                       base::Passed(&tpm_args)),
64-            true /* task_is_slow */
65-            )) {
66-      initializing_tpm_token_ = true;
67-    } else {
68-      base::MessageLoop::current()->task_runner()->PostTask(
69-          FROM_HERE, base::Bind(callback, false));
70-    }
71+    base::PostTaskAndReply(
72+        FROM_HERE,
73+        base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
74+                   system_slot_id,
75+                   tpm_args_ptr),
76+        base::Bind(&NSSInitSingleton::OnInitializedTPMTokenAndSystemSlot,
77+                   base::Unretained(this),  // NSSInitSingleton is leaky
78+                   callback,
79+                   base::Passed(&tpm_args)));
80+    initializing_tpm_token_ = true;
81   }
82
83   static void InitializeTPMTokenOnWorkerThread(CK_SLOT_ID token_slot_id,
84@@ -508,7 +501,7 @@ class NSSInitSingleton {
85         "%s %s", kUserNSSDatabaseName, username_hash.c_str());
86     ScopedPK11Slot public_slot(OpenPersistentNSSDBForPath(db_name, path));
87     chromeos_user_map_[username_hash] =
88-        base::MakeUnique<ChromeOSUserData>(std::move(public_slot));
89+        std::make_unique<ChromeOSUserData>(std::move(public_slot));
90     return true;
91   }
92
93@@ -543,7 +536,7 @@ class NSSInitSingleton {
94     std::unique_ptr<TPMModuleAndSlot> tpm_args(
95         new TPMModuleAndSlot(chaps_module_));
96     TPMModuleAndSlot* tpm_args_ptr = tpm_args.get();
97-    base::WorkerPool::PostTaskAndReply(
98+    base::PostTaskAndReply(
99         FROM_HERE,
100         base::Bind(&NSSInitSingleton::InitializeTPMTokenOnWorkerThread,
101                    slot_id,
102@@ -551,9 +544,7 @@ class NSSInitSingleton {
103         base::Bind(&NSSInitSingleton::OnInitializedTPMForChromeOSUser,
104                    base::Unretained(this),  // NSSInitSingleton is leaky
105                    username_hash,
106-                   base::Passed(&tpm_args)),
107-        true /* task_is_slow */
108-        );
109+                   base::Passed(&tpm_args)));
110   }
111
112   void OnInitializedTPMForChromeOSUser(
113diff --git a/crypto/openssl_util.cc b/crypto/openssl_util.cc
114index c1b7a90..b671eab 100644
115--- a/crypto/openssl_util.cc
116+++ b/crypto/openssl_util.cc
117@@ -46,15 +46,13 @@ void EnsureOpenSSLInit() {
118 #endif
119 }
120
121-void ClearOpenSSLERRStack(const tracked_objects::Location& location) {
122+void ClearOpenSSLERRStack(const base::Location& location) {
123   if (DCHECK_IS_ON() && VLOG_IS_ON(1)) {
124     uint32_t error_num = ERR_peek_error();
125     if (error_num == 0)
126       return;
127
128-    std::string message;
129-    location.Write(true, true, &message);
130-    DVLOG(1) << "OpenSSL ERR_get_error stack from " << message;
131+    DVLOG(1) << "OpenSSL ERR_get_error stack from " << location.ToString();
132     ERR_print_errors_cb(&OpenSSLErrorCallback, NULL);
133   } else {
134     ERR_clear_error();
135diff --git a/crypto/openssl_util.h b/crypto/openssl_util.h
136index d608cde..c3d6cc9 100644
137--- a/crypto/openssl_util.h
138+++ b/crypto/openssl_util.h
139@@ -63,8 +63,7 @@ CRYPTO_EXPORT void EnsureOpenSSLInit();
140 // Drains the OpenSSL ERR_get_error stack. On a debug build the error codes
141 // are send to VLOG(1), on a release build they are disregarded. In most
142 // cases you should pass FROM_HERE as the |location|.
143-CRYPTO_EXPORT void ClearOpenSSLERRStack(
144-    const tracked_objects::Location& location);
145+CRYPTO_EXPORT void ClearOpenSSLERRStack(const base::Location& location);
146
147 // Place an instance of this class on the call stack to automatically clear
148 // the OpenSSL error stack on function exit.
149@@ -73,7 +72,7 @@ class OpenSSLErrStackTracer {
150   // Pass FROM_HERE as |location|, to help track the source of OpenSSL error
151   // messages. Note any diagnostic emitted will be tagged with the location of
152   // the constructor call as it's not possible to trace a destructor's callsite.
153-  explicit OpenSSLErrStackTracer(const tracked_objects::Location& location)
154+  explicit OpenSSLErrStackTracer(const base::Location& location)
155       : location_(location) {
156     EnsureOpenSSLInit();
157   }
158@@ -82,7 +81,7 @@ class OpenSSLErrStackTracer {
159   }
160
161  private:
162-  const tracked_objects::Location location_;
163+  const base::Location location_;
164
165   DISALLOW_IMPLICIT_CONSTRUCTORS(OpenSSLErrStackTracer);
166 };
167diff --git a/crypto/sha2.cc b/crypto/sha2.cc
168index 1b302b3..71566a9 100644
169--- a/crypto/sha2.cc
170+++ b/crypto/sha2.cc
171@@ -21,7 +21,7 @@ void SHA256HashString(const base::StringPiece& str, void* output, size_t len) {
172
173 std::string SHA256HashString(const base::StringPiece& str) {
174   std::string output(kSHA256Length, 0);
175-  SHA256HashString(str, base::string_as_array(&output), output.size());
176+  SHA256HashString(str, base::data(output), output.size());
177   return output;
178 }
179
180--
1812.22.0.rc2.383.gf4fbbf30c2-goog
182
183