forked from Green-Sky/tomato
Green Sky
b2ae9530a4
f1df709b87 feat: add ngc events 1b6c907235 refactor: Make event dispatch ordered by receive time. b7f9367f6f test: Upgrade cppcheck, fix some warnings. 766e62bc89 chore: Use `pkg_search_module` directly in cmake. 00ff078f91 cleanup: Use target_link_libraries directly in cmake. c58928cc89 chore: Add `IMPORTED_TARGET` to pkg-config packages. 895a6af122 cleanup: Remove NaCl support. 41dfb1c1c0 fix: unpack enum function names in event impl generator 447666d1a1 chore: Disable targets for cross-compilation. 572924e924 chore: Build a docker image with coverage info in it. 415cb78f5e cleanup: Some portability/warning fixes for Windows builds. 425216d9ec fix: Correct a use-after-free and fix some memory leaks. 4b1cfa3e08 refactor: Change all enum-like `#define` sequences into enums. d3c2704fa9 chore: Fix make_single_file to support core-only. 0ce46b644e refactor: Change the `TCP_PACKET_*` defines into an enum. 22cd38ad50 adopt event impl generation tool to #2392 f31ea1088a add the event impl generation tool 4e603bb613 refactor: Use `enum-from-int` rule from tokstyle. 19d8f180d6 chore: Update github actions `uses`. 6a895be0c7 test: Make esp32 build actually try to instantiate tox. 65d09c9bfb cleanup: Remove test net support. REVERT: e29e185c03 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: f1df709b8792da4c0e946d826b11df77d565064d
55 lines
2.2 KiB
Markdown
55 lines
2.2 KiB
Markdown
Encryption library used: https://doc.libsodium.org/
|
|
|
|
|
|
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 friend list by adding his 32 byte public key (client_id) to her friend list.
|
|
2 cases:
|
|
case 1: Alice adds the public key of Bob, then Bob waits for Alice to attempt to connect to him.
|
|
case 2: Bob and Alice add their respective public keys to their friend lists at the same time.
|
|
|
|
case 1:
|
|
Alice sends an onion data (see: Prevent_tracking.txt) packet to Bob with the encrypted part containing the friend request like so:
|
|
```
|
|
[char with a value of 32][nospam number (4 bytes)][Message]
|
|
```
|
|
|
|
Ex message: hello Bob it's me Alice -_- add me pl0x.
|
|
|
|
For more info on the nospam see: Spam_Prevention.txt
|
|
|
|
Bob receives the request and decrypts the message using the function crypto_box_open()
|
|
|
|
If the message decrypts successfully:
|
|
If Alice is already in Bob's friend list: case 2
|
|
If Alice is not in Bob's friend list and the nospam is good: Bob is prompt to add Alice and is shown the message from her.
|
|
If Bob accepts Alice friend request he adds her public key to his friend list.
|
|
|
|
case 2:
|
|
Bob and Alice both have the others public key in their friend 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
|
|
-------------------------------------
|
|
|
|
see: Tox_middle_level_network_protocol.txt
|
|
|
|
Crypto request packets
|
|
--------------------------------------
|
|
|
|
```
|
|
[char with a value of 32][Bob (The receiver's) Public key (client_id) (32 bytes))][Alice's (The sender's) Public key (client_id) (32 bytes)][Random nonce (24 bytes)][Encrypted message]
|
|
```
|
|
|
|
The encrypted message is encrypted with crypto_box() (using Bob's public key, Alice's private key and the nonce (randomly generated 24 bytes)) and is a message from Alice in which she tells Bob who she is.
|
|
|
|
Each node can route the request to the receiver if they are connected to him. This is to bypass bad NATs.
|