mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
* Change everything to Uint8Array related to https://github.com/jestjs/jest/issues/14379 * Work on failing type tests * Revert changes to custom matcher setup * Remove last BufferArrays from tests * Fix custom matcher type errors in vscode * Remove errant `.buffer` calls on Uint8Arrays * Encryption Pair should serialize Array Buffer and Uint8Array * Fix EncArrayBuffer encryption --------- Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { CsprngArray } from "../../types/csprng";
|
|
import { DecryptParameters } from "../models/domain/decrypt-parameters";
|
|
import { SymmetricCryptoKey } from "../models/domain/symmetric-crypto-key";
|
|
|
|
export abstract class CryptoFunctionService {
|
|
pbkdf2: (
|
|
password: string | Uint8Array,
|
|
salt: string | Uint8Array,
|
|
algorithm: "sha256" | "sha512",
|
|
iterations: number
|
|
) => Promise<Uint8Array>;
|
|
argon2: (
|
|
password: string | Uint8Array,
|
|
salt: string | Uint8Array,
|
|
iterations: number,
|
|
memory: number,
|
|
parallelism: number
|
|
) => Promise<Uint8Array>;
|
|
hkdf: (
|
|
ikm: Uint8Array,
|
|
salt: string | Uint8Array,
|
|
info: string | Uint8Array,
|
|
outputByteSize: number,
|
|
algorithm: "sha256" | "sha512"
|
|
) => Promise<Uint8Array>;
|
|
hkdfExpand: (
|
|
prk: Uint8Array,
|
|
info: string | Uint8Array,
|
|
outputByteSize: number,
|
|
algorithm: "sha256" | "sha512"
|
|
) => Promise<Uint8Array>;
|
|
hash: (
|
|
value: string | Uint8Array,
|
|
algorithm: "sha1" | "sha256" | "sha512" | "md5"
|
|
) => Promise<Uint8Array>;
|
|
hmac: (
|
|
value: Uint8Array,
|
|
key: Uint8Array,
|
|
algorithm: "sha1" | "sha256" | "sha512"
|
|
) => Promise<Uint8Array>;
|
|
compare: (a: Uint8Array, b: Uint8Array) => Promise<boolean>;
|
|
hmacFast: (
|
|
value: Uint8Array | string,
|
|
key: Uint8Array | string,
|
|
algorithm: "sha1" | "sha256" | "sha512"
|
|
) => Promise<Uint8Array | string>;
|
|
compareFast: (a: Uint8Array | string, b: Uint8Array | string) => Promise<boolean>;
|
|
aesEncrypt: (data: Uint8Array, iv: Uint8Array, key: Uint8Array) => Promise<Uint8Array>;
|
|
aesDecryptFastParameters: (
|
|
data: string,
|
|
iv: string,
|
|
mac: string,
|
|
key: SymmetricCryptoKey
|
|
) => DecryptParameters<Uint8Array | string>;
|
|
aesDecryptFast: (parameters: DecryptParameters<Uint8Array | string>) => Promise<string>;
|
|
aesDecrypt: (data: Uint8Array, iv: Uint8Array, key: Uint8Array) => Promise<Uint8Array>;
|
|
rsaEncrypt: (
|
|
data: Uint8Array,
|
|
publicKey: Uint8Array,
|
|
algorithm: "sha1" | "sha256"
|
|
) => Promise<Uint8Array>;
|
|
rsaDecrypt: (
|
|
data: Uint8Array,
|
|
privateKey: Uint8Array,
|
|
algorithm: "sha1" | "sha256"
|
|
) => Promise<Uint8Array>;
|
|
rsaExtractPublicKey: (privateKey: Uint8Array) => Promise<Uint8Array>;
|
|
rsaGenerateKeyPair: (length: 1024 | 2048 | 4096) => Promise<[Uint8Array, Uint8Array]>;
|
|
randomBytes: (length: number) => Promise<CsprngArray>;
|
|
}
|