diff options
author | Maxim Biro <nurupo.contributions@gmail.com> | 2020-03-23 20:28:19 -0400 |
---|---|---|
committer | Maxim Biro <nurupo.contributions@gmail.com> | 2020-04-04 16:38:28 -0400 |
commit | 40dd88596eda0eea5df67e747e93baf65cab2cbf (patch) | |
tree | a7cc328aafeaa9b43068e5d7d6fd094919e2c2c6 | |
parent | 4b73607b6f1bbe858000c0665b5eeb7e1d60e7cf (diff) |
Add minimal save generator
-rw-r--r-- | INSTALL.md | 16 | ||||
-rw-r--r-- | other/fun/BUILD.bazel | 8 | ||||
-rw-r--r-- | other/fun/minimal-save-generator.c | 62 |
3 files changed, 79 insertions, 7 deletions
@@ -45,13 +45,15 @@ This repository, although called `toxcore`, in fact contains several libraries b | |||
45 | 45 | ||
46 | There are some programs that are not plugged into the CMake build system which you might find interesting. You would need to build those programs yourself. These programs reside in [`other/fun`](other/fun) directory. | 46 | There are some programs that are not plugged into the CMake build system which you might find interesting. You would need to build those programs yourself. These programs reside in [`other/fun`](other/fun) directory. |
47 | 47 | ||
48 | | Name | Type | Dependencies | Platform | Description | | 48 | | Name | Type | Dependencies | Platform | Description | |
49 | |-----------------------|------------|----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 49 | |--------------------------|------------|----------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
50 | | `bootstrap_node_info` | Script | python3 | Cross-platform | Script for getting version and Message Of The Day (MOTD) information from a DHT bootstrap node. | | 50 | | `bootstrap_node_info` | Script | python3 | Cross-platform | Prints version and Message Of The Day (MOTD) information of a specified DHT bootstrap node. | |
51 | | `cracker` | Executable | libnacl or libsodium | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which starts with the specified byte sequence. | | 51 | | `cracker` | Executable | libnacl or libsodium | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which starts with a specified byte sequence. | |
52 | | `strkey` | Executable | libsodium | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which contains a specified byte pattern at the specified position or at any position. | | 52 | | `make-funny-savefile` | Script | python | Cross-platform | Generates a Tox profile file (savedata file) with the provided key pair. Useful for generating Tox profiles from the output of cracker or strkey programs. | |
53 | | `make-funny-savefile` | Script | python | Cross-platform | Generates Tox profile file (savedata file) with provided key pair. Useful for generating Tox profiles from the output of cracker or strkey programs. | | 53 | | `minimal-save-generator` | Executable | libsodium | Cross-platform | Generates a minimal Tox profile file (savedata file) with a random key pair. | |
54 | | `sign` | Executable | libsodium | Cross-platform | Program for ed25519 file signing. | | 54 | | `save-generator` | Executable | libtoxcore | Cross-platform | Generates a Tox profile file (savedata file) with a random key pair using libtoxcore. Allows setting a name and adding friends. | |
55 | | `sign` | Executable | libsodium | Cross-platform | Signs a file with a ed25519 key. | | ||
56 | | `strkey` | Executable | libsodium | Cross-platform | Tries to find a curve25519 key pair, hex representation of the public key of which contains a specified byte pattern at a specified position or at any position. | | ||
55 | 57 | ||
56 | ## Building | 58 | ## Building |
57 | 59 | ||
diff --git a/other/fun/BUILD.bazel b/other/fun/BUILD.bazel index 584c2a83..ae4cfb2f 100644 --- a/other/fun/BUILD.bazel +++ b/other/fun/BUILD.bazel | |||
@@ -8,6 +8,14 @@ cc_binary( | |||
8 | "@libsodium", | 8 | "@libsodium", |
9 | ], | 9 | ], |
10 | ) | 10 | ) |
11 | cc_binary( | ||
12 | name = "minimal-save-generator", | ||
13 | srcs = ["minimal-save-generator.c"], | ||
14 | deps = [ | ||
15 | "@libsodium", | ||
16 | ], | ||
17 | ) | ||
18 | |||
11 | 19 | ||
12 | cc_binary( | 20 | cc_binary( |
13 | name = "sign", | 21 | name = "sign", |
diff --git a/other/fun/minimal-save-generator.c b/other/fun/minimal-save-generator.c new file mode 100644 index 00000000..b4833ea8 --- /dev/null +++ b/other/fun/minimal-save-generator.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* minimal-save-generator -- Minimal Save Generator | ||
2 | * | ||
3 | * Generates a minimal Tox savedata file that can be used in clients. | ||
4 | * Prints the savedata file to stderr, prints information to stdout. | ||
5 | * | ||
6 | * Requires sodium library. | ||
7 | * | ||
8 | * Usage: minimal-save-generator 2> profile.tox | ||
9 | * | ||
10 | * Compile: gcc minimal-save-generator.c -o minimal-save-generator -lsodium | ||
11 | */ | ||
12 | |||
13 | #include <stdio.h> | ||
14 | #include <string.h> | ||
15 | #include <ctype.h> | ||
16 | |||
17 | #include <sodium.h> | ||
18 | |||
19 | int main(void) | ||
20 | { | ||
21 | unsigned char public_key[crypto_box_PUBLICKEYBYTES]; | ||
22 | unsigned char secret_key[crypto_box_SECRETKEYBYTES]; | ||
23 | crypto_box_keypair(public_key, secret_key); | ||
24 | |||
25 | // print new tox savedata to stderr | ||
26 | char tox_file[] = "\x00\x00\x00\x00\x1f\x1b\xed\x15\x44\x00\x00\x00\x01\x00\xce\x01\x00\x00\x00\x00"; | ||
27 | fwrite(tox_file, sizeof(tox_file) - 1, 1, stderr); | ||
28 | fwrite(public_key, sizeof(public_key), 1, stderr); | ||
29 | fwrite(secret_key, sizeof(secret_key), 1, stderr); | ||
30 | |||
31 | // print info on it to stdout | ||
32 | char public_key_str[crypto_box_PUBLICKEYBYTES * 2 + 1]; | ||
33 | char secret_key_str[crypto_box_SECRETKEYBYTES * 2 + 1]; | ||
34 | sodium_bin2hex(public_key_str, sizeof(public_key_str), public_key, sizeof(public_key)); | ||
35 | sodium_bin2hex(secret_key_str, sizeof(secret_key_str), secret_key, sizeof(secret_key)); | ||
36 | |||
37 | for (size_t i = 0; i < sizeof(public_key_str); i ++) { | ||
38 | public_key_str[i] = toupper(public_key_str[i]); | ||
39 | secret_key_str[i] = toupper(secret_key_str[i]); | ||
40 | } | ||
41 | |||
42 | fprintf(stdout, "Public key: %s\n", public_key_str); | ||
43 | fprintf(stdout, "Secret key: %s\n", secret_key_str); | ||
44 | |||
45 | // calculate checksum for tox id printing | ||
46 | unsigned char checksum[2] = {0}; | ||
47 | |||
48 | for (size_t i = 0; i < crypto_box_PUBLICKEYBYTES; i ++) { | ||
49 | checksum[i % 2] ^= public_key[i]; | ||
50 | } | ||
51 | |||
52 | char checksum_str[sizeof(checksum) * 2 + 1]; | ||
53 | sodium_bin2hex(checksum_str, sizeof(checksum_str), checksum, sizeof(checksum)); | ||
54 | |||
55 | for (size_t i = 0; i < sizeof(checksum_str); i ++) { | ||
56 | checksum_str[i] = toupper(checksum_str[i]); | ||
57 | } | ||
58 | |||
59 | fprintf(stdout, "Tox Id: %s00000000%s\n", public_key_str, checksum_str); | ||
60 | |||
61 | return 0; | ||
62 | } | ||