fmt
This commit is contained in:
+8
-4
@@ -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<Uint8Array | null> {
|
||||
export async function pbkdf(
|
||||
salt: Uint8Array,
|
||||
password: string,
|
||||
strength: Strength = Strength.moderate
|
||||
): Promise<Uint8Array | null> {
|
||||
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
|
||||
|
||||
+7
-1
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user