From dc9f9337b32aacbada8c36ef56ca158e8830a931 Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sun, 10 Mar 2024 12:06:45 +0800 Subject: [PATCH] refine PBKDF2 params --- src/mod.ts | 5 ++++- src/pbkdf2.ts | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mod.ts b/src/mod.ts index 4fa528c..82acc9e 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -30,7 +30,10 @@ export async function main ([ throw new Error('invalid salt, at least 5 characters long'); } - const entropy = await PBKDF2(encode(salt), encode(passphrase)); + const entropy = await PBKDF2({ + salt: encode(salt), + passphrase: encode(passphrase), + }); return ssh(new Uint8Array(entropy)); diff --git a/src/pbkdf2.ts b/src/pbkdf2.ts index e98285f..7de2d78 100644 --- a/src/pbkdf2.ts +++ b/src/pbkdf2.ts @@ -4,12 +4,14 @@ import { webcrypto } from './utils.ts'; -export async function PBKDF2 ( +export async function PBKDF2 (opts: { salt: BufferSource, passphrase: BufferSource, -): Promise { +}): Promise { + + const { salt, passphrase } = opts; const name = 'PBKDF2'; const byte = 32;