Skip to content

ArtiomSu/DynamiCrypt

Repository files navigation

DynamiCrypt

This project uses tree parity machines to generate keys dynamically to use with AES encryption.

This repo contains an API that allows data to be encrypted and decrypted dynamically. A sync server that manages the tree parity machines. An example NodeJS App that consumes the API and provides a basic messaging app like interface. Finally some python scripts that interact with the NodeJs app so you dont have to fill in the forms manually.

To execute the API and the sync server run the following (API and sync server are part of the same proccess)
cd into DynamiCrypt/DynamiCrypt and sure you can see all .cpp files when you ls
g++ *.cpp -lboost_system -lpthread -lboost_thread -lboost_program_options -lcryptopp -lpistache -o DynamiCrypt

If there are errors while compiling please install boost libraries and Pistache
https://www.boost.org/
https://github.com/oktal/pistache


Also when syncing the sync server will spawn a gnome-terminal instance to write info about the keys received.
If you dont have gnome-terminal installed you can edit the source code to use whichever terminal you want or you can tell DynamiCrypt to write everything into one terminal by adding.
--PRINT_KEYS_TO_EXTERNAL_GNOME_TERMINAL 0
like so:
./DynamiCrypt --listen-port 8001 --api-port 9081 --PRINT_KEYS_TO_EXTERNAL_GNOME_TERMINAL 0
For more toggle switches and options you can type in:
./DynamiCrypt --help
or simply ./DynamiCrypt will print the same help message since it needs the listen-port and api-port to start executing.

Then once there are no errors or warnings after compiling open up two terminals in the same directory where you compiled the binary. In the first terminal execute:
./DynamiCrypt --listen-port 8001 --api-port 9081
And in the second terminal execute:
./DynamiCrypt --listen-port 8002 --api-port 9082

if there are issues with starting you have something running on the ports specified so just change them to what you like.

Next the NodeJs apps will need to be started up.
cd into DynamiCrypt/NodeApp/
run:
npm install
To install all the node modules

open up two terminals again
In the first terminal execute:
./run 3000
And in the second terminal execute:
./run 4000

This will execute two nodejs apps one on port 3000 and the other on port 4000.
You can open up the web-browser to see the apps
http://127.0.0.1:3000/
http://127.0.0.1:4000/

Now you can either fill out the forms manually to register the node apps with the apis or you can use my python script quick_setup.py which will fill out the forms you need for setup.
If using script make sure that the ports and ips are correct inside the script. The default ones provided should work if you used the same ports as I specified above.


If you decide to fill them out manually you can do the following
In the browser at http://127.0.0.1:3000/
you can fill out the form providing any service name you want
The API port will be 9081 if you are following the same setup.
And the API address will be local host you can put in 127.0.0.1

In the browser at http://127.0.0.1:4000/ fill out the same form
you can fill out the form providing any service name you want
The API port will be 9082 if you are following the same setup.
And the API address will be local host you can put in 127.0.0.1

The next form you only need to fill out in one of the browser windows as it will send the needed info to the other NodeJs app regardless.
So lets use the window pointing at http://127.0.0.1:3000/
This will ask for the info of the nodeJS app that is running on port 4000
For port fill in 4000
for address fill in 127.0.0.1

Now you should see a send message box in both of the browsers. At this time the tree parity machines did not begin syncronising to start sync press the green start sync button at the top of one of the browsers it should be visible in the browser accessing port 3000. Now the tree parity machines will begin to syncronise and you will see varius output displayed in the first two terminals. You will also see two other terminals spawn and display keys aswell as the time it took to obtain the key.

You can type and send messages by typing into the message box. You will see your message in plaintext and encrypted form in both of the browser windows.
You can send messages automatically by using another script called send_messages.py.
Again make sure to change the variables in the script to suit your setup. The script is handy for testing different ecryption options i.e. fast or secure.

Demo

Demo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published