Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element-R: improve logging for secret gossiping #4018

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/rust-crypto/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents,
/**
* Handles a backup secret received event and store it if it matches the current backup version.
*
* @param secret - The secret as received from a `m.secert.send` event for secret `m.megolm_backup.v1`.
* @param secret - The secret as received from a `m.secret.send` event for secret `m.megolm_backup.v1`.
* @returns true if the secret is valid and has been stored, false otherwise.
*/
public async handleBackupSecretReceived(secret: string): Promise<boolean> {
Expand All @@ -141,15 +141,19 @@ export class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents,
if (!backupCheck?.backupInfo?.version || !backupCheck.trustInfo.trusted) {
// There is no server-side key backup, or the backup is not signed by a trusted cross-signing key or trusted own device.
// This decryption key is useless to us.
logger.warn("Received backup decryption key, but there is no trusted server-side key backup");
logger.warn(
"handleBackupSecretReceived: Received a backup decryption key, but there is no trusted server-side key backup",
);
return false;
}

try {
const backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(secret);
const privateKeyMatches = backupInfoMatchesBackupDecryptionKey(backupCheck.backupInfo, backupDecryptionKey);
if (!privateKeyMatches) {
logger.debug(`onReceiveSecret: backup decryption key does not match current backup version`);
logger.warn(
`handleBackupSecretReceived: Private decryption key does not match the public key of the current remote backup.`,
);
// just ignore the secret
return false;
}
Expand Down
Loading