]> git.codecow.com Git - libnemo.git/commitdiff
Generate encryption key once per safe storage request.
authorChris Duncan <chris@zoso.dev>
Thu, 17 Jul 2025 21:43:59 +0000 (14:43 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 17 Jul 2025 21:43:59 +0000 (14:43 -0700)
src/lib/workers/safe.ts

index 6543a1948fbb0b52352890395a71918183a123b2..bcc8c63f6ef6422317cf36d9fa822a3051bdece3 100644 (file)
@@ -76,9 +76,9 @@ export class Safe extends WorkerInterface {
 
                try {
                        const records: SafeRecord[] = []
+                       const salt = await Entropy.create()
+                       const encryptionKey = await Safe.#createAesKey('encrypt', password, salt.buffer)
                        for (const label of Object.keys(data)) {
-                               const salt = await Entropy.create()
-                               const encryptionKey = await Safe.#createAesKey('encrypt', password, salt.buffer)
                                const iv = await Entropy.create()
                                const encrypted = await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv: iv.buffer }, encryptionKey, data[label])
                                const record: SafeRecord = {