1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-31 22:51:28 +01:00

[EC-598] feat: tweak key data to contain separate type and algorithm

This commit is contained in:
Andreas Coroiu 2023-03-27 09:45:18 +02:00
parent 800f032e92
commit ad27234576
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
6 changed files with 39 additions and 17 deletions

View File

@ -1,12 +1,15 @@
import { BaseResponse } from "../../../models/response/base.response";
export class Fido2KeyApi extends BaseResponse {
keyType: "ECDSA";
keyType: "public-key";
keyAlgorithm: "ECDSA";
keyCurve: "P-256";
keyValue: string;
rpId: string;
rpName: string;
userHandle: string;
// Extras
rpName: string;
userName: string;
origin: string;
@ -17,12 +20,13 @@ export class Fido2KeyApi extends BaseResponse {
}
this.keyType = this.getResponseProperty("KeyType");
this.keyAlgorithm = this.getResponseProperty("KeyType");
this.keyCurve = this.getResponseProperty("KeyCurve");
this.keyValue = this.getResponseProperty("keyValue");
this.rpId = this.getResponseProperty("RpId");
this.rpName = this.getResponseProperty("RpName");
this.userHandle = this.getResponseProperty("UserHandle");
this.userName = this.getResponseProperty("UserName");
this.userHandle = this.getResponseProperty("UserHandle");
this.origin = this.getResponseProperty("Origin");
}
}

View File

@ -1,12 +1,15 @@
import { Fido2KeyApi } from "../api/fido2-key.api";
export class Fido2KeyData {
keyType: "ECDSA";
keyType: "public-key";
keyAlgorithm: "ECDSA";
keyCurve: "P-256";
keyValue: string;
rpId: string;
rpName: string;
userHandle: string;
// Extras
rpName: string;
userName: string;
origin: string;
@ -16,11 +19,12 @@ export class Fido2KeyData {
}
this.keyType = data.keyType;
this.keyAlgorithm = data.keyAlgorithm;
this.keyCurve = data.keyCurve;
this.keyValue = data.keyValue;
this.rpId = data.rpId;
this.rpName = data.rpName;
this.userHandle = data.userHandle;
this.rpName = data.rpName;
this.userName = data.userName;
this.origin = data.origin;
}

View File

@ -8,11 +8,14 @@ import { Fido2KeyView } from "../view/fido2-key.view";
export class Fido2Key extends Domain {
keyType: EncString;
keyAlgorithm: EncString;
keyCurve: EncString;
keyValue: EncString;
rpId: EncString;
rpName: EncString;
userHandle: EncString;
// Extras
rpName: EncString;
userName: EncString;
origin: EncString;
@ -27,11 +30,12 @@ export class Fido2Key extends Domain {
obj,
{
keyType: null,
keyAlgorithm: null,
keyCurve: null,
keyValue: null,
rpId: null,
rpName: null,
userHandle: null,
rpName: null,
userName: null,
origin: null,
},
@ -44,11 +48,12 @@ export class Fido2Key extends Domain {
new Fido2KeyView(),
{
keyType: null,
keyAlgorithm: null,
keyCurve: null,
keyValue: null,
rpId: null,
rpName: null,
userHandle: null,
rpName: null,
userName: null,
origin: null,
},
@ -61,11 +66,12 @@ export class Fido2Key extends Domain {
const i = new Fido2KeyData();
this.buildDataModel(this, i, {
keyType: null,
keyAlgorithm: null,
keyCurve: null,
keyValue: null,
rpId: null,
rpName: null,
userHandle: null,
rpName: null,
userName: null,
origin: null,
});
@ -78,21 +84,23 @@ export class Fido2Key extends Domain {
}
const keyType = EncString.fromJSON(obj.keyType);
const keyAlgorithm = EncString.fromJSON(obj.keyAlgorithm);
const keyCurve = EncString.fromJSON(obj.keyCurve);
const keyValue = EncString.fromJSON(obj.keyValue);
const rpId = EncString.fromJSON(obj.rpId);
const rpName = EncString.fromJSON(obj.rpName);
const userHandle = EncString.fromJSON(obj.userHandle);
const rpName = EncString.fromJSON(obj.rpName);
const userName = EncString.fromJSON(obj.userName);
const origin = EncString.fromJSON(obj.origin);
return Object.assign(new Fido2Key(), obj, {
keyType,
keyAlgorithm,
keyCurve,
keyValue,
rpId,
rpName,
userHandle,
rpName,
userName,
origin,
});

View File

@ -3,12 +3,15 @@ import { Jsonify } from "type-fest";
import { ItemView } from "../../../vault/models/view/item.view";
export class Fido2KeyView extends ItemView {
keyType: "ECDSA";
keyType: "public-key";
keyAlgorithm: "ECDSA";
keyCurve: "P-256";
keyValue: string;
rpId: string;
rpName: string;
userHandle: string;
// Extras
rpName: string;
userName: string;
origin: string;

View File

@ -182,7 +182,8 @@ describe("FidoAuthenticatorService", () => {
name: params.rpEntity.name,
fido2Key: expect.objectContaining({
keyType: "ECDSA",
keyType: "public-key",
keyAlgorithm: "ECDSA",
keyCurve: "P-256",
rpId: params.rpEntity.id,
rpName: params.rpEntity.name,
@ -261,7 +262,8 @@ describe("FidoAuthenticatorService", () => {
name: existingCipherView.name,
fido2Key: expect.objectContaining({
keyType: "ECDSA",
keyType: "public-key",
keyAlgorithm: "ECDSA",
keyCurve: "P-256",
rpId: params.rpEntity.id,
rpName: params.rpEntity.name,

View File

@ -134,7 +134,8 @@ export class Fido2AuthenticatorService implements Fido2AuthenticatorServiceAbstr
const pcks8Key = await crypto.subtle.exportKey("pkcs8", keyValue);
const fido2Key = new Fido2KeyView();
fido2Key.keyType = "ECDSA";
fido2Key.keyType = "public-key";
fido2Key.keyAlgorithm = "ECDSA";
fido2Key.keyCurve = "P-256";
fido2Key.keyValue = Fido2Utils.bufferToString(pcks8Key);
fido2Key.rpId = params.rpEntity.id;