diff --git a/src/kdf.ts b/src/kdf.ts index d41550a..10b9440 100644 --- a/src/kdf.ts +++ b/src/kdf.ts @@ -89,7 +89,11 @@ export async function hkdf(key: Uint8Array, usage: Usage, context?: string): Pro } /** Minimum salt size : 16 bytes */ -export async function pbkdf(salt: Uint8Array, password: string, strength: Strength = Strength.moderate): Promise { +export async function pbkdf( + salt: Uint8Array, + password: string, + strength: Strength = Strength.moderate +): Promise { log.trace('PBKDF') if (salt.length < 16) { @@ -106,13 +110,13 @@ export async function pbkdf(salt: Uint8Array, password: string, strength: Streng switch (strength) { case Strength.weak: iterations = 100_000 - break; + break case Strength.moderate: iterations = 250_000 - break; + break case Strength.strong: iterations = 500_000 - break; + break default: log.warn('Invalid strength used !') return null diff --git a/test/kdf.test.ts b/test/kdf.test.ts index fb72019..d734c7b 100644 --- a/test/kdf.test.ts +++ b/test/kdf.test.ts @@ -1,7 +1,13 @@ import {describe, expect, test} from 'bun:test' import {kdf, PrivateWrap, SecretBox, SecretWrap} from '..' -async function test_keys(k1: CryptoKey, k2: CryptoKey, usage: kdf.Usage | kdf.DHusage, should_box: boolean, should_unbox: boolean) { +async function test_keys( + k1: CryptoKey, + k2: CryptoKey, + usage: kdf.Usage | kdf.DHusage, + should_box: boolean, + should_unbox: boolean +) { if (usage === kdf.Usage.wrap || usage == kdf.DHusage.wrap) { const payload = await SecretBox.gen(true)