mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
Use constant type
This commit is contained in:
parent
a945edfe07
commit
0e18247184
@ -9,7 +9,7 @@
|
|||||||
import type {Crypto} from "../../platform/web/dom/Crypto.js";
|
import type {Crypto} from "../../platform/web/dom/Crypto.js";
|
||||||
|
|
||||||
// forked this code to make it use the cryptoDriver for HMAC that is more backwards-compatible
|
// forked this code to make it use the cryptoDriver for HMAC that is more backwards-compatible
|
||||||
export async function hkdf(cryptoDriver: Crypto, key: Uint8Array, salt: Uint8Array, info: Uint8Array, hash: string, length: number): Promise<Uint8Array> {
|
export async function hkdf(cryptoDriver: Crypto, key: Uint8Array, salt: Uint8Array, info: Uint8Array, hash: "SHA-256" | "SHA-512", length: number): Promise<Uint8Array> {
|
||||||
length = length / 8;
|
length = length / 8;
|
||||||
const len = cryptoDriver.digestSize(hash);
|
const len = cryptoDriver.digestSize(hash);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ const nwbo = (num: number, len: number): Uint8Array => {
|
|||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function pbkdf2(cryptoDriver: Crypto, password: Uint8Array, iterations: number, salt: Uint8Array, hash: string, length: number): Promise<Uint8Array> {
|
export async function pbkdf2(cryptoDriver: Crypto, password: Uint8Array, iterations: number, salt: Uint8Array, hash: "SHA-256" | "SHA-512", length: number): Promise<Uint8Array> {
|
||||||
const dkLen = length / 8;
|
const dkLen = length / 8;
|
||||||
if (iterations <= 0) {
|
if (iterations <= 0) {
|
||||||
throw new Error('InvalidIterationCount');
|
throw new Error('InvalidIterationCount');
|
||||||
|
Loading…
Reference in New Issue
Block a user