Pass array buffer to libsignal encrypt/decrypt methods
This commit is contained in:
parent
6a061b4525
commit
c8211085fd
6
dist/converse.js
vendored
6
dist/converse.js
vendored
@ -71797,7 +71797,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
|
|
||||||
if (attrs.encrypted.prekey === 'true') {
|
if (attrs.encrypted.prekey === 'true') {
|
||||||
let plaintext;
|
let plaintext;
|
||||||
return session_cipher.decryptPreKeyWhisperMessage(atob(attrs.encrypted.key), 'binary').then(key_and_tag => {
|
return session_cipher.decryptPreKeyWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary').then(key_and_tag => {
|
||||||
if (attrs.encrypted.payload) {
|
if (attrs.encrypted.payload) {
|
||||||
const key = key_and_tag.slice(0, 16),
|
const key = key_and_tag.slice(0, 16),
|
||||||
tag = key_and_tag.slice(16);
|
tag = key_and_tag.slice(16);
|
||||||
@ -71826,7 +71826,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
return attrs;
|
return attrs;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return session_cipher.decryptWhisperMessage(atob(attrs.encrypted.key), 'binary').then(key_and_tag => {
|
return session_cipher.decryptWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary').then(key_and_tag => {
|
||||||
const key = key_and_tag.slice(0, 16),
|
const key = key_and_tag.slice(0, 16),
|
||||||
tag = key_and_tag.slice(16);
|
tag = key_and_tag.slice(16);
|
||||||
return this.decryptMessage(_.extend(attrs.encrypted, {
|
return this.decryptMessage(_.extend(attrs.encrypted, {
|
||||||
@ -71984,7 +71984,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|||||||
// devices associated with the contact, the result of this
|
// devices associated with the contact, the result of this
|
||||||
// concatenation is encrypted using the corresponding
|
// concatenation is encrypted using the corresponding
|
||||||
// long-standing SignalProtocol session.
|
// long-standing SignalProtocol session.
|
||||||
const promises = devices.filter(device => device.get('trusted') != UNTRUSTED).map(device => this.encryptKey(u.arrayBufferToString(obj.key_and_tag), device));
|
const promises = devices.filter(device => device.get('trusted') != UNTRUSTED).map(device => this.encryptKey(obj.key_and_tag, device));
|
||||||
return Promise.all(promises).then(dicts => this.addKeysToMessageStanza(stanza, dicts, obj.iv)).then(stanza => {
|
return Promise.all(promises).then(dicts => this.addKeysToMessageStanza(stanza, dicts, obj.iv)).then(stanza => {
|
||||||
stanza.c('payload').t(obj.payload).up().up();
|
stanza.c('payload').t(obj.payload).up().up();
|
||||||
stanza.c('store', {
|
stanza.c('store', {
|
||||||
|
@ -230,7 +230,7 @@
|
|||||||
// https://xmpp.org/extensions/xep-0384.html#usecases-receiving
|
// https://xmpp.org/extensions/xep-0384.html#usecases-receiving
|
||||||
if (attrs.encrypted.prekey === 'true') {
|
if (attrs.encrypted.prekey === 'true') {
|
||||||
let plaintext;
|
let plaintext;
|
||||||
return session_cipher.decryptPreKeyWhisperMessage(atob(attrs.encrypted.key), 'binary')
|
return session_cipher.decryptPreKeyWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary')
|
||||||
.then(key_and_tag => {
|
.then(key_and_tag => {
|
||||||
if (attrs.encrypted.payload) {
|
if (attrs.encrypted.payload) {
|
||||||
const key = key_and_tag.slice(0, 16),
|
const key = key_and_tag.slice(0, 16),
|
||||||
@ -253,7 +253,7 @@
|
|||||||
return attrs;
|
return attrs;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return session_cipher.decryptWhisperMessage(atob(attrs.encrypted.key), 'binary')
|
return session_cipher.decryptWhisperMessage(u.base64ToArrayBuffer(attrs.encrypted.key), 'binary')
|
||||||
.then(key_and_tag => {
|
.then(key_and_tag => {
|
||||||
const key = key_and_tag.slice(0, 16),
|
const key = key_and_tag.slice(0, 16),
|
||||||
tag = key_and_tag.slice(16);
|
tag = key_and_tag.slice(16);
|
||||||
@ -398,7 +398,7 @@
|
|||||||
// long-standing SignalProtocol session.
|
// long-standing SignalProtocol session.
|
||||||
const promises = devices
|
const promises = devices
|
||||||
.filter(device => device.get('trusted') != UNTRUSTED)
|
.filter(device => device.get('trusted') != UNTRUSTED)
|
||||||
.map(device => this.encryptKey(u.arrayBufferToString(obj.key_and_tag), device));
|
.map(device => this.encryptKey(obj.key_and_tag, device));
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
.then(dicts => this.addKeysToMessageStanza(stanza, dicts, obj.iv))
|
.then(dicts => this.addKeysToMessageStanza(stanza, dicts, obj.iv))
|
||||||
|
Loading…
Reference in New Issue
Block a user