1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-21 11:35:34 +01:00

Add context logs for native messaging (#11690)

* Add logging to decryption routines

* Fix case of uknown encryption type

* Add decryption context to log where failures occur

* Update log message

* Fix linting

* Add more context logs

* Add context logs for native messaging

* Update apps/desktop/native-messaging-test-runner/src/native-message.service.ts

Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com>

* Update apps/desktop/src/services/native-message-handler.service.ts

Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com>

* Rename channel key to desktop ipc channel key

---------

Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com>
This commit is contained in:
Bernd Schoolmann 2024-11-05 15:38:23 +01:00 committed by GitHub
parent 8bee0ada2f
commit 48bd438824
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 2 deletions

View File

@ -274,7 +274,11 @@ export class NativeMessagingBackground {
let message = rawMessage as ReceiveMessage; let message = rawMessage as ReceiveMessage;
if (!this.platformUtilsService.isSafari()) { if (!this.platformUtilsService.isSafari()) {
message = JSON.parse( message = JSON.parse(
await this.encryptService.decryptToUtf8(rawMessage as EncString, this.sharedSecret), await this.encryptService.decryptToUtf8(
rawMessage as EncString,
this.sharedSecret,
"ipc-desktop-ipc-channel-key",
),
); );
} }

View File

@ -219,7 +219,11 @@ export default class NativeMessageService {
key: string, key: string,
): Promise<DecryptedCommandData> { ): Promise<DecryptedCommandData> {
const sharedKey = await this.getSharedKeyForKey(key); const sharedKey = await this.getSharedKeyForKey(key);
const decrypted = await this.encryptService.decryptToUtf8(payload, sharedKey); const decrypted = await this.encryptService.decryptToUtf8(
payload,
sharedKey,
"native-messaging-session",
);
return JSON.parse(decrypted); return JSON.parse(decrypted);
} }

View File

@ -185,6 +185,7 @@ export class NativeMessageHandlerService {
let decryptedResult = await this.encryptService.decryptToUtf8( let decryptedResult = await this.encryptService.decryptToUtf8(
message.encryptedCommand as EncString, message.encryptedCommand as EncString,
this.ddgSharedSecret, this.ddgSharedSecret,
"ddg-shared-key",
); );
decryptedResult = this.trimNullCharsFromMessage(decryptedResult); decryptedResult = this.trimNullCharsFromMessage(decryptedResult);

View File

@ -114,6 +114,7 @@ export class NativeMessagingService {
await this.encryptService.decryptToUtf8( await this.encryptService.decryptToUtf8(
rawMessage as EncString, rawMessage as EncString,
SymmetricCryptoKey.fromString(await ipc.platform.ephemeralStore.getEphemeralValue(appId)), SymmetricCryptoKey.fromString(await ipc.platform.ephemeralStore.getEphemeralValue(appId)),
`native-messaging-session-${appId}`,
), ),
); );