diff --git a/js/background.js b/js/background.js index b89561c0e..1fc6005ac 100644 --- a/js/background.js +++ b/js/background.js @@ -221,10 +221,6 @@ // start a background worker for ecc textsecure.startWorker('js/libsignal-protocol-worker.js'); Whisper.KeyChangeListener.init(textsecure.storage.protocol); - textsecure.storage.protocol.on('removePreKey', () => { - getAccountManager().refreshPreKeys(); - }); - let messageReceiver; window.getSocketStatus = () => { if (messageReceiver) { diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index b30778621..c0e081087 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -7,7 +7,6 @@ lokiFileServerAPI, mnemonic, btoa, - Signal, getString, Event, dcodeIO, @@ -48,60 +47,6 @@ AccountManager.prototype = new textsecure.EventTarget(); AccountManager.prototype.extend({ constructor: AccountManager, - requestVoiceVerification(number) {}, - requestSMSVerification(number) {}, - async encryptDeviceName(name, providedIdentityKey) { - if (!name) { - return null; - } - const identityKey = - providedIdentityKey || - (await textsecure.storage.protocol.getIdentityKeyPair()); - if (!identityKey) { - throw new Error( - 'Identity key was not provided and is not in database!' - ); - } - const encrypted = await Signal.Crypto.encryptDeviceName( - name, - identityKey.pubKey - ); - - const proto = new textsecure.protobuf.DeviceName(); - proto.ephemeralPublic = encrypted.ephemeralPublic; - proto.syntheticIv = encrypted.syntheticIv; - proto.ciphertext = encrypted.ciphertext; - - const arrayBuffer = proto.encode().toArrayBuffer(); - return Signal.Crypto.arrayBufferToBase64(arrayBuffer); - }, - async decryptDeviceName(base64) { - const identityKey = await textsecure.storage.protocol.getIdentityKeyPair(); - - const arrayBuffer = Signal.Crypto.base64ToArrayBuffer(base64); - const proto = textsecure.protobuf.DeviceName.decode(arrayBuffer); - const encrypted = { - ephemeralPublic: proto.ephemeralPublic.toArrayBuffer(), - syntheticIv: proto.syntheticIv.toArrayBuffer(), - ciphertext: proto.ciphertext.toArrayBuffer(), - }; - - const name = await Signal.Crypto.decryptDeviceName( - encrypted, - identityKey.privKey - ); - - return name; - }, - async maybeUpdateDeviceName() { - throw new Error('Signal method called: maybeUpdateDeviceName'); - }, - async deviceNameIsEncrypted() { - await textsecure.storage.user.setDeviceNameEncrypted(); - }, - async maybeDeleteSignalingKey() { - throw new Error('Signal method called: maybeDeleteSignalingKey'); - }, registerSingleDevice(mnemonic, mnemonicLanguage, profileName) { const createAccount = this.createAccount.bind(this); const clearSessionsAndPreKeys = this.clearSessionsAndPreKeys.bind(this); @@ -140,65 +85,6 @@ ) ); }, - async addMockContact(doSave) { - if (doSave === undefined) { - // eslint-disable-next-line no-param-reassign - doSave = true; - } - const keyPair = await libsignal.KeyHelper.generateIdentityKeyPair(); - const pubKey = StringView.arrayBufferToHex(keyPair.pubKey); - const privKey = StringView.arrayBufferToHex(keyPair.privKey); - log.info(`contact pubkey ${pubKey}`); - log.info(`contact privkey ${privKey}`); - const signedKeyId = Math.floor(Math.random() * 1000 + 1); - - const signedPreKey = await libsignal.KeyHelper.generateSignedPreKey( - keyPair, - signedKeyId - ); - const contactSignedPreKey = { - publicKey: signedPreKey.keyPair.pubKey, - signature: signedPreKey.signature, - keyId: signedPreKey.keyId, - }; - if (doSave) { - await textsecure.storage.protocol.storeContactSignedPreKey( - pubKey, - contactSignedPreKey - ); - } else { - log.info( - `signed prekey: - ${StringView.arrayBufferToHex(contactSignedPreKey.publicKey)}` - ); - log.info( - `signature: - ${StringView.arrayBufferToHex(contactSignedPreKey.signature)}` - ); - } - - for (let keyId = 0; keyId < 10; keyId += 1) { - const preKey = await libsignal.KeyHelper.generatePreKey(keyId); - if (doSave) { - await textsecure.storage.protocol.storeContactPreKey(pubKey, { - publicKey: preKey.keyPair.pubKey, - keyId, - }); - } else { - log.info( - `signed prekey: - ${StringView.arrayBufferToHex(preKey.keyPair.pubKey)}` - ); - } - } - log.info('Added mock contact'); - }, - registerSecondDevice(setProvisioningUrl, confirmNumber, progressCallback) { - throw new Error( - 'account_manager: registerSecondDevice has not been implemented!' - ); - }, - refreshPreKeys() {}, rotateSignedPreKey() { return this.queueTask(() => { const signedKeyId = textsecure.storage.get('signedKeyId', 1); diff --git a/libtextsecure/test/account_manager_test.js b/libtextsecure/test/account_manager_test.js index 7f70ea08d..f73425db6 100644 --- a/libtextsecure/test/account_manager_test.js +++ b/libtextsecure/test/account_manager_test.js @@ -29,22 +29,6 @@ describe('AccountManager', () => { window.textsecure.storage.protocol = originalProtocolStorage; }); - describe('encrypted device name', () => { - it('roundtrips', async () => { - const deviceName = 'v2.5.0 on Ubunto 20.04'; - const encrypted = await accountManager.encryptDeviceName(deviceName); - assert.strictEqual(typeof encrypted, 'string'); - const decrypted = await accountManager.decryptDeviceName(encrypted); - - assert.strictEqual(decrypted, deviceName); - }); - - it('handles null deviceName', async () => { - const encrypted = await accountManager.encryptDeviceName(null); - assert.strictEqual(encrypted, null); - }); - }); - it('keeps three confirmed keys even if over a week old', () => { const now = Date.now(); signedPreKeys = [ diff --git a/test/crypto_test.js b/test/crypto_test.js index 44eb42877..a5a6b0ac1 100644 --- a/test/crypto_test.js +++ b/test/crypto_test.js @@ -110,43 +110,6 @@ describe('Crypto', () => { }); }); - describe('encrypted device name', () => { - it('roundtrips', async () => { - const deviceName = 'v1.19.0 on Windows 10'; - const identityKey = await libsignal.KeyHelper.generateIdentityKeyPair(); - - const encrypted = await Signal.Crypto.encryptDeviceName( - deviceName, - identityKey.pubKey - ); - const decrypted = await Signal.Crypto.decryptDeviceName( - encrypted, - identityKey.privKey - ); - - assert.strictEqual(decrypted, deviceName); - }); - - it('fails if iv is changed', async () => { - const deviceName = 'v1.19.0 on Windows 10'; - const identityKey = await libsignal.KeyHelper.generateIdentityKeyPair(); - - const encrypted = await Signal.Crypto.encryptDeviceName( - deviceName, - identityKey.pubKey - ); - encrypted.syntheticIv = Signal.Crypto.getRandomBytes(16); - try { - await Signal.Crypto.decryptDeviceName(encrypted, identityKey.privKey); - } catch (error) { - assert.strictEqual( - error.message, - 'decryptDeviceName: synthetic IV did not match' - ); - } - }); - }); - describe('attachment encryption', () => { it('roundtrips', async () => { const staticKeyPair = await libsignal.KeyHelper.generateIdentityKeyPair();