From f558a35d3d4ae99973d5633efe7b3cc26070c134 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Wed, 4 Jan 2023 15:55:52 -0600 Subject: [PATCH] padding? --- internal/server/static/webauthn.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/internal/server/static/webauthn.js b/internal/server/static/webauthn.js index 82b4c3e..11aafea 100644 --- a/internal/server/static/webauthn.js +++ b/internal/server/static/webauthn.js @@ -66,12 +66,13 @@ async function register(challenge) { console.dir(parsed) console.info("webauthn: issuing credential creation request to browser") - let credential - try { - credential = await webauthnJSON.create(parsed); - } catch (err) { - console.error("sigh", err) - throw err + let credential = await webauthnJSON.create(parsed); + let missing = 4 - (credential.response.clientDataJSON.length % 4) + if (missing != 0) { + while (missing > 0) { + credential.response.clientDataJSON += "=" + missing -= 1 + } } console.debug(`webauthn: registering credentials with server: ${JSON.stringify(credential)}`) @@ -108,6 +109,13 @@ async function login(challenge, target, config) { console.debug("webauthn: fetching stored client credentials") let credential = await webauthnJSON.get(parsed); + let missing = 4 - (credential.response.clientDataJSON.length % 4) + if (missing != 0) { + while (missing > 0) { + credential.response.clientDataJSON += "=" + missing -= 1 + } + } config.credentials = "include" config.headers = config.headers || {}