Move prekey sigcheck to libaxolotl
This commit is contained in:
parent
cb6cb4ff89
commit
12844590f5
3 changed files with 20 additions and 17 deletions
|
@ -567,6 +567,7 @@ window.axolotl.protocol = function() {
|
|||
try {
|
||||
delete deviceObject['signedKey'];
|
||||
delete deviceObject['signedKeyId'];
|
||||
delete deviceObject['signedKeySignature'];
|
||||
delete deviceObject['preKey'];
|
||||
delete deviceObject['preKeyId'];
|
||||
} catch(_) {}
|
||||
|
@ -586,19 +587,23 @@ window.axolotl.protocol = function() {
|
|||
preKeyMsg.registrationId = axolotl.api.getMyRegistrationId();
|
||||
|
||||
if (session === undefined) {
|
||||
return axolotl.crypto.createKeyPair().then(function(baseKey) {
|
||||
preKeyMsg.preKeyId = deviceObject.preKeyId;
|
||||
preKeyMsg.signedPreKeyId = deviceObject.signedKeyId;
|
||||
preKeyMsg.baseKey = toArrayBuffer(baseKey.pubKey);
|
||||
return initSession(true, baseKey, undefined, deviceObject.encodedNumber,
|
||||
toArrayBuffer(deviceObject.identityKey), toArrayBuffer(deviceObject.preKey), toArrayBuffer(deviceObject.signedKey))
|
||||
.then(function(new_session) {
|
||||
session = new_session;
|
||||
session.pendingPreKey = { preKeyId: deviceObject.preKeyId, signedKeyId: deviceObject.signedKeyId, baseKey: baseKey.pubKey };
|
||||
return doEncryptPushMessageContent().then(function(message) {
|
||||
preKeyMsg.message = message;
|
||||
var result = String.fromCharCode((3 << 4) | 3) + getString(preKeyMsg.encode());
|
||||
return {type: 3, body: result};
|
||||
var deviceIdentityKey = toArrayBuffer(deviceObject.identityKey);
|
||||
var deviceSignedKey = toArrayBuffer(deviceObject.signedKey);
|
||||
return axolotl.crypto.Ed25519Verify(deviceIdentityKey, deviceSignedKey, toArrayBuffer(deviceObject.signedKeySignature)).then(function() {
|
||||
return axolotl.crypto.createKeyPair().then(function(baseKey) {
|
||||
preKeyMsg.preKeyId = deviceObject.preKeyId;
|
||||
preKeyMsg.signedPreKeyId = deviceObject.signedKeyId;
|
||||
preKeyMsg.baseKey = toArrayBuffer(baseKey.pubKey);
|
||||
return initSession(true, baseKey, undefined, deviceObject.encodedNumber,
|
||||
deviceIdentityKey, toArrayBuffer(deviceObject.preKey), deviceSignedKey)
|
||||
.then(function(new_session) {
|
||||
session = new_session;
|
||||
session.pendingPreKey = { preKeyId: deviceObject.preKeyId, signedKeyId: deviceObject.signedKeyId, baseKey: baseKey.pubKey };
|
||||
return doEncryptPushMessageContent().then(function(message) {
|
||||
preKeyMsg.message = message;
|
||||
var result = String.fromCharCode((3 << 4) | 3) + getString(preKeyMsg.encode());
|
||||
return {type: 3, body: result};
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -196,15 +196,12 @@ window.textsecure.api = function () {
|
|||
for (var i = 0; i < res.devices.length; i++) {
|
||||
res.devices[i].signedPreKey.publicKey = StringView.base64ToBytes(res.devices[i].signedPreKey.publicKey);
|
||||
res.devices[i].signedPreKey.signature = StringView.base64ToBytes(res.devices[i].signedPreKey.signature);
|
||||
promises[i] = window.axolotl.crypto.Ed25519Verify(res.identityKey, res.devices[i].signedPreKey.publicKey, res.devices[i].signedPreKey.signature);
|
||||
res.devices[i].preKey.publicKey = StringView.base64ToBytes(res.devices[i].preKey.publicKey);
|
||||
//TODO: Is this still needed?
|
||||
//if (res.devices[i].keyId === undefined)
|
||||
// res.devices[i].keyId = 0;
|
||||
}
|
||||
return Promise.all(promises).then(function() {
|
||||
return res;
|
||||
});
|
||||
return res;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ window.textsecure.messaging = function() {
|
|||
preKeyId: response.devices[i].preKey.keyId,
|
||||
signedKey: response.devices[i].signedPreKey.publicKey,
|
||||
signedKeyId: response.devices[i].signedPreKey.keyId,
|
||||
signedKeySignature: response.devices[i].signedPreKey.signature,
|
||||
registrationId: response.devices[i].registrationId
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue