]> git.ardis.lu - static-encrypt-passkey/commitdiff
Wrap prf output in Uint8Array main
authorArdis Lu <ardisglu@gmail.com>
Sun, 19 Jul 2026 06:25:59 +0000 (23:25 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 19 Jul 2026 06:25:59 +0000 (23:25 -0700)
Non-standard passkey implementations (e.g., 1Password) return `Array` instead of `BufferSource`.

index.html
script.js

index b6c3b4b6f614a10d605183626767a42dd68aa87b..fa592dc20c5e0128f5464cfdc8e5594b8f09278b 100644 (file)
@@ -12,7 +12,7 @@
   <link rel="canonical" href="https://108117.xyz/">
   <link rel="icon" href="data:,">
   <link rel="stylesheet" href="./style.css">
-  <link rel="modulepreload" href="./script.js" integrity="sha512-Lkb5w3ts0GdkX4MFDhtyGZFN8o4PtN1u+jq0tX4XqCCN/sV+ddnsro9zNQ12vt6fSBS6NJUPUCxwqiIpNgSAMA==">
+  <link rel="modulepreload" href="./script.js" integrity="sha512-sHPFqLYMufpPGU53gpoPM2s55ijr6QaxHj9GApSkciPYW6FyvTRHNESHEbrlRrJCMABcxrXmNukGtn89h2H/Iw==">
   <title>static-encrypt-passkey</title>
 </head>
 
index 093f5d6d1f16c81a4c3b604b04019ca93fe47c28..29850fb4570f6e94799c4943814f30a832c3b43b 100644 (file)
--- a/script.js
+++ b/script.js
@@ -93,7 +93,9 @@ export async function encrypt(plaintext) {
   paddedPlaintext.set([p]); // Offset to discard on decode
   paddedPlaintext.set(encodedPlaintext, p); // Gap filled with zero bytes, e.g. [3, 0, 0, ...encodedPlaintext]
 
-  const prf = await createPrf();
+  // As per the specification, the PRF extension *should* already return a BufferSource which can be directly
+  // passed to Web Crypto API, however non-standard passkey implementations (e.g., 1Password) return Array.
+  const prf = new Uint8Array(await createPrf());
   const key = await getKey(prf, salt, info);
   const ciphertext = new Uint8Array(await crypto.subtle.encrypt(
     { name: 'AES-GCM', iv },
@@ -126,7 +128,9 @@ export async function decrypt(content) {
   // Prepare non-crypto inputs
   const info = new TextEncoder().encode('https://github.com/ardislu/static-encrypt-passkey');
 
-  const prf = await getPrf();
+  // As per the specification, the PRF extension *should* already return a BufferSource which can be directly
+  // passed to Web Crypto API, however non-standard passkey implementations (e.g., 1Password) return Array.
+  const prf = new Uint8Array(await getPrf());
   const key = await getKey(prf, salt, info);
   const encodedPlaintext = new Uint8Array(await crypto.subtle.decrypt(
     { name: 'AES-GCM', iv },
This page took 0.033352 seconds and 4 git commands to generate.