mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
keys from backup need to be imported with import_session, not create
This commit is contained in:
parent
915925d6ee
commit
1b8e481559
@ -138,11 +138,17 @@ export class Decryption {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const session = new this._olm.InboundGroupSession();
|
||||||
|
try {
|
||||||
|
session.create(sessionKey);
|
||||||
const sessionEntry = await this._writeInboundSession(
|
const sessionEntry = await this._writeInboundSession(
|
||||||
roomId, senderKey, claimedEd25519Key, sessionId, sessionKey, txn);
|
session, roomId, senderKey, claimedEd25519Key, sessionId, txn);
|
||||||
if (sessionEntry) {
|
if (sessionEntry) {
|
||||||
newSessions.push(sessionEntry);
|
newSessions.push(sessionEntry);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
session.free();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// this will be passed to the Room in notifyRoomKeys
|
// this will be passed to the Room in notifyRoomKeys
|
||||||
return newSessions;
|
return newSessions;
|
||||||
@ -171,15 +177,17 @@ export class Decryption {
|
|||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return await this._writeInboundSession(
|
|
||||||
roomId, senderKey, claimedEd25519Key, sessionId, sessionKey, txn);
|
|
||||||
}
|
|
||||||
|
|
||||||
async _writeInboundSession(roomId, senderKey, claimedEd25519Key, sessionId, sessionKey, txn) {
|
|
||||||
const session = new this._olm.InboundGroupSession();
|
const session = new this._olm.InboundGroupSession();
|
||||||
try {
|
try {
|
||||||
session.create(sessionKey);
|
session.import_session(sessionKey);
|
||||||
|
return await this._writeInboundSession(
|
||||||
|
session, roomId, senderKey, claimedEd25519Key, sessionId, txn);
|
||||||
|
} finally {
|
||||||
|
session.free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async _writeInboundSession(session, roomId, senderKey, claimedEd25519Key, sessionId, txn) {
|
||||||
let incomingSessionIsBetter = true;
|
let incomingSessionIsBetter = true;
|
||||||
const existingSessionEntry = await txn.inboundGroupSessions.get(roomId, senderKey, sessionId);
|
const existingSessionEntry = await txn.inboundGroupSessions.get(roomId, senderKey, sessionId);
|
||||||
if (existingSessionEntry) {
|
if (existingSessionEntry) {
|
||||||
@ -203,9 +211,6 @@ export class Decryption {
|
|||||||
txn.inboundGroupSessions.set(sessionEntry);
|
txn.inboundGroupSessions.set(sessionEntry);
|
||||||
return sessionEntry;
|
return sessionEntry;
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
session.free();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user