diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-02 15:28:59 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-02 15:28:59 -0400 |
commit | e1acd327ed31be920286b1b8c2a9a38f13f87cae (patch) | |
tree | 0243ecd4500cfcfbaf0460421c4a5ef60bc134b3 /docs/Crypto.txt | |
parent | e2967396ac73cb7410787886cdaf072a184ffc49 (diff) |
Draft proposal of how crypto will be implemented added. TODO updated.
Diffstat (limited to 'docs/Crypto.txt')
-rw-r--r-- | docs/Crypto.txt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/docs/Crypto.txt b/docs/Crypto.txt new file mode 100644 index 00000000..97e39560 --- /dev/null +++ b/docs/Crypto.txt | |||
@@ -0,0 +1,52 @@ | |||
1 | Draft proposal for how crypto will be implemented. | ||
2 | |||
3 | |||
4 | Encryption library used: http://nacl.cr.yp.to/ | ||
5 | |||
6 | |||
7 | When running the program for the first time the crypto_box_keypair() function is used to | ||
8 | generate the users public-private key pair. (32 bytes each) | ||
9 | |||
10 | The generated public key is set as the client_id of the peer. | ||
11 | |||
12 | Adding a friend: | ||
13 | Alice adds bob to her friends list by adding his 32 byte public key (client_id) to his friends list. | ||
14 | 2 cases: | ||
15 | case 1: Alice adds Bobs public key and bob waits for Alice to attempt to connect to him. | ||
16 | case 2: Bob and Alice add their respective public keys to their friends list at the same time. | ||
17 | |||
18 | case 1: | ||
19 | Alice connects to Bob and sends a data packet (friends request) like so: | ||
20 | [char with a value of 01][Alice's Public key (client_id) (32 bits)][Random nonce (24 bits)][Encrypted message] | ||
21 | |||
22 | Where the encrypted message is encrypted with crypto_box() (using Bobs public key, Alice's private key | ||
23 | and the nonce (randomly generated 24bits)) and is a message from Alice in which she tells Bob who she is. | ||
24 | Ex: hello bob it's me alice -_- add me pl0x. | ||
25 | |||
26 | Bob receives the request and decrypts the message using the function crypto_box_open() | ||
27 | |||
28 | If the message decrypts successfully: | ||
29 | If Alice is already in Bobs friends list: case 2 | ||
30 | If Alice is not in Bob's friends list: Bob is prompt to add Alice and is shown the message from her. | ||
31 | If Bobs accepts Alice's friends request he adds her public key to his friends list. | ||
32 | |||
33 | case 2: | ||
34 | 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 | ||
35 | |||
36 | |||
37 | In the next step. | ||
38 | only crypto_box() is used for encryption and only crypto_box_open() for decryption (just like in the last step.) | ||
39 | |||
40 | |||
41 | Connecting to an already added friend: | ||
42 | Alice and Bob are friends. | ||
43 | As soon as they connect they each send themselves the following packet (encrypted part encrypted with the public nonce in the packet | ||
44 | the public key of the receiver and private key of the sender) | ||
45 | [char with a value of 02][Random nonce (24 bits)][Encrypted message containing a random 24 bit base nonce] | ||
46 | If the packet is decrypted successfully: | ||
47 | Each start using the secret nonce provided by the other to encrypt data packets (adding to it + 1 for each packet.) | ||
48 | Data packet: | ||
49 | [char with a value of 03][Encrypted data] | ||
50 | 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...) | ||
51 | Every data packet sent is encrypted using the secret nonce we received (with +1 added for the first packet +2 for the second, etc...) | ||
52 | The encrypted connection is only deemed successful when a data packet is received and decrypted successfully. | ||