Merge pull request #42 from sachaaaaa/restore_padding

restore ciphertext padding
pull/44/head
sachaaaaa 7 years ago committed by GitHub
commit 82a09d46d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -705,16 +705,16 @@ MessageReceiver.prototype.extend({
switch (envelope.type) { switch (envelope.type) {
case textsecure.protobuf.Envelope.Type.CIPHERTEXT: case textsecure.protobuf.Envelope.Type.CIPHERTEXT:
window.log.info('message from', this.getEnvelopeId(envelope)); window.log.info('message from', this.getEnvelopeId(envelope));
promise = sessionCipher.decryptWhisperMessage(ciphertext); promise = sessionCipher.decryptWhisperMessage(ciphertext)
// TODO: restore unpadding (?) .then(this.unpad);
// .then(this.unpad);
break; break;
case textsecure.protobuf.Envelope.Type.FRIEND_REQUEST: case textsecure.protobuf.Envelope.Type.FRIEND_REQUEST:
window.log.info('friend-request message from ', envelope.source); window.log.info('friend-request message from ', envelope.source);
const fallBackSessionCipher = new libloki.FallBackSessionCipher( const fallBackSessionCipher = new libloki.FallBackSessionCipher(
address address
); );
promise = fallBackSessionCipher.decrypt(ciphertext.toArrayBuffer()); promise = fallBackSessionCipher.decrypt(ciphertext.toArrayBuffer())
.then(this.unpad);
break; break;
case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE: case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE:
window.log.info('prekey message from', this.getEnvelopeId(envelope)); window.log.info('prekey message from', this.getEnvelopeId(envelope));
@ -826,7 +826,6 @@ MessageReceiver.prototype.extend({
}, },
async decryptPreKeyWhisperMessage(ciphertext, sessionCipher, address) { async decryptPreKeyWhisperMessage(ciphertext, sessionCipher, address) {
const padded = await sessionCipher.decryptPreKeyWhisperMessage(ciphertext); const padded = await sessionCipher.decryptPreKeyWhisperMessage(ciphertext);
return padded;
try { try {
return this.unpad(padded); return this.unpad(padded);

@ -207,13 +207,11 @@ OutgoingMessage.prototype = {
getPlaintext() { getPlaintext() {
if (!this.plaintext) { if (!this.plaintext) {
const messageBuffer = this.message.toArrayBuffer(); const messageBuffer = this.message.toArrayBuffer();
this.plaintext = new Uint8Array(messageBuffer.byteLength); this.plaintext = new Uint8Array(
// TODO: figure out why we needed padding in the first place this.getPaddedMessageLength(messageBuffer.byteLength + 1) - 1
// this.plaintext = new Uint8Array( );
// this.getPaddedMessageLength(messageBuffer.byteLength + 1) - 1
// );
this.plaintext.set(new Uint8Array(messageBuffer)); this.plaintext.set(new Uint8Array(messageBuffer));
// this.plaintext[messageBuffer.byteLength] = 0x80; this.plaintext[messageBuffer.byteLength] = 0x80;
} }
return this.plaintext; return this.plaintext;
}, },

Loading…
Cancel
Save