Skip to content

Commit

Permalink
[PM-4925] Implemented getPublicKey to follow WSC standards (#6934)
Browse files Browse the repository at this point in the history
* Implemented getPublicKey to follow WSC standards

* Renamed variable
  • Loading branch information
gbubemismith authored Nov 27, 2023
1 parent 75e1486 commit 301142f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/browser/src/vault/fido2/webauthn-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class WebauthnUtils {
},

getPublicKey(): ArrayBuffer {
return null;
return Fido2Utils.stringToBuffer(result.publicKey);
},

getPublicKeyAlgorithm(): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface Fido2AuthenticatorMakeCredentialResult {
credentialId: BufferSource;
attestationObject: BufferSource;
authData: BufferSource;
publicKey: BufferSource;
publicKeyAlgorithm: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface CreateCredentialResult {
clientDataJSON: string;
attestationObject: string;
authData: string;
publicKey: string;
publicKeyAlgorithm: number;
transports: string[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -174,6 +175,7 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
credentialId: guidToRawFormat(credentialId),
attestationObject,
authData,
publicKey: pubKeyDer,
publicKeyAlgorithm: -7,
};
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ describe("FidoAuthenticatorService", () => {
credentialId: guidToRawFormat(Utils.newGuid()),
attestationObject: randomBytes(128),
authData: randomBytes(64),
publicKey: randomBytes(64),
publicKeyAlgorithm: -7,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
};
Expand Down

0 comments on commit 301142f

Please sign in to comment.