diff options
author | Oliver Hunt <oliver.huntuk@gmail.com> | 2013-07-21 09:50:36 +0100 |
---|---|---|
committer | Oliver Hunt <oliver.huntuk@gmail.com> | 2013-07-21 09:50:36 +0100 |
commit | 0ec04a92afa28028d9935f6a0a51fe4592ef790d (patch) | |
tree | 56609103065045b3b06400b7f3e8eb88bbb0a8bf /docs/Crypto.txt | |
parent | 4f4e41f2eb7812678523060526292798be1c6e59 (diff) |
Removed docs, all are now in the wiki
Diffstat (limited to 'docs/Crypto.txt')
-rw-r--r-- | docs/Crypto.txt | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/docs/Crypto.txt b/docs/Crypto.txt deleted file mode 100644 index d53c16a8..00000000 --- a/docs/Crypto.txt +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
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 her 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 bytes)][Random nonce (24 bytes)][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 24 bytes)) 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 generate a new keypair which will only be used for the current connection (The session keys). | ||
44 | They then send themselves the following packet (the crypto handshake) (encrypted part encrypted with the public nonce in the packet | ||
45 | the public key of the receiver and private key of the sender) | ||
46 | [char with a value of 02][Senders Public key (client_id) (32 bytes)][Random nonce (24 bytes)][Encrypted message containing: [random 24 bytes base nonce][session public key of the peer (32 bytes)]] | ||
47 | |||
48 | If the packet is decrypted successfully: | ||
49 | Each start using the secret nonce, the public key provided by the other and their own session private key to encrypt data packets (adding to it + 1 for each packet.) | ||
50 | Each node sends themselves an empty data packet (data packet with 4 encrypted zero bytes) | ||
51 | Data packet: | ||
52 | [char with a value of 03][Encrypted data] | ||
53 | 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...) | ||
54 | along with the private session key of the receiver. | ||
55 | Every data packet sent is encrypted using the secret nonce we received (with +1 added for the first packet +2 for the second, etc...), | ||
56 | the session public key of the receiver and the session private key of the sender. | ||
57 | |||
58 | The encrypted connection is only deemed successful when the empty data packet is received and decrypted successfully. | ||