Commit 546a02b0 authored by Nina Satragno's avatar Nina Satragno Committed by Commit Bot

[testdriver] Binary values should be base64url

On testdriver virtual authenticator tests, binary values were being
encoded as base64 instead of base64url. This didn't blow anything up
because the test values happened to have the same representation in
both, but is still a bug.

Bug: 1141104
Change-Id: I6edd7fdfd4ab0f9ae1d196d8f2e14ed2bd9e334d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490230
Commit-Queue: Nina Satragno <nsatragno@chromium.org>
Auto-Submit: Nina Satragno <nsatragno@chromium.org>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819523}
parent d6006e1b
...@@ -8,6 +8,13 @@ ...@@ -8,6 +8,13 @@
<script> <script>
"use strict"; "use strict";
// Encodes |data| into a base64url string. There is no '=' padding, and the
// characters '-' and '_' must be used instead of '+' and '/', respectively.
function base64urlEncode(data) {
let result = btoa(data);
return result.replaceAll("=", "").replaceAll("+", "-").replaceAll("/", "_");
}
// The example attestation private key from the U2F spec at // 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 // 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. // PKCS.8 encoded without encryption, as a base64url string.
...@@ -15,7 +22,7 @@ const private_key = ...@@ -15,7 +22,7 @@ const private_key =
"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Q" "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Q"
+ "hk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwU" + "hk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwU"
+ "RmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB"; + "RmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB";
let credential_id = btoa("cred-1"); let credential_id = base64urlEncode("cred-1");
let credential = { let credential = {
credentialId: credential_id, credentialId: credential_id,
rpId: window.location.hostname, rpId: window.location.hostname,
...@@ -58,7 +65,7 @@ promise_test(async t => { ...@@ -58,7 +65,7 @@ promise_test(async t => {
promise_test(async t => { promise_test(async t => {
let credential1 = credential; let credential1 = credential;
let credential2 = let credential2 =
Object.assign({}, credential, {credentialId: btoa("cred-2")}); Object.assign({}, credential, {credentialId: base64urlEncode("cred-2")});
await test_driver.add_credential(authenticator_id, credential1); await test_driver.add_credential(authenticator_id, credential1);
await test_driver.add_credential(authenticator_id, credential2); await test_driver.add_credential(authenticator_id, credential2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment