mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[EC-598] fix: counter not being saved correctly
This commit is contained in:
@@ -8,7 +8,7 @@ export class Fido2KeyApi extends BaseResponse {
|
|||||||
keyValue: string;
|
keyValue: string;
|
||||||
rpId: string;
|
rpId: string;
|
||||||
userHandle: string;
|
userHandle: string;
|
||||||
counter: number;
|
counter: string;
|
||||||
|
|
||||||
// Extras
|
// Extras
|
||||||
rpName: string;
|
rpName: string;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export class Fido2KeyData {
|
|||||||
keyValue: string;
|
keyValue: string;
|
||||||
rpId: string;
|
rpId: string;
|
||||||
userHandle: string;
|
userHandle: string;
|
||||||
counter: number;
|
counter: string;
|
||||||
|
|
||||||
// Extras
|
// Extras
|
||||||
rpName: string;
|
rpName: string;
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ export class Fido2Key extends Domain {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<Fido2KeyView> {
|
async decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<Fido2KeyView> {
|
||||||
return this.decryptObj(
|
const view = await this.decryptObj(
|
||||||
new Fido2KeyView(),
|
new Fido2KeyView(),
|
||||||
{
|
{
|
||||||
nonDiscoverableId: null,
|
nonDiscoverableId: null,
|
||||||
@@ -58,7 +58,6 @@ export class Fido2Key extends Domain {
|
|||||||
keyValue: null,
|
keyValue: null,
|
||||||
rpId: null,
|
rpId: null,
|
||||||
userHandle: null,
|
userHandle: null,
|
||||||
counter: null,
|
|
||||||
rpName: null,
|
rpName: null,
|
||||||
userName: null,
|
userName: null,
|
||||||
origin: null,
|
origin: null,
|
||||||
@@ -66,6 +65,19 @@ export class Fido2Key extends Domain {
|
|||||||
orgId,
|
orgId,
|
||||||
encKey
|
encKey
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { counter } = await this.decryptObj(
|
||||||
|
{ counter: "" },
|
||||||
|
{
|
||||||
|
counter: null,
|
||||||
|
},
|
||||||
|
orgId,
|
||||||
|
encKey
|
||||||
|
);
|
||||||
|
// Counter will end up as NaN if this fails
|
||||||
|
view.counter = parseInt(counter);
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
toFido2KeyData(): Fido2KeyData {
|
toFido2KeyData(): Fido2KeyData {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import { Fido2KeyApi } from "../../../fido2/models/api/fido2-key.api";
|
||||||
import { CardApi } from "../../../models/api/card.api";
|
import { CardApi } from "../../../models/api/card.api";
|
||||||
import { FieldApi } from "../../../models/api/field.api";
|
import { FieldApi } from "../../../models/api/field.api";
|
||||||
import { IdentityApi } from "../../../models/api/identity.api";
|
import { IdentityApi } from "../../../models/api/identity.api";
|
||||||
import { LoginUriApi } from "../../../models/api/login-uri.api";
|
import { LoginUriApi } from "../../../models/api/login-uri.api";
|
||||||
import { LoginApi } from "../../../models/api/login.api";
|
import { LoginApi } from "../../../models/api/login.api";
|
||||||
import { SecureNoteApi } from "../../../models/api/secure-note.api";
|
import { SecureNoteApi } from "../../../models/api/secure-note.api";
|
||||||
import { Fido2KeyApi } from "../../../fido2/models/api/fido2-key.api";
|
|
||||||
import { CipherRepromptType } from "../../enums/cipher-reprompt-type";
|
import { CipherRepromptType } from "../../enums/cipher-reprompt-type";
|
||||||
import { CipherType } from "../../enums/cipher-type";
|
import { CipherType } from "../../enums/cipher-type";
|
||||||
import { Cipher } from "../domain/cipher";
|
import { Cipher } from "../domain/cipher";
|
||||||
@@ -92,6 +92,10 @@ export class CipherRequest {
|
|||||||
cipher.login.fido2Key.rpName != null
|
cipher.login.fido2Key.rpName != null
|
||||||
? cipher.login.fido2Key.rpName.encryptedString
|
? cipher.login.fido2Key.rpName.encryptedString
|
||||||
: null;
|
: null;
|
||||||
|
this.login.fido2Key.counter =
|
||||||
|
cipher.login.fido2Key.counter != null
|
||||||
|
? cipher.login.fido2Key.counter.encryptedString
|
||||||
|
: null;
|
||||||
this.login.fido2Key.userHandle =
|
this.login.fido2Key.userHandle =
|
||||||
cipher.login.fido2Key.userHandle != null
|
cipher.login.fido2Key.userHandle != null
|
||||||
? cipher.login.fido2Key.userHandle.encryptedString
|
? cipher.login.fido2Key.userHandle.encryptedString
|
||||||
@@ -185,6 +189,8 @@ export class CipherRequest {
|
|||||||
cipher.fido2Key.rpId != null ? cipher.fido2Key.rpId.encryptedString : null;
|
cipher.fido2Key.rpId != null ? cipher.fido2Key.rpId.encryptedString : null;
|
||||||
this.fido2Key.rpName =
|
this.fido2Key.rpName =
|
||||||
cipher.fido2Key.rpName != null ? cipher.fido2Key.rpName.encryptedString : null;
|
cipher.fido2Key.rpName != null ? cipher.fido2Key.rpName.encryptedString : null;
|
||||||
|
this.fido2Key.counter =
|
||||||
|
cipher.fido2Key.counter != null ? cipher.fido2Key.counter.encryptedString : null;
|
||||||
this.fido2Key.userHandle =
|
this.fido2Key.userHandle =
|
||||||
cipher.fido2Key.userHandle != null ? cipher.fido2Key.userHandle.encryptedString : null;
|
cipher.fido2Key.userHandle != null ? cipher.fido2Key.userHandle.encryptedString : null;
|
||||||
this.fido2Key.userName =
|
this.fido2Key.userName =
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { SettingsService } from "../../abstractions/settings.service";
|
|||||||
import { StateService } from "../../abstractions/state.service";
|
import { StateService } from "../../abstractions/state.service";
|
||||||
import { FieldType } from "../../enums/fieldType";
|
import { FieldType } from "../../enums/fieldType";
|
||||||
import { UriMatchType } from "../../enums/uriMatchType";
|
import { UriMatchType } from "../../enums/uriMatchType";
|
||||||
|
import { Fido2Key } from "../../fido2/models/domain/fido2-key";
|
||||||
import { sequentialize } from "../../misc/sequentialize";
|
import { sequentialize } from "../../misc/sequentialize";
|
||||||
import { Utils } from "../../misc/utils";
|
import { Utils } from "../../misc/utils";
|
||||||
import { AccountSettingsSettings } from "../../models/domain/account";
|
import { AccountSettingsSettings } from "../../models/domain/account";
|
||||||
@@ -19,7 +20,6 @@ import { EncString } from "../../models/domain/enc-string";
|
|||||||
import { SymmetricCryptoKey } from "../../models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "../../models/domain/symmetric-crypto-key";
|
||||||
import { ErrorResponse } from "../../models/response/error.response";
|
import { ErrorResponse } from "../../models/response/error.response";
|
||||||
import { View } from "../../models/view/view";
|
import { View } from "../../models/view/view";
|
||||||
import { Fido2Key } from "../../fido2/models/domain/fido2-key";
|
|
||||||
import { CipherService as CipherServiceAbstraction } from "../abstractions/cipher.service";
|
import { CipherService as CipherServiceAbstraction } from "../abstractions/cipher.service";
|
||||||
import { CipherFileUploadService } from "../abstractions/file-upload/cipher-file-upload.service";
|
import { CipherFileUploadService } from "../abstractions/file-upload/cipher-file-upload.service";
|
||||||
import { CipherType } from "../enums/cipher-type";
|
import { CipherType } from "../enums/cipher-type";
|
||||||
@@ -1137,6 +1137,10 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
},
|
},
|
||||||
key
|
key
|
||||||
);
|
);
|
||||||
|
cipher.login.fido2Key.counter = await this.cryptoService.encrypt(
|
||||||
|
String(model.login.fido2Key.counter),
|
||||||
|
key
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case CipherType.SecureNote:
|
case CipherType.SecureNote:
|
||||||
@@ -1205,6 +1209,10 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
},
|
},
|
||||||
key
|
key
|
||||||
);
|
);
|
||||||
|
cipher.fido2Key.counter = await this.cryptoService.encrypt(
|
||||||
|
String(model.fido2Key.counter),
|
||||||
|
key
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Unknown cipher type.");
|
throw new Error("Unknown cipher type.");
|
||||||
|
|||||||
Reference in New Issue
Block a user