remove unused proto files and ProvisioningCipher.js
parent
ce8bc84de0
commit
ec9bd4a3a9
@ -1,78 +0,0 @@
|
|||||||
/* global libsignal, textsecure */
|
|
||||||
|
|
||||||
/* eslint-disable more/no-then */
|
|
||||||
|
|
||||||
// eslint-disable-next-line func-names
|
|
||||||
(function() {
|
|
||||||
function ProvisioningCipher() {}
|
|
||||||
|
|
||||||
ProvisioningCipher.prototype = {
|
|
||||||
decrypt(provisionEnvelope) {
|
|
||||||
const masterEphemeral = provisionEnvelope.publicKey.toArrayBuffer();
|
|
||||||
const message = provisionEnvelope.body.toArrayBuffer();
|
|
||||||
if (new Uint8Array(message)[0] !== 1) {
|
|
||||||
throw new Error('Bad version number on ProvisioningMessage');
|
|
||||||
}
|
|
||||||
|
|
||||||
const iv = message.slice(1, 16 + 1);
|
|
||||||
const mac = message.slice(message.byteLength - 32, message.byteLength);
|
|
||||||
const ivAndCiphertext = message.slice(0, message.byteLength - 32);
|
|
||||||
const ciphertext = message.slice(16 + 1, message.byteLength - 32);
|
|
||||||
|
|
||||||
return libsignal.Curve.async
|
|
||||||
.calculateAgreement(masterEphemeral, this.keyPair.privKey)
|
|
||||||
.then(ecRes =>
|
|
||||||
libsignal.HKDF.deriveSecrets(
|
|
||||||
ecRes,
|
|
||||||
new ArrayBuffer(32),
|
|
||||||
'TextSecure Provisioning Message'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.then(keys =>
|
|
||||||
libsignal.crypto
|
|
||||||
.verifyMAC(ivAndCiphertext, keys[1], mac, 32)
|
|
||||||
.then(() => libsignal.crypto.decrypt(keys[0], ciphertext, iv))
|
|
||||||
)
|
|
||||||
.then(plaintext => {
|
|
||||||
const provisionMessage = textsecure.protobuf.ProvisionMessage.decode(
|
|
||||||
plaintext
|
|
||||||
);
|
|
||||||
const privKey = provisionMessage.identityKeyPrivate.toArrayBuffer();
|
|
||||||
|
|
||||||
return libsignal.Curve.async.createKeyPair(privKey).then(keyPair => {
|
|
||||||
const ret = {
|
|
||||||
identityKeyPair: keyPair,
|
|
||||||
number: provisionMessage.number,
|
|
||||||
provisioningCode: provisionMessage.provisioningCode,
|
|
||||||
userAgent: provisionMessage.userAgent,
|
|
||||||
readReceipts: provisionMessage.readReceipts,
|
|
||||||
};
|
|
||||||
if (provisionMessage.profileKey) {
|
|
||||||
ret.profileKey = provisionMessage.profileKey.toArrayBuffer();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getPublicKey() {
|
|
||||||
return Promise.resolve()
|
|
||||||
.then(() => {
|
|
||||||
if (!this.keyPair) {
|
|
||||||
return libsignal.Curve.async.generateKeyPair().then(keyPair => {
|
|
||||||
this.keyPair = keyPair;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
})
|
|
||||||
.then(() => this.keyPair.pubKey);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
libsignal.ProvisioningCipher = function ProvisioningCipherWrapper() {
|
|
||||||
const cipher = new ProvisioningCipher();
|
|
||||||
|
|
||||||
this.decrypt = cipher.decrypt.bind(cipher);
|
|
||||||
this.getPublicKey = cipher.getPublicKey.bind(cipher);
|
|
||||||
};
|
|
||||||
})();
|
|
@ -1,12 +1,11 @@
|
|||||||
/* global window, textsecure, SignalProtocolStore, libsignal */
|
/* global window, textsecure, SignalProtocolStore, libsignal */
|
||||||
|
|
||||||
// eslint-disable-next-line func-names
|
// eslint-disable-next-line func-names
|
||||||
(function() {
|
(function () {
|
||||||
window.textsecure = window.textsecure || {};
|
window.textsecure = window.textsecure || {};
|
||||||
window.textsecure.storage = window.textsecure.storage || {};
|
window.textsecure.storage = window.textsecure.storage || {};
|
||||||
textsecure.storage.protocol = new SignalProtocolStore();
|
textsecure.storage.protocol = new SignalProtocolStore();
|
||||||
|
|
||||||
textsecure.ProvisioningCipher = libsignal.ProvisioningCipher;
|
|
||||||
textsecure.startWorker = libsignal.worker.startWorker;
|
textsecure.startWorker = libsignal.worker.startWorker;
|
||||||
textsecure.stopWorker = libsignal.worker.stopWorker;
|
textsecure.stopWorker = libsignal.worker.stopWorker;
|
||||||
})();
|
})();
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package signalservice;
|
|
||||||
|
|
||||||
option java_package = "org.whispersystems.libsignal.protocol";
|
|
||||||
option java_outer_classname = "WhisperProtos";
|
|
||||||
|
|
||||||
message WhisperMessage {
|
|
||||||
optional bytes ephemeralKey = 1;
|
|
||||||
optional uint32 counter = 2;
|
|
||||||
optional uint32 previousCounter = 3;
|
|
||||||
optional bytes ciphertext = 4; // PushMessageContent
|
|
||||||
}
|
|
||||||
|
|
||||||
message PreKeyWhisperMessage {
|
|
||||||
optional uint32 registrationId = 5;
|
|
||||||
optional uint32 preKeyId = 1;
|
|
||||||
optional uint32 signedPreKeyId = 6;
|
|
||||||
optional bytes baseKey = 2;
|
|
||||||
optional bytes identityKey = 3;
|
|
||||||
optional bytes message = 4; // WhisperMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
message KeyExchangeMessage {
|
|
||||||
optional uint32 id = 1;
|
|
||||||
optional bytes baseKey = 2;
|
|
||||||
optional bytes ephemeralKey = 3;
|
|
||||||
optional bytes identityKey = 4;
|
|
||||||
optional bytes baseKeySignature = 5;
|
|
||||||
}
|
|
Loading…
Reference in New Issue