dogzy123 / denisbook

An open social network on node js. People need it since all others are bad.
2 stars 2 forks source link

Implement end-to-end private chat encryption #2

Open klesun opened 5 years ago

klesun commented 5 years ago
klesun commented 5 years ago

Update: it appears immanuel.co has a limit on the url size of 288 characters. So base64-ed email and publicKey may not exceed 226 characters. Since we don't posses the techonogy to compress anything into 36 bytes via a black hole, we'll have to think of a workaround.

What we will do - chunk the base64-ed public key into 2 urls: https://keyvalue.immanuel.co/api/KeyVal/UpdateValue/7p6a4g00/vasya@gmail.com_1/publickeyinbase64part1 and https://keyvalue.immanuel.co/api/KeyVal/UpdateValue/7p6a4g00/vasya@gmail.com_2/publickeyinbase64part2 If you pull you'll see that I tweaked CryptHelper.js a bit (https://github.com/dogzy123/denisbook/commit/f87a3e1b3ed1c32cb65568036251da0b17299084) so now public key consists of 210 bytes instead of 1024. After base64 it becomes 280 characters. You should split this string in half, so you get two 140-characters strings - store them in vasya@gmail.com_1 and vasya@gmail.com_2 keys respectively. Likewise when you fetch the key to encrypt the message on the other end or to check that it did not change - fetch these two strings from both urls and join them back.

Besides the key chunking, everything else stays same - let's stick to the plan described above.

P.S.: it would be nice if amount of chunks was actually configurable in case we ever decide that btoa(226 - 140) - _1 = 62 characters is too little for email. So that we could just change a constant from 2 to 4 and everything started working with public key being split into 4 chunks.

dogzy123 commented 5 years ago

@klesun the way we are now encrypting/decrypting messages works fine on Chrome, also, possibly will work fine on Firefox, but how it reacts on other browsers? (MS IE & MS Edge isn't working at all). Need to think about solution. (Or we just forget about all other browsers except Chrome :D)

klesun commented 5 years ago

In edge it does not work because of a bug in their engine, as I already mentioned before. I personally don't give a damn about this microsoft crap, so I would ignore this browser as you suggested.

Firefox should work, safari should too, at least MDN page says so.

Any other browsers don't exist.

klesun commented 5 years ago

Oh, lol: image image

dogzy123 commented 5 years ago

ahahah