1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-25 12:15:18 +01:00

[PM-4925] Implemented getPublicKey to follow WSC standards (#6934)

* Implemented getPublicKey to follow WSC standards

* Renamed variable
This commit is contained in:
SmithThe4th 2023-11-27 11:02:38 -05:00 committed by GitHub
parent 75e1486c18
commit 301142fbf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 2 deletions

View File

@ -67,7 +67,7 @@ export class WebauthnUtils {
},
getPublicKey(): ArrayBuffer {
return null;
return Fido2Utils.stringToBuffer(result.publicKey);
},
getPublicKeyAlgorithm(): number {

View File

@ -109,6 +109,7 @@ export interface Fido2AuthenticatorMakeCredentialResult {
credentialId: BufferSource;
attestationObject: BufferSource;
authData: BufferSource;
publicKey: BufferSource;
publicKeyAlgorithm: number;
}

View File

@ -122,6 +122,7 @@ export interface CreateCredentialResult {
clientDataJSON: string;
attestationObject: string;
authData: string;
publicKey: string;
publicKeyAlgorithm: number;
transports: string[];
}

View File

@ -109,6 +109,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
let keyPair: CryptoKeyPair;
let userVerified = false;
let credentialId: string;
let pubKeyDer: ArrayBuffer;
const response = await userInterfaceSession.confirmNewCredential({
credentialName: params.rpEntity.name,
userName: params.userEntity.displayName,
@ -126,7 +127,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
try {
keyPair = await createKeyPair();
pubKeyDer = await crypto.subtle.exportKey("spki", keyPair.publicKey);
const encrypted = await this.cipherService.get(cipherId);
cipher = await encrypted.decrypt(
await this.cipherService.getKeyForCipherKeyDecryption(encrypted)
@ -174,6 +175,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
credentialId: guidToRawFormat(credentialId),
attestationObject,
authData,
publicKey: pubKeyDer,
publicKeyAlgorithm: -7,
};
} finally {

View File

@ -285,6 +285,7 @@ describe("FidoAuthenticatorService", () => {
credentialId: guidToRawFormat(Utils.newGuid()),
attestationObject: randomBytes(128),
authData: randomBytes(64),
publicKey: randomBytes(64),
publicKeyAlgorithm: -7,
};
}

View File

@ -199,6 +199,7 @@ export class Fido2ClientService implements Fido2ClientServiceAbstraction {
attestationObject: Fido2Utils.bufferToString(makeCredentialResult.attestationObject),
authData: Fido2Utils.bufferToString(makeCredentialResult.authData),
clientDataJSON: Fido2Utils.bufferToString(clientDataJSONBytes),
publicKey: Fido2Utils.bufferToString(makeCredentialResult.publicKey),
publicKeyAlgorithm: makeCredentialResult.publicKeyAlgorithm,
transports: params.rp.id === "google.com" ? ["internal", "usb"] : ["internal"],
};