Draft proposal of how crypto will be implemented added. TODO updated.

This commit is contained in:
irungentoo 2013-07-02 15:28:59 -04:00
parent e2967396ac
commit e1acd327ed
2 changed files with 54 additions and 0 deletions

52
docs/Crypto.txt Normal file
View File

@ -0,0 +1,52 @@
Draft proposal for how crypto will be implemented.
Encryption library used: http://nacl.cr.yp.to/
When running the program for the first time the crypto_box_keypair() function is used to
generate the users public-private key pair. (32 bytes each)
The generated public key is set as the client_id of the peer.
Adding a friend:
Alice adds bob to her friends list by adding his 32 byte public key (client_id) to his friends list.
2 cases:
case 1: Alice adds Bobs public key and bob waits for Alice to attempt to connect to him.
case 2: Bob and Alice add their respective public keys to their friends list at the same time.
case 1:
Alice connects to Bob and sends a data packet (friends request) like so:
[char with a value of 01][Alice's Public key (client_id) (32 bits)][Random nonce (24 bits)][Encrypted message]
Where the encrypted message is encrypted with crypto_box() (using Bobs public key, Alice's private key
and the nonce (randomly generated 24bits)) and is a message from Alice in which she tells Bob who she is.
Ex: hello bob it's me alice -_- add me pl0x.
Bob receives the request and decrypts the message using the function crypto_box_open()
If the message decrypts successfully:
If Alice is already in Bobs friends list: case 2
If Alice is not in Bob's friends list: Bob is prompt to add Alice and is shown the message from her.
If Bobs accepts Alice's friends request he adds her public key to his friends list.
case 2:
Bob and Alice both have the others public key in their friends list, they are ready for the next step: Connecting to an already added friend
In the next step.
only crypto_box() is used for encryption and only crypto_box_open() for decryption (just like in the last step.)
Connecting to an already added friend:
Alice and Bob are friends.
As soon as they connect they each send themselves the following packet (encrypted part encrypted with the public nonce in the packet
the public key of the receiver and private key of the sender)
[char with a value of 02][Random nonce (24 bits)][Encrypted message containing a random 24 bit base nonce]
If the packet is decrypted successfully:
Each start using the secret nonce provided by the other to encrypt data packets (adding to it + 1 for each packet.)
Data packet:
[char with a value of 03][Encrypted data]
Each data packet received it is decrypted using the secret nonce sent to the other(with +1 added for the first packet +2 for the second, etc...)
Every data packet sent is encrypted using the secret nonce we received (with +1 added for the first packet +2 for the second, etc...)
The encrypted connection is only deemed successful when a data packet is received and decrypted successfully.

View File

@ -13,6 +13,8 @@ Things to do now:
-Find some good encryption libraries.(Done)
we will use: http://nacl.cr.yp.to/
-Add NaCl to our build system.
-Find and fix bugs in the code.
Things to do later: