summaryrefslogtreecommitdiff
path: root/www-client/chromium/files/chromium-revert-e7963c4-78.patch
blob: fe7e1a68722b85106af94e64c5991ef00192907f (plain) (blame)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
diff --git a/chrome/test/chromedriver/client/chromedriver.py b/chrome/test/chromedriver/client/chromedriver.py
index 74b780e5f..8bd1cc004 100644
--- a/chrome/test/chromedriver/client/chromedriver.py
+++ b/chrome/test/chromedriver/client/chromedriver.py
@@ -653,7 +653,3 @@ class ChromeDriver(object):
     if signCount is not None:
       options['signCount'] = signCount
     return self.ExecuteCommand(Command.ADD_CREDENTIAL, options)
-
-  def GetCredentials(self, authenticatorId):
-    params = {'authenticatorId': authenticatorId}
-    return self.ExecuteCommand(Command.GET_CREDENTIALS, params)
diff --git a/chrome/test/chromedriver/client/command_executor.py b/chrome/test/chromedriver/client/command_executor.py
index 2286d839f..de27e1a3c 100644
--- a/chrome/test/chromedriver/client/command_executor.py
+++ b/chrome/test/chromedriver/client/command_executor.py
@@ -176,9 +176,6 @@ class Command(object):
   ADD_CREDENTIAL = (
       _Method.POST,
       '/session/:sessionId/webauthn/authenticator/:authenticatorId/credential')
-  GET_CREDENTIALS = (
-      _Method.GET,
-      '/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')
 
   # Custom Chrome commands.
   IS_LOADING = (_Method.GET, '/session/:sessionId/is_loading')
diff --git a/chrome/test/chromedriver/server/http_handler.cc b/chrome/test/chromedriver/server/http_handler.cc
index 737e34dce..0c9a00119 100644
--- a/chrome/test/chromedriver/server/http_handler.cc
+++ b/chrome/test/chromedriver/server/http_handler.cc
@@ -764,14 +764,6 @@ HttpHandler::HttpHandler(
               "AddCredential",
               base::BindRepeating(&ExecuteWebAuthnCommand,
                                   base::BindRepeating(&ExecuteAddCredential)))),
