summaryrefslogtreecommitdiff
path: root/libchrome_tools/patches/libchrome-Update-crypto.patch
blob: 45991605cd165abd6c03bdf243d80cb73ef6e7d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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