Skip to content

Commit

Permalink
provide right keys
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 9, 2024
1 parent 5f7a5fa commit 7d2b443
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/meteor/app/e2e/client/rocketchat.e2e.room.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ export class E2ERoom extends Emitter {
}

async exportSessionKey(key) {
key = key.slice(12);
key = Base64.decode(key);

try {
const decryptedKey = await decryptRSA(e2e.privateKey, key);
return toString(decryptedKey);
Expand Down Expand Up @@ -425,7 +428,7 @@ export class E2ERoom extends Emitter {
return await Promise.all(
oldRoomKeys.map(async (key) => {
const encryptedKey = await encryptRSA(userKey, toArrayBuffer(key.E2EKey));
const encryptedKeyToString = key.keyID + Base64.encode(new Uint8Array(encryptedKey));
const encryptedKeyToString = key.e2eKeyId + Base64.encode(new Uint8Array(encryptedKey));
return { ...key, E2EKey: encryptedKeyToString };
}),
);
Expand Down Expand Up @@ -641,11 +644,12 @@ export class E2ERoom extends Emitter {
return;
}

const mySub = Subscriptions.findOne({ rid: this.roomId });
const usersWithKeys = await Promise.all(
users.map(async (user) => {
const { _id, public_key } = user;
const key = await this.encryptGroupKeyForParticipant(public_key);
const oldKeys = await this.encryptOldKeysForParticipant(public_key, await this.exportOldRoomKeys(this.oldKeys));
const oldKeys = await this.encryptOldKeysForParticipant(public_key, await this.exportOldRoomKeys(mySub?.oldRoomKeys));
return { _id, key, ...(oldKeys && { oldKeys }) };
}),
);
Expand Down

0 comments on commit 7d2b443

Please sign in to comment.