From: Chris Duncan Date: Sun, 9 Aug 2026 18:58:34 +0000 (-0700) Subject: Refactor secret buffers to enable proper zeroing. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=b6d95042c4419d2784bfb9b6dc3dfc3108e050e7;p=libnemo.git Refactor secret buffers to enable proper zeroing. --- diff --git a/src/lib/vault/vault-worker.ts b/src/lib/vault/vault-worker.ts index cce4181..4364f48 100644 --- a/src/lib/vault/vault-worker.ts +++ b/src/lib/vault/vault-worker.ts @@ -188,12 +188,18 @@ function derive (index?: number | Uint32Array): Promise { - const prv = new Uint8Array(result) - const pub = nano25519_derive(prv) - prv.fill(0) - return { index: i, publicKey: pub.buffer } - })) + const prv = new Uint8Array(32) + promises.push(_ckd(i) + .then(result => { + prv.set(result) + result.fill(0) + const pub = nano25519_derive(prv) + return { index: i, publicKey: pub.buffer } + }) + .finally(() => { + prv.fill(0) + }) + ) } return Promise.all(promises) .then(results => { @@ -269,10 +275,11 @@ function sign (index?: Uint32Array, data?: ArrayBuffer): Promise { - const prv = new Uint8Array(result) + prv.set(result) + result.fill(0) const pub = nano25519_derive(prv) const sk = new Uint8Array([...prv, ...pub]) prv.fill(0) @@ -287,6 +294,9 @@ function sign (index?: Uint32Array, data?: ArrayBuffer): Promise { + prv.fill(0) + }) } catch (err) { console.error(err) _timer.resume()