diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/taler-util/package.json | 4 | ||||
-rw-r--r-- | packages/taler-util/src/argon2-impl.missing.ts | 10 | ||||
-rw-r--r-- | packages/taler-util/src/argon2-impl.node.ts | 19 | ||||
-rw-r--r-- | packages/taler-util/src/argon2.ts | 18 | ||||
-rw-r--r-- | packages/taler-util/src/taler-crypto.ts | 18 |
5 files changed, 59 insertions, 10 deletions
diff --git a/packages/taler-util/package.json b/packages/taler-util/package.json index 766163c48..b0bfbbaef 100644 --- a/packages/taler-util/package.json +++ b/packages/taler-util/package.json @@ -49,6 +49,10 @@ "node": "./lib/http-impl.node.js", "qtart": "./lib/http-impl.qtart.js", "default": "./lib/http-impl.missing.js" + }, + "#argon2-impl": { + "node": "./lib/argon2-impl.node.js", + "default": "/lib/argon2-impl.missing.js" } }, "scripts": { diff --git a/packages/taler-util/src/argon2-impl.missing.ts b/packages/taler-util/src/argon2-impl.missing.ts new file mode 100644 index 000000000..32a10fe5a --- /dev/null +++ b/packages/taler-util/src/argon2-impl.missing.ts @@ -0,0 +1,10 @@ + +export async function HashArgon2idImpl( + password: Uint8Array, + salt: Uint8Array, + iterations: number, + memorySize: number, + hashLength: number, +): Promise<Uint8Array> { + throw new Error("Method not implemented."); +} diff --git a/packages/taler-util/src/argon2-impl.node.ts b/packages/taler-util/src/argon2-impl.node.ts new file mode 100644 index 000000000..d1a36c4fe --- /dev/null +++ b/packages/taler-util/src/argon2-impl.node.ts @@ -0,0 +1,19 @@ +import { argon2id } from "hash-wasm"; + +export async function HashArgon2idImpl( + password: Uint8Array, + salt: Uint8Array, + iterations: number, + memorySize: number, + hashLength: number, +): Promise<Uint8Array> { + return await argon2id({ + password: password, + salt: salt, + iterations: iterations, + memorySize: memorySize, + hashLength: hashLength, + parallelism: 1, + outputType: "binary", + }); +} diff --git a/packages/taler-util/src/argon2.ts b/packages/taler-util/src/argon2.ts new file mode 100644 index 000000000..a2e04e53e --- /dev/null +++ b/packages/taler-util/src/argon2.ts @@ -0,0 +1,18 @@ +import * as impl from "#argon2-impl"; + +export async function hashArgon2id( + password: Uint8Array, + salt: Uint8Array, + iterations: number, + memorySize: number, + hashLength: number, +): Promise<Uint8Array> { + return await impl.HashArgon2idImpl( + password, + salt, + iterations, + memorySize, + hashLength, + ); +} + diff --git a/packages/taler-util/src/taler-crypto.ts b/packages/taler-util/src/taler-crypto.ts index cabe2b7d0..408b7e7c2 100644 --- a/packages/taler-util/src/taler-crypto.ts +++ b/packages/taler-util/src/taler-crypto.ts @@ -24,7 +24,7 @@ import * as nacl from "./nacl-fast.js"; import { hmacSha256, hmacSha512 } from "./kdf.js"; import bigint from "big-integer"; -import { argon2id } from "hash-wasm"; +import * as argon2 from "./argon2.js"; import { CoinEnvelope, CoinPublicKeyString, @@ -277,15 +277,13 @@ export async function hashArgon2id( hashLength, ); } - return await argon2id({ - password: password, - salt: salt, - iterations: iterations, - memorySize: memorySize, - hashLength: hashLength, - parallelism: 1, - outputType: "binary", - }); + return await argon2.hashArgon2id( + password, + salt, + iterations, + memorySize, + hashLength, + ); } export function eddsaGetPublic(eddsaPriv: Uint8Array): Uint8Array { |