From dc68c8050422ef1c43f57d3841139e18e2f03fe9 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 22 Jan 2021 10:36:23 +1100 Subject: [PATCH] fix refresh of moderator list and removed unused proto --- js/modules/crypto.js | 51 -------------------------- libtextsecure/protobufs.js | 10 +---- libtextsecure/protocol_wrapper.js | 2 +- protos/DeviceMessages.proto | 20 ---------- protos/DeviceName.proto | 7 ---- protos/UnidentifiedDelivery.proto | 39 -------------------- ts/components/conversation/Message.tsx | 4 ++ 7 files changed, 7 insertions(+), 126 deletions(-) delete mode 100644 protos/DeviceMessages.proto delete mode 100644 protos/DeviceName.proto delete mode 100644 protos/UnidentifiedDelivery.proto diff --git a/js/modules/crypto.js b/js/modules/crypto.js index 953832b02..c67a9053e 100644 --- a/js/modules/crypto.js +++ b/js/modules/crypto.js @@ -10,13 +10,11 @@ module.exports = { concatenateBytes, constantTimeEqual, decryptAesCtr, - decryptDeviceName, decryptAttachment, decryptFile, decryptSymmetric, deriveAccessKey, encryptAesCtr, - encryptDeviceName, encryptAttachment, encryptFile, encryptSymmetric, @@ -54,55 +52,6 @@ function stringFromBytes(buffer) { // High-level Operations -async function encryptDeviceName(deviceName, identityPublic) { - const plaintext = bytesFromString(deviceName); - const ephemeralKeyPair = await libsignal.KeyHelper.generateIdentityKeyPair(); - const masterSecret = await libsignal.Curve.async.calculateAgreement( - identityPublic, - ephemeralKeyPair.privKey - ); - - const key1 = await hmacSha256(masterSecret, bytesFromString('auth')); - const syntheticIv = _getFirstBytes(await hmacSha256(key1, plaintext), 16); - - const key2 = await hmacSha256(masterSecret, bytesFromString('cipher')); - const cipherKey = await hmacSha256(key2, syntheticIv); - - const counter = getZeroes(16); - const ciphertext = await encryptAesCtr(cipherKey, plaintext, counter); - - return { - ephemeralPublic: ephemeralKeyPair.pubKey, - syntheticIv, - ciphertext, - }; -} - -async function decryptDeviceName( - { ephemeralPublic, syntheticIv, ciphertext } = {}, - identityPrivate -) { - const masterSecret = await libsignal.Curve.async.calculateAgreement( - ephemeralPublic, - identityPrivate - ); - - const key2 = await hmacSha256(masterSecret, bytesFromString('cipher')); - const cipherKey = await hmacSha256(key2, syntheticIv); - - const counter = getZeroes(16); - const plaintext = await decryptAesCtr(cipherKey, ciphertext, counter); - - const key1 = await hmacSha256(masterSecret, bytesFromString('auth')); - const ourSyntheticIv = _getFirstBytes(await hmacSha256(key1, plaintext), 16); - - if (!constantTimeEqual(ourSyntheticIv, syntheticIv)) { - throw new Error('decryptDeviceName: synthetic IV did not match'); - } - - return stringFromBytes(plaintext); -} - // Path structure: 'fa/facdf99c22945b1c9393345599a276f4b36ad7ccdc8c2467f5441b742c2d11fa' function getAttachmentLabel(path) { const filename = path.slice(3); diff --git a/libtextsecure/protobufs.js b/libtextsecure/protobufs.js index 3e7910bc5..06888ee7d 100644 --- a/libtextsecure/protobufs.js +++ b/libtextsecure/protobufs.js @@ -30,14 +30,8 @@ ); } + // this is all the Session Protocols loadProtoBufs('SignalService.proto'); + // this is for websocket wrapping of messages loadProtoBufs('SubProtocol.proto'); - loadProtoBufs('DeviceMessages.proto'); - loadProtoBufs('WhisperTextProtocol.proto'); - - // Just for encrypting device names - loadProtoBufs('DeviceName.proto'); - - // Metadata-specific protos - loadProtoBufs('UnidentifiedDelivery.proto'); })(); diff --git a/libtextsecure/protocol_wrapper.js b/libtextsecure/protocol_wrapper.js index 0a0a17369..1846f26b9 100644 --- a/libtextsecure/protocol_wrapper.js +++ b/libtextsecure/protocol_wrapper.js @@ -1,7 +1,7 @@ /* global window, textsecure, SignalProtocolStore, libsignal */ // eslint-disable-next-line func-names -(function () { +(function() { window.textsecure = window.textsecure || {}; window.textsecure.storage = window.textsecure.storage || {}; textsecure.storage.protocol = new SignalProtocolStore(); diff --git a/protos/DeviceMessages.proto b/protos/DeviceMessages.proto deleted file mode 100644 index 3e96e5f58..000000000 --- a/protos/DeviceMessages.proto +++ /dev/null @@ -1,20 +0,0 @@ -package signalservice; - -message ProvisioningUuid { - optional string uuid = 1; -} - - -message ProvisionEnvelope { - optional bytes publicKey = 1; - optional bytes body = 2; // Encrypted ProvisionMessage -} - -message ProvisionMessage { - optional bytes identityKeyPrivate = 2; - optional string number = 3; - optional string provisioningCode = 4; - optional string userAgent = 5; - optional bytes profileKey = 6; - optional bool readReceipts = 7; -} diff --git a/protos/DeviceName.proto b/protos/DeviceName.proto deleted file mode 100644 index ec2859b18..000000000 --- a/protos/DeviceName.proto +++ /dev/null @@ -1,7 +0,0 @@ -package signalservice; - -message DeviceName { - optional bytes ephemeralPublic = 1; - optional bytes syntheticIv = 2; - optional bytes ciphertext = 3; -} diff --git a/protos/UnidentifiedDelivery.proto b/protos/UnidentifiedDelivery.proto deleted file mode 100644 index ee7422d65..000000000 --- a/protos/UnidentifiedDelivery.proto +++ /dev/null @@ -1,39 +0,0 @@ -package signalservice; - -option java_package = "org.whispersystems.libsignal.protocol"; -option java_outer_classname = "WhisperProtos"; - -message ServerCertificate { - message Certificate { - optional uint32 id = 1; - optional bytes key = 2; - } - - optional bytes certificate = 1; - optional bytes signature = 2; -} - -// This should perhaps be renamed to something like `SenderInfo` -message SenderCertificate { - optional string sender = 1; - optional uint32 senderDevice = 2; -} - -message UnidentifiedSenderMessage { - - message Message { - enum Type { - PREKEY_MESSAGE = 1; - MESSAGE = 2; - FALLBACK_MESSAGE = 3; - } - - optional Type type = 1; - optional SenderCertificate senderCertificate = 2; - optional bytes content = 3; - } - - optional bytes ephemeralPublic = 1; - optional bytes encryptedStatic = 2; - optional bytes encryptedMessage = 3; -} diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 88924fb84..55a6e77ca 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -991,6 +991,10 @@ class MessageInner extends React.PureComponent { ToastUtils.pushUserNeedsToHaveJoined(); } else { window.log.info(`${pubkey} added as moderator...`); + // refresh the moderator list. Will trigger a refresh + const modPubKeys = (await channelAPI.getModerators()) as Array; + convo.updateGroupAdmins(modPubKeys); + ToastUtils.pushUserAddedToModerators(); } } catch (e) {