Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Fix key slice.
Browse files Browse the repository at this point in the history
  • Loading branch information
jq-rs committed Apr 4, 2023
1 parent bd6f575 commit 2b1dfbe
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions js/webworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ function processBd(channel, uid, msgtype, timestamp, message) {
if(BDDEBUG)
console.log("!!! bd invalidated in short message !!!");
initBd(channel, myuid);

}

let pub = buf2bn(StringToUint8(message.substring(0, DH_BITS/8)));
Expand Down Expand Up @@ -357,7 +356,7 @@ function processBd(channel, uid, msgtype, timestamp, message) {
gBdDb[channel][myuid] = gMyDhKey[channel].bd;
}

if (message.length == 2 * (DH_BITS/8) || (message.length == DH_BITS/8 && msgtype & MSGISBDONE)) {
if (message.length == 2 * (DH_BITS/8) || (message.length == DH_BITS/8 && (msgtype & MSGISBDONE))) {
let bd = BigInt(1);
let init = false;
let len = 0;
Expand Down Expand Up @@ -450,8 +449,8 @@ function processBd(channel, uid, msgtype, timestamp, message) {
//ack received from everyone else?
//console.log("Ackcnt " + ackcnt + " pubcnt " + pubcnt + " bdcnt " + bdcnt);
if (pubcnt == bdcnt && ackcnt == pubcnt &&
(message.length == DH_BITS/8 && msgtype & MSGISBDACK && msgtype & MSGISBDONE && pubcnt == 2 ||
message.length == 2 * (DH_BITS/8) && msgtype & MSGISBDACK && pubcnt > 2)) {
(message.length == DH_BITS/8 && (msgtype & MSGISBDACK) && (msgtype & MSGISBDONE) && pubcnt == 2 ||
message.length == 2 * (DH_BITS/8) && (msgtype & MSGISBDACK) && pubcnt > 2)) {

//console.log("Ack count matches to pub&bdcnt, enabling send encryption!");
gMyDhKey[channel].secretAcked = true;
Expand Down Expand Up @@ -552,8 +551,8 @@ function processOnMessageData(channel, msg) {
let karray = crypt.split64by32(keysizestr);
let keysz = unscatterU16(karray[0], karray[1]);

//let padsz = decrypted.length - msgsz - keysz;
//console.log("RX: Msgsize " + msgsz + " Keysz " + keysz + " Pad size " + padsz);
//let padsz = decompressed.length - msgsz - keysz;
//console.log("RX: Len " + decompressed.length + " Msgsize " + msgsz + " Keysz " + keysz + " Pad size " + padsz);

let timestring = decompressed.slice(16, 24);
let rarray = crypt.split64by32(timestring);
Expand Down Expand Up @@ -590,7 +589,7 @@ function processOnMessageData(channel, msg) {
msgtype |= MSGISBDACK;

if(keysz > 0) {
const keystr = decrypted.slice(msgsz, msgsz+keysz);
const keystr = decompressed.slice(msgsz, msgsz+keysz);
msgtype = processBd(channel, uid, msgtype, msgDate.valueOf(), keystr);
}

Expand Down Expand Up @@ -1128,7 +1127,7 @@ onmessage = function (e) {
const msglen = newmessage.length;
//padmé padding
const padsz = padme(msglen + padlen) - msglen;
//console.log("TX: Total msgsize " + (msglen + padsz) + " Msglen " + msglen + " padding sz " + padsz + " keysz " + keysz)
//console.log("TX: Total msgsize " + (msglen + padsz) + " Msglen " + msglen + " padlen " + padlen + " padding sz " + padsz + " keysz " + keysz)
if(padsz > 0) {
newmessage += Uint8ToString(randBytesSync(padsz));
}
Expand Down

0 comments on commit 2b1dfbe

Please sign in to comment.