Skip to content

Quick Start Guide

p4nd4ta edited this page Feb 4, 2021 · 1 revision

Chat in Action

App in Action

Backend Database with the encrypted messages, unreadable for nobody, except the user that they are meant for

Database "Messages" Table

Way of working

  1. After you register, click on Encryption Keys /Keys

  2. Then click on Add New Key

/Keys/Create 3. You can either generate an RSA Key pair using OpenSSL or the JSEncrypt Key Generator.

Via OpenSSL

In Git Bash, change to your desired directory and type:

To generate private key: openssl genrsa -out rsa_2048_priv.pem 2048

To generate public key: openssl rsa -pubout -in rsa_2048_priv.pem -out rsa_2048_pub.pem

Paste the Public Key (the Private Key textbox is readonly and is not inside the <form> tag) and click on Add Public Key to submit the form.

Via JSEncrypt

Click on Generate Key Pair, to call the JSEncrypt script which will generate a pair for you. Make sure you copy and save your private key, and click on Add Public Key to submit the form (the Private Key textbox is readonly and is not inside the <form> tag).

About RSA key Sizes

By default we are using 2048 bit RSA keys. I have hardcoded the JSEncrypt generator on 2048 bits. To generate a longer key, use OpenSSL. Though, there is a hardcoded constant in the backend and the frontend script, which checks the length of the message, because a 2048 bit key can encryot only 245 chars with its modulus. So you need to change that if you are going to use longer RSA keys:

Backend: ChatHub.cs on Lines 21 and 22
const int MESSAGE_PAYLOAD_LEN = 345; //With RSA 2048 bit key, the max base64 string is of length exactly 345(+ "%" sign for whisper traffic)
const int SIGNED_MESSAGE_PAYLOAD_LEN = 344; //With RSA 2048 bit key, the max base64 string of the SHA-256 hash is exactly 344 chars long
Frontend: chat.js on Line 6
const  MESSAGE_LENGTH  =  245;  // the max RSA encryption length for 2048 bit key Modulus, if the message is longer, the library would fail

/Keys with key

  1. After submitting your key, the page should look like this, then to use the chat, you can click on Chat

Private key prompt 5. You will be prompted for your private key. Copy and paste it. If it is wrong you will be prompted again.

To leave the page while being prompted, close the current tab in the web browser.

If the key supplied is correct, the decryption process will begin. It can take a while, depending on the key size you have chosen and your device and browser.

That's it, enjoy the app.