Skip to content

Commit

Permalink
Rename backup_password & functions
Browse files Browse the repository at this point in the history
Not Just For Backups Anymore
  • Loading branch information
dbkr committed Nov 15, 2019
1 parent 04b57bb commit ca1bdaa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 86 deletions.
6 changes: 3 additions & 3 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import logger from './logger';
import Crypto from './crypto';
import { isCryptoAvailable } from './crypto';
import { encodeRecoveryKey, decodeRecoveryKey } from './crypto/recoverykey';
import { keyForNewBackup, keyForExistingBackup } from './crypto/backup_password';
import { keyFromPassphrase, keyFromAuthData } from './crypto/key_passphrase';
import { randomString } from './randomstring';

// Disable warnings for now: we use deprecated bluebird functions
Expand Down Expand Up @@ -1380,7 +1380,7 @@ MatrixClient.prototype.prepareKeyBackupVersion = async function(password) {
let publicKey;
const authData = {};
if (password) {
const keyInfo = await keyForNewBackup(password);
const keyInfo = await keyFromPassphrase(password);
publicKey = decryption.init_with_private_key(keyInfo.key);
authData.private_key_salt = keyInfo.salt;
authData.private_key_iterations = keyInfo.iterations;
Expand Down Expand Up @@ -1542,7 +1542,7 @@ MatrixClient.RESTORE_BACKUP_ERROR_BAD_KEY = 'RESTORE_BACKUP_ERROR_BAD_KEY';
MatrixClient.prototype.restoreKeyBackupWithPassword = async function(
password, targetRoomId, targetSessionId, backupInfo,
) {
const privKey = await keyForExistingBackup(backupInfo, password);
const privKey = await keyFromAuthData(backupInfo.auth_data, password);
return this._restoreKeyBackup(
privKey, targetRoomId, targetSessionId, backupInfo,
);
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/Secrets.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {EventEmitter} from 'events';
import logger from '../logger';
import olmlib from './olmlib';
import { randomString } from '../randomstring';
import { keyForNewBackup } from './backup_password';
import { keyFromPassphrase } from './backup_password';
import { encodeRecoveryKey } from './recoverykey';
import { pkVerify } from './olmlib';

Expand Down Expand Up @@ -91,7 +91,7 @@ export default class SecretStorage extends EventEmitter {
const decryption = new global.Olm.PkDecryption();
try {
if (opts.passphrase) {
const key = await keyForNewBackup(opts.passphrase);
const key = await keyFromPassphrase(opts.passphrase);
keyData.passphrase = {
algorithm: "m.pbkdf2",
iterations: key.iterations,
Expand Down
81 changes: 0 additions & 81 deletions src/crypto/backup_password.js

This file was deleted.

0 comments on commit ca1bdaa

Please sign in to comment.