mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
update makeKeyPair on crypto service to be generic
This commit is contained in:
@@ -59,7 +59,7 @@ export abstract class CryptoService {
|
||||
setPrivateKey: (encPrivateKey: string) => Promise<void>;
|
||||
getPrivateKey: () => Promise<ArrayBuffer>;
|
||||
getFingerprint: (fingerprintMaterial: string, publicKey?: ArrayBuffer) => Promise<string[]>;
|
||||
makeKeyPair: (key?: UserSymKey) => Promise<[string, EncString]>;
|
||||
makeKeyPair: (key?: SymmetricCryptoKey) => Promise<[string, EncString]>;
|
||||
clearKeyPair: (memoryOnly?: boolean, userId?: string) => Promise<void[]>;
|
||||
makePinKey: (pin: string, salt: string, kdf: KdfType, kdfConfig: KdfConfig) => Promise<PinKey>;
|
||||
clearPinProtectedKey: () => Promise<void>;
|
||||
|
||||
@@ -613,11 +613,14 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new keypair for the user
|
||||
* @param key The user's symmetric key
|
||||
* @returns A new keypair: [publicKey in Base64, protected privateKey]
|
||||
* Generates a new keypair
|
||||
* @param key A key to encrypt the private key with. If not provided,
|
||||
* defaults to the user's symmetric key
|
||||
* @returns A new keypair: [publicKey in Base64, encrypted privateKey]
|
||||
*/
|
||||
async makeKeyPair(key?: UserSymKey): Promise<[string, EncString]> {
|
||||
async makeKeyPair(key?: SymmetricCryptoKey): Promise<[string, EncString]> {
|
||||
key ||= await this.getUserKey();
|
||||
|
||||
const keyPair = await this.cryptoFunctionService.rsaGenerateKeyPair(2048);
|
||||
const publicB64 = Utils.fromBufferToB64(keyPair[0]);
|
||||
const privateEnc = await this.encrypt(keyPair[1], key);
|
||||
|
||||
Reference in New Issue
Block a user