Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33037151
D8118.1768410450.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D8118.1768410450.diff
View Options
diff --git a/web/database/utils/worker-crypto-utils.js b/web/database/utils/worker-crypto-utils.js
--- a/web/database/utils/worker-crypto-utils.js
+++ b/web/database/utils/worker-crypto-utils.js
@@ -7,13 +7,17 @@
+ciphertext: Uint8Array,
};
-function generateDatabaseCryptoKey(): Promise<CryptoKey> {
+function generateDatabaseCryptoKey({
+ extractable,
+}: {
+ +extractable: boolean,
+}): Promise<CryptoKey> {
return crypto.subtle.generateKey(
{
name: ENCRYPTION_ALGORITHM,
length: 256,
},
- false,
+ extractable,
['encrypt', 'decrypt'],
);
}
diff --git a/web/database/utils/worker-crypto-utlis.test.js b/web/database/utils/worker-crypto-utlis.test.js
--- a/web/database/utils/worker-crypto-utlis.test.js
+++ b/web/database/utils/worker-crypto-utlis.test.js
@@ -36,7 +36,7 @@
database = new SQL.Database();
setUpMockDb(database);
- cryptoKey = await generateDatabaseCryptoKey();
+ cryptoKey = await generateDatabaseCryptoKey({ extractable: false });
});
it('should encrypt database content', async () => {
@@ -57,7 +57,9 @@
const dbContent: Uint8Array = database.export();
const encryptedData = await encryptDatabaseFile(dbContent, cryptoKey);
- const newCryptoKey = await generateDatabaseCryptoKey();
+ const newCryptoKey = await generateDatabaseCryptoKey({
+ extractable: false,
+ });
expect(decryptDatabaseFile(encryptedData, newCryptoKey)).rejects.toThrow();
});
diff --git a/web/database/worker/db-worker.js b/web/database/worker/db-worker.js
--- a/web/database/worker/db-worker.js
+++ b/web/database/worker/db-worker.js
@@ -61,7 +61,7 @@
async function initDatabase(sqljsFilePath: string, sqljsFilename: ?string) {
encryptionKey = await localforage.getItem(SQLITE_ENCRYPTION_KEY);
if (!encryptionKey) {
- const cryptoKey = await generateDatabaseCryptoKey();
+ const cryptoKey = await generateDatabaseCryptoKey({ extractable: false });
await localforage.setItem(SQLITE_ENCRYPTION_KEY, cryptoKey);
}
@@ -191,7 +191,7 @@
} else if (
message.type === workerRequestMessageTypes.GENERATE_DATABASE_ENCRYPTION_KEY
) {
- const cryptoKey = await generateDatabaseCryptoKey();
+ const cryptoKey = await generateDatabaseCryptoKey({ extractable: false });
await localforage.setItem(SQLITE_ENCRYPTION_KEY, cryptoKey);
return undefined;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 14, 5:07 PM (10 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5933030
Default Alt Text
D8118.1768410450.diff (2 KB)
Attached To
Mode
D8118: [web-db] add `extractable` param while creating crypto key
Attached
Detach File
Event Timeline
Log In to Comment