]> git.codecow.com Git - libnemo.git/commitdiff
Explicitly assign buffers to enable explicit zeroing.
authorChris Duncan <chris@codecow.com>
Wed, 5 Aug 2026 08:42:05 +0000 (01:42 -0700)
committerChris Duncan <chris@codecow.com>
Wed, 5 Aug 2026 08:42:05 +0000 (01:42 -0700)
src/lib/crypto/wallet-aes-gcm.ts

index 069578c8abf58085bb406cb2a51bc86e348de8f4..1e951c80f2ca47adcc9ece98752c327e1cc0cd9d 100644 (file)
@@ -37,11 +37,16 @@ export class WalletAesGcm {
                // restrict iv to 96 bits per GCM best practice
                const iv = crypto.getRandomValues(new Uint8Array(12)).buffer
                const additionalData = utf8.toBuffer(`${type};${id}`)
-               const encoded = new Uint8Array([...new Uint8Array(seed), ...new Uint8Array(mnemonic ?? [])])
+               const s = new Uint8Array(seed)
+               const m = new Uint8Array(mnemonic ?? [])
+               const encoded = new Uint8Array([...s, ...m])
+               s.fill(0)
+               m.fill(0)
                return crypto.subtle
                        .encrypt({ name: 'AES-GCM', iv, additionalData }, key, encoded)
                        .then(encrypted => {
                                encoded.fill(0)
+                               key
                                return { iv, encrypted }
                        })
        }