Skip to content

Commit

Permalink
perf(encryption): update encryption method to AES-GCM
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert27 committed Oct 18, 2024
1 parent 1c639d5 commit b0eba35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rogue-thi-app/lib/credential-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ export default class CredentialStorage {
async write(id, data) {
const key = await crypto.subtle.generateKey(
{
name: 'AES-CBC',
name: 'AES-GCM',
length: 256,
},
false,
['encrypt', 'decrypt']
)
const iv = crypto.getRandomValues(new Uint8Array(16))
const iv = crypto.getRandomValues(new Uint8Array(12)) // AES-GCM typically uses a 12-byte IV

const encrypted = await crypto.subtle.encrypt(
{
name: 'AES-CBC',
name: 'AES-GCM',
iv,
},
key,
Expand Down Expand Up @@ -94,7 +94,7 @@ export default class CredentialStorage {

const decrypted = await crypto.subtle.decrypt(
{
name: 'AES-CBC',
name: 'AES-GCM',
iv,
},
key,
Expand All @@ -119,4 +119,4 @@ export default class CredentialStorage {
db.close()
}
}
}
}

0 comments on commit b0eba35

Please sign in to comment.