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

Minor improvements to logging in device verification #4390

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/rust-crypto/CrossSigningIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ export class CrossSigningIdentity {
// Update 4S before uploading cross-signing keys, to stay consistent with legacy that asks
// 4S passphrase before asking for account password.
// Ultimately should be made atomic and resistant to forgotten password/passphrase.
logger.log("resetCrossSigning: exporting to secret storage");

logger.log("resetCrossSigning: exporting private keys to secret storage");
await this.exportCrossSigningKeysToStorage();
}
logger.log("resetCrossSigning: publishing keys to server");

logger.log("resetCrossSigning: publishing public keys to server");
for (const req of [
outgoingRequests.uploadKeysRequest,
outgoingRequests.uploadSigningKeysRequest,
Expand Down
5 changes: 2 additions & 3 deletions src/rust-crypto/PerSessionKeyBackupDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,6 @@ export class PerSessionKeyBackupDownloader {
return null;
}

const authData = currentServerVersion.auth_data as Curve25519AuthData;

const backupKeys = await this.getBackupDecryptionKey();
if (!backupKeys?.decryptionKey) {
this.logger.debug(`Not checking key backup for session (no decryption key)`);
Expand All @@ -483,8 +481,9 @@ export class PerSessionKeyBackupDownloader {
return null;
}

const authData = currentServerVersion.auth_data as Curve25519AuthData;
if (authData.public_key != backupKeys.decryptionKey.megolmV1PublicKey.publicKeyBase64) {
this.logger.debug(`getBackupDecryptor key mismatch error`);
this.logger.debug(`Key backup on server does not match our decryption key`);
this.hasConfigurationProblem = true;
return null;
}
Expand Down
13 changes: 6 additions & 7 deletions src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,19 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
* Implementation of {@link CryptoBackend#getBackupDecryptor}.
*/
public async getBackupDecryptor(backupInfo: KeyBackupInfo, privKey: ArrayLike<number>): Promise<BackupDecryptor> {
if (backupInfo.algorithm != "m.megolm_backup.v1.curve25519-aes-sha2") {
throw new Error(`getBackupDecryptor Unsupported algorithm ${backupInfo.algorithm}`);
if (!(privKey instanceof Uint8Array)) {
throw new Error(`getBackupDecryptor: expects Uint8Array`);
}

const authData = <Curve25519AuthData>backupInfo.auth_data;

if (!(privKey instanceof Uint8Array)) {
throw new Error(`getBackupDecryptor expects Uint8Array`);
if (backupInfo.algorithm != "m.megolm_backup.v1.curve25519-aes-sha2") {
throw new Error(`getBackupDecryptor: Unsupported algorithm ${backupInfo.algorithm}`);
}

const backupDecryptionKey = RustSdkCryptoJs.BackupDecryptionKey.fromBase64(encodeBase64(privKey));

const authData = <Curve25519AuthData>backupInfo.auth_data;
if (authData.public_key != backupDecryptionKey.megolmV1PublicKey.publicKeyBase64) {
throw new Error(`getBackupDecryptor key mismatch error`);
throw new Error(`getBackupDecryptor: key backup on server does not match the decryption key`);
}

return this.backupManager.createBackupDecryptor(backupDecryptionKey);
Expand Down
Loading