1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-29 07:59:42 +01:00
bitwarden-browser/src/abstractions/crypto.service.ts

52 lines
3.1 KiB
TypeScript
Raw Normal View History

import { CipherArrayBuffer } from '../models/domain/cipherArrayBuffer';
import { CipherString } from '../models/domain/cipherString';
import { SymmetricCryptoKey } from '../models/domain/symmetricCryptoKey';
import { ProfileOrganizationResponse } from '../models/response/profileOrganizationResponse';
2018-08-14 21:12:10 +02:00
import { KdfType } from '../enums/kdfType';
2018-01-25 20:26:09 +01:00
export abstract class CryptoService {
setKey: (key: SymmetricCryptoKey) => Promise<any>;
setKeyHash: (keyHash: string) => Promise<{}>;
setEncKey: (encKey: string) => Promise<{}>;
setEncPrivateKey: (encPrivateKey: string) => Promise<{}>;
setOrgKeys: (orgs: ProfileOrganizationResponse[]) => Promise<{}>;
getKey: () => Promise<SymmetricCryptoKey>;
getKeyHash: () => Promise<string>;
2019-08-29 15:40:50 +02:00
getEncKey: (key?: SymmetricCryptoKey) => Promise<SymmetricCryptoKey>;
getPublicKey: () => Promise<ArrayBuffer>;
2018-01-25 20:26:09 +01:00
getPrivateKey: () => Promise<ArrayBuffer>;
getFingerprint: (userId: string, publicKey?: ArrayBuffer) => Promise<string[]>;
2018-01-25 20:26:09 +01:00
getOrgKeys: () => Promise<Map<string, SymmetricCryptoKey>>;
getOrgKey: (orgId: string) => Promise<SymmetricCryptoKey>;
2018-06-13 23:10:52 +02:00
hasKey: () => Promise<boolean>;
2018-07-12 23:07:06 +02:00
hasEncKey: () => Promise<boolean>;
2018-01-25 20:26:09 +01:00
clearKey: () => Promise<any>;
clearKeyHash: () => Promise<any>;
clearEncKey: (memoryOnly?: boolean) => Promise<any>;
2018-07-03 17:41:55 +02:00
clearKeyPair: (memoryOnly?: boolean) => Promise<any>;
2018-01-25 20:26:09 +01:00
clearOrgKeys: (memoryOnly?: boolean) => Promise<any>;
2019-02-13 05:52:50 +01:00
clearPinProtectedKey: () => Promise<any>;
2018-01-25 20:26:09 +01:00
clearKeys: () => Promise<any>;
toggleKey: () => Promise<any>;
2018-08-14 21:12:10 +02:00
makeKey: (password: string, salt: string, kdf: KdfType, kdfIterations: number) => Promise<SymmetricCryptoKey>;
2019-08-29 15:40:50 +02:00
makeKeyFromPin: (pin: string, salt: string, kdf: KdfType, kdfIterations: number,
protectedKeyCs?: CipherString) => Promise<SymmetricCryptoKey>;
makeShareKey: () => Promise<[CipherString, SymmetricCryptoKey]>;
2018-07-03 17:41:55 +02:00
makeKeyPair: (key?: SymmetricCryptoKey) => Promise<[string, CipherString]>;
makePinKey: (pin: string, salt: string, kdf: KdfType, kdfIterations: number) => Promise<SymmetricCryptoKey>;
makeSendKey: (keyMaterial: ArrayBuffer) => Promise<SymmetricCryptoKey>;
2018-01-25 20:26:09 +01:00
hashPassword: (password: string, key: SymmetricCryptoKey) => Promise<string>;
2018-07-03 17:41:55 +02:00
makeEncKey: (key: SymmetricCryptoKey) => Promise<[SymmetricCryptoKey, CipherString]>;
remakeEncKey: (key: SymmetricCryptoKey, encKey?: SymmetricCryptoKey) => Promise<[SymmetricCryptoKey, CipherString]>;
encrypt: (plainValue: string | ArrayBuffer, key?: SymmetricCryptoKey) => Promise<CipherString>;
encryptToBytes: (plainValue: ArrayBuffer, key?: SymmetricCryptoKey) => Promise<CipherArrayBuffer>;
rsaEncrypt: (data: ArrayBuffer, publicKey?: ArrayBuffer) => Promise<CipherString>;
rsaDecrypt: (encValue: string) => Promise<ArrayBuffer>;
2018-09-10 18:13:30 +02:00
decryptToBytes: (cipherString: CipherString, key?: SymmetricCryptoKey) => Promise<ArrayBuffer>;
decryptToUtf8: (cipherString: CipherString, key?: SymmetricCryptoKey) => Promise<string>;
2018-01-25 20:26:09 +01:00
decryptFromBytes: (encBuf: ArrayBuffer, key: SymmetricCryptoKey) => Promise<ArrayBuffer>;
2018-04-23 19:03:47 +02:00
randomNumber: (min: number, max: number) => Promise<number>;
}