From b8c9ca88ca8cb0b71dcd96e8d880499c422f0f1e Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Wed, 25 Nov 2020 14:06:54 +0100 Subject: [PATCH] fix: alter argon2 config, use more memory, closes #363 --- app/crypto/key-generation.spec.ts | 56 +++---------------------------- app/crypto/key-generation.ts | 3 +- 2 files changed, 7 insertions(+), 52 deletions(-) diff --git a/app/crypto/key-generation.spec.ts b/app/crypto/key-generation.spec.ts index c6e67ffa4..0ca954934 100644 --- a/app/crypto/key-generation.spec.ts +++ b/app/crypto/key-generation.spec.ts @@ -14,57 +14,11 @@ describe(deriveKey.name, () => { const salt = '$2a$12$BwnByfKrfRbpxsazN712T.'; const pass = 'f255cadb0af84854819c63f26c53e1a9'; const { derivedKeyHash } = await deriveKey({ salt, pass }); - const expectedResultArray = [ - 94, - 0, - 166, - 167, - 20, - 189, - 146, - 233, - 48, - 163, - 248, - 178, - 48, - 11, - 140, - 87, - 82, - 126, - 73, - 82, - 237, - 166, - 232, - 173, - 90, - 192, - 67, - 200, - 149, - 147, - 30, - 223, - 60, - 15, - 133, - 99, - 89, - 142, - 223, - 116, - 131, - 24, - 169, - 157, - 157, - 245, - 159, - 140, - ]; - expect(derivedKeyHash).toEqual(Uint8Array.from(expectedResultArray)); + const hash = Buffer.from(derivedKeyHash).toString('hex'); + console.log(hash); + expect(hash).toEqual( + 'd941c6ec3f04fa67c68b497169986588436b1697aa6b3a93218152658e5c494d2e3da9ea93522f0e4cb14b414b57b463' + ); }); }); diff --git a/app/crypto/key-generation.ts b/app/crypto/key-generation.ts index e2d9699b0..2adbdcb3e 100644 --- a/app/crypto/key-generation.ts +++ b/app/crypto/key-generation.ts @@ -6,7 +6,8 @@ export async function deriveKey({ pass, salt }: { pass: string; salt: string }) pass, salt, hashLen: 48, - time: 400, + time: 44, + mem: 1024 * 32, type: ArgonType.Argon2id, }); return { derivedKeyHash: result.hash };