phutchins / pipo

Secure end to end client side encryption chat
GNU Affero General Public License v3.0
50 stars 11 forks source link

PiPo - A secure chat client with client side encryption written in NodeJS

Goal

PiPo's goal is to make secure communication easy to use and open source. It is a client server appilcation that aims to remove the server from being a vulnerable point in the communication chain.

Features

Encryption

Currently PiPo uses the KbPGP library to do PGP encryption. Behind this is AES-256 with 4096 bit keys.

Data Flow

Uploading Files

The following is the the process in which a file traverses when being sent from the client to the server and then is retrieved.

// Upload a whole chunk which is ( currentChunk * chunkSize )
if (currentChunk < wholeChunks) {
  start = ( currentChunk * chunkSize );
  end = (( currentChunk  + 1 ) * chunkSize );
}

// If this is the last chunk, set final bytes
// to ( currentChunk * chunkSize ) + finalChunk
if (currentChunk === wholeChunks) {
  start = ( currentChunk * chunkSize );
  end = ( currentChunk * chunkSize ) + finalChunk;
}

var blob = file.slice(start,end);
reader.readAsArrayBuffer(blob);
currentChunk++;

while (currentChunk <= wholeChunks) {
  ...
  reader.onloadend = (function(chunkNum) {
    return function(evt) {
      if (evt.target.readyState == FileReader.DONE) {
        self.sendFile({
          fileChunkArrayBuffer: evt.target.result,
          ...
        }, function...
// fileManager.js
window.encryptionManager.encryptFile({
  file: fileChunkArrayBuffer,
  ...

// encryptionManager.js
var fileArrayBuffer = data.file;
var fileBuffer = new kbpgp.Buffer(fileArrayBuffer);
window.kbpgp.box({
  msg: fileBuffer,
  encrypt_for: keys,
  sign_with: self.keyManager
}, function(err, resultString, resultBuffer) {
    callback(err, resultBuffer);
});
var binStream = binSocketClient.binSocket.send(encryptedChunkBuffer, {
  fileName: fileName,
  ...
});

binStream.end();
fs.writeFile("files/" + pfileChunkName, fileBuffer, { encoding: 'binary' }, function(err) {
  ...

Downloading Files

Screenshots

User1 User2

How it works...

When a user signs up with their username, email address and password, an AES-256 keypair is generated within their browser. The public part of that keypair is then uploaded to the server and associated with that username. From here, access is granted to private rooms by an admin. The addition of this user is signed in a transaction that can then be verified by all clients back to one of the original two administrators. This removes the possibliity of a malitious attacker injecting their public key onto a compromised server and tricking users into sending them messages thinking they are someone else.

Requirements

Quick Setup (Dev/Test)

To try out PiPo, I've included a sample adminCertificate. You should not use these for production as you do not have the private keys associated with these admin certificates.

Setup

Testing

Framework

Front End Testing

We're still working through gathering the proper toolset to do frontend testing. Here are the pieces we are considering.

Links

Statically compile pug templates

Running

npm test

Protocol Outline & Planning Considerations

Authentication

Sessions

Server Management of Keys

Mobile

Desktop & Browser

Problem & Solution Walkthrough

UX Flow

MVP Feature List