-      CommandMapping(
-          kGet,
-          "session/:sessionId/webauthn/authenticator/:authenticatorId/"
-          "credentials",
-          WrapToCommand("GetCredentials",
-                        base::BindRepeating(
-                            &ExecuteWebAuthnCommand,
-                            base::BindRepeating(&ExecuteGetCredentials)))),
 
       //
       // Non-standard extension commands
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py
index 15e986899..d59650004 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -226,7 +226,6 @@ _ANDROID_NEGATIVE_FILTER['chrome'] = (
         'ChromeDriverSecureContextTest.testAddVirtualAuthenticator',
         'ChromeDriverSecureContextTest.testRemoveVirtualAuthenticator',
         'ChromeDriverSecureContextTest.testAddCredential',
-        'ChromeDriverSecureContextTest.testGetCredentials',
     ]
 )
 _ANDROID_NEGATIVE_FILTER['chrome_stable'] = (
@@ -2018,11 +2017,6 @@ class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
 
 # Tests that require a secure context.
 class ChromeDriverSecureContextTest(ChromeDriverBaseTest):
-  # The example attestation private key from the U2F spec at
-  # https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.html#registration-example
-  # PKCS.8 encoded without encryption, as a base64url string.
-  privateKey = "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Qhk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwURmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB"
-
   @staticmethod
   def GlobalSetUp():
     cert_path = os.path.join(chrome_paths.GetTestData(),
@@ -2039,21 +2033,6 @@ class ChromeDriverSecureContextTest(ChromeDriverBaseTest):
     return ChromeDriverSecureContextTest._https_server.GetUrl(
         host) + file_path
 
-  # Encodes a string in URL-safe base64 with no padding.
-  @staticmethod
-  def URLSafeBase64Encode(string):
-    encoded = base64.urlsafe_b64encode(string)
-    while encoded[-1] == "=":
-      encoded = encoded[0:-1]
-    return encoded
-
-  # Decodes a base64 string with no padding.
-  @staticmethod
-  def UrlSafeBase64Decode(string):
-    string = string.encode("utf-8")
-    string += "=" * (4 - len(string) % 4)
-    return base64.urlsafe_b64decode(string)
-
   def setUp(self):
     self._driver = self.CreateDriver(
         chrome_switches=['host-resolver-rules=MAP * 127.0.0.1'])
@@ -2101,6 +2080,10 @@ class ChromeDriverSecureContextTest(ChromeDriverBaseTest):
         self._driver.RemoveVirtualAuthenticator, response['authenticatorId'])
 
   def testAddCredential(self):
+    # The example attestation private key from the U2F spec at
+    # https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.html#registration-example
+    # PKCS.8 encoded without encryption.
+    privateKey = "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8/zMDQDYAxlU+Qhk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwURmgsJYxGP//fWN/S+j5sN4tT15XEpN/7QZnt14YvI6uvAgO0uJEboFaZlOEB"
 
     script = """
       let done = arguments[0];
@@ -2123,78 +2106,16 @@ class ChromeDriverSecureContextTest(ChromeDriverBaseTest):
     # Register a credential and try authenticating with it.
     self._driver.AddCredential(
       authenticatorId = authenticatorId,
-      credentialId = self.URLSafeBase64Encode("cred-1"),
+      credentialId = base64.b64encode("cred-1"),
       isResidentCredential=False,
       rpId="chromedriver.test",
-      privateKey=self.privateKey,
+      privateKey=privateKey,
       signCount=1,
     )
 
     result = self._driver.ExecuteAsyncScript(script)
     self.assertEquals('OK', result['status'])
 
-  def testAddCredentialBase64Errors(self):
-    # Test that AddCredential checks UrlBase64 parameteres.
-    self._driver.Load(self.GetHttpsUrlForFile(
-        '/chromedriver/webauthn_test.html', 'chromedriver.test'))
-
-    authenticatorId = self._driver.AddVirtualAuthenticator(
-        protocol = 'ctap2',
-        transport = 'usb',
-        hasResidentKey = False,
-        hasUserVerification = False,
-    )['authenticatorId']
-
-    # Try adding a credentialId that is encoded in vanilla base64.
-    self.assertRaisesRegexp(
-        chromedriver.InvalidArgument,
-        'credentialId must be a base64url encoded string',
-        self._driver.AddCredential, authenticatorId, '_0n+wWqg=',
-        False, "chromedriver.test", self.privateKey, None, 1,
-    )
-
-    # Try adding a credentialId that is not a string.
-    self.assertRaisesRegexp(
-        chromedriver.InvalidArgument,
-        'credentialId must be a base64url encoded string',
-        self._driver.AddCredential, authenticatorId, 1,
-        False, "chromedriver.test", self.privateKey, None, 1,
-    )
-
-  def testGetCredentials(self):
-    script = """
-      let done = arguments[0];
-      registerCredential({
-        authenticatorSelection: {
-          requireResidentKey: true,
-        },
-      }).then(done);
-    """
-    self._driver.Load(self.GetHttpsUrlForFile(
-        '/chromedriver/webauthn_test.html', 'chromedriver.test'))
-    authenticatorId = self._driver.AddVirtualAuthenticator(
-        protocol = 'ctap2',
-        transport = 'usb',
-        hasResidentKey = True,
-        hasUserVerification = True,
-    )['authenticatorId']
-
-    # Register a credential via the webauthn API.
-    result = self._driver.ExecuteAsyncScript(script)
-    self.assertEquals('OK', result['status'])
-    credentialId = result['credential']['id']
-
-    # GetCredentials should return the credential that was just created.
-    credentials = self._driver.GetCredentials(authenticatorId)['credentials']
-    self.assertEquals(1, len(credentials))
-    self.assertEquals(credentialId, credentials[0]['credentialId'])
-    self.assertEquals(True, credentials[0]['isResidentCredential'])
-    self.assertEquals('chromedriver.test', credentials[0]['rpId'])
-    self.assertEquals(chr(1),
-                      self.UrlSafeBase64Decode(credentials[0]['userHandle']))
-    self.assertEquals(1, credentials[0]['signCount'])
-    self.assertTrue(credentials[0]['privateKey'])
-
 # Tests in the following class are expected to be moved to ChromeDriverTest
 # class when we no longer support the legacy mode.
 class ChromeDriverW3cTest(ChromeDriverBaseTestWithWebServer):
diff --git a/chrome/test/chromedriver/webauthn_commands.cc b/chrome/test/chromedriver/webauthn_commands.cc
index b0d4d62bc..32c8a4a61 100644
--- a/chrome/test/chromedriver/webauthn_commands.cc
+++ b/chrome/test/chromedriver/webauthn_commands.cc
@@ -6,8 +6,6 @@
 
 #include <utility>
 
-#include "base/base64.h"
-#include "base/base64url.h"
 #include "base/callback.h"
 #include "base/containers/flat_map.h"
 #include "base/values.h"
@@ -17,8 +15,6 @@
 
 namespace {
 
-static constexpr char kBase64UrlError[] = " must be a base64url encoded string";
-
 // Creates a base::DictionaryValue by cloning the parameters specified by
 // |mapping| from |params|.
 base::DictionaryValue MapParams(
@@ -33,48 +29,6 @@ base::DictionaryValue MapParams(
   return options;
 }
 
-// Converts the string |keys| in |params| from base64url to base64. Returns a
-// status error if conversion of one of the keys failed.
-Status ConvertBase64UrlToBase64(base::Value* params,
-                                const std::vector<const std::string> keys) {
-  for (const std::string key : keys) {
-    base::Value* maybe_value = params->FindKey(key);
-    if (!maybe_value)
-      continue;
-
-    if (!maybe_value->is_string())
-      return Status(kInvalidArgument, key + kBase64UrlError);
-
-    std::string& value = maybe_value->GetString();
-    std::string temp;
-    if (!Base64UrlDecode(value, base::Base64UrlDecodePolicy::IGNORE_PADDING,
-                         &temp)) {
-      return Status(kInvalidArgument, key + kBase64UrlError);
-    }
-
-    base::Base64Encode(temp, &value);
-  }
-
-  return Status(kOk);
-}
-
-// Converts the string |keys| in |params| from base64 to base64url.
-void ConvertBase64ToBase64Url(base::Value* params,
-                              const std::vector<const std::string> keys) {
-  for (const std::string key : keys) {
-    std::string* maybe_value = params->FindStringKey(key);
-    if (!maybe_value)
-      continue;
-
-    std::string temp;
-    bool result = base::Base64Decode(*maybe_value, &temp);
-    DCHECK(result);
-
-    base::Base64UrlEncode(temp, base::Base64UrlEncodePolicy::OMIT_PADDING,
-                          maybe_value);
-  }
-}
-
 }  // namespace
 
 Status ExecuteWebAuthnCommand(const WebAuthnCommand& command,
@@ -125,40 +79,18 @@ Status ExecuteRemoveVirtualAuthenticator(WebView* web_view,
 Status ExecuteAddCredential(WebView* web_view,
                             const base::Value& params,
                             std::unique_ptr<base::Value>* value) {
-  base::DictionaryValue mapped_params = MapParams(
-      {
-          {"authenticatorId", "authenticatorId"},
-          {"credential.credentialId", "credentialId"},
-          {"credential.isResidentCredential", "isResidentCredential"},
-          {"credential.rpId", "rpId"},
-          {"credential.privateKey", "privateKey"},
-          {"credential.userHandle", "userHandle"},
-          {"credential.signCount", "signCount"},
-      },
-      params);
-  Status status =
-      ConvertBase64UrlToBase64(mapped_params.FindKey("credential"),
-                               {"credentialId", "privateKey", "userHandle"});
-  if (status.IsError())
-    return status;
-
-  return web_view->SendCommandAndGetResult("WebAuthn.addCredential",
-                                           std::move(mapped_params), value);
-}
-
-Status ExecuteGetCredentials(WebView* web_view,
-                             const base::Value& params,
-                             std::unique_ptr<base::Value>* value) {
-  Status status = web_view->SendCommandAndGetResult(
-      "WebAuthn.getCredentials",
-      MapParams({{"authenticatorId", "authenticatorId"}}, params), value);
-  if (status.IsError())
-    return status;
-
-  for (base::Value& credential : (*value)->FindKey("credentials")->GetList()) {
-    ConvertBase64ToBase64Url(&credential,
-                             {"credentialId", "privateKey", "userHandle"});
-  }
-
-  return status;
+  return web_view->SendCommandAndGetResult(
+      "WebAuthn.addCredential",
+      MapParams(
+          {
+              {"authenticatorId", "authenticatorId"},
+              {"credential.credentialId", "credentialId"},
+              {"credential.isResidentCredential", "isResidentCredential"},
+              {"credential.rpId", "rpId"},
+              {"credential.privateKey", "privateKey"},
+              {"credential.userHandle", "userHandle"},
+              {"credential.signCount", "signCount"},
+          },
+          params),
+      value);
 }
diff --git a/chrome/test/chromedriver/webauthn_commands.h b/chrome/test/chromedriver/webauthn_commands.h
index dcc278428..fd75ecfed 100644
--- a/chrome/test/chromedriver/webauthn_commands.h
+++ b/chrome/test/chromedriver/webauthn_commands.h
@@ -44,9 +44,4 @@ Status ExecuteAddCredential(WebView* web_view,
                             const base::Value& params,
                             std::unique_ptr<base::Value>* value);
 
-// Retrieve all the credentials stored in an authenticator.
-Status ExecuteGetCredentials(WebView* web_view,
-                             const base::Value& params,
-                             std::unique_ptr<base::Value>* value);
-
 #endif  // CHROME_TEST_CHROMEDRIVER_WEBAUTHN_COMMANDS_H_
diff --git a/device/fido/virtual_ctap2_device.cc b/device/fido/virtual_ctap2_device.cc
index 672b61cb5..843bd0f4e 100644
--- a/device/fido/virtual_ctap2_device.cc
+++ b/device/fido/virtual_ctap2_device.cc
@@ -864,7 +864,6 @@ base::Optional<CtapDeviceResponseCode> VirtualCtap2Device::OnMakeCredential(
 
     registration.is_resident = true;
     registration.user = request.user;
-    registration.rp = request.rp;
   }
 
   if (request.cred_protect) {