diff options
Diffstat (limited to 'src/encryption.h')
| -rw-r--r-- | src/encryption.h | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/encryption.h b/src/encryption.h index 1f04dae..b5fe04e 100644 --- a/src/encryption.h +++ b/src/encryption.h | |||
| @@ -3,9 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | #include <sodium.h> | 4 | #include <sodium.h> |
| 5 | 5 | ||
| 6 | #define CHUNKSIZE (1 << 9) | ||
| 7 | |||
| 8 | |||
| 9 | // Determines whether any function that calls libsodium functions also checks to make sure libsodium is actually initialized. May | 6 | // Determines whether any function that calls libsodium functions also checks to make sure libsodium is actually initialized. May |
| 10 | // cause unexpected issues with early exiting due to libsodium failing to initialize properly. It's recommended that you just | 7 | // cause unexpected issues with early exiting due to libsodium failing to initialize properly. It's recommended that you just |
| 11 | // manually run `sodium_init()` in some main or init function of your own so that you can deal with a potential error yourself | 8 | // manually run `sodium_init()` in some main or init function of your own so that you can deal with a potential error yourself |
| @@ -16,10 +13,7 @@ | |||
| 16 | #define ___VXGG___USE_CLS_CALLBACK___ 1 | 13 | #define ___VXGG___USE_CLS_CALLBACK___ 1 |
| 17 | 14 | ||
| 18 | 15 | ||
| 19 | |||
| 20 | |||
| 21 | #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 | 16 | #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 |
| 22 | |||
| 23 | // Checks if sodium is initialized. Initializes it if not. If `___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0`, it's possible to set an error callback to avoid exiting the entire program. Otherwise calls `error()` if libsodium can't initialize | 17 | // Checks if sodium is initialized. Initializes it if not. If `___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0`, it's possible to set an error callback to avoid exiting the entire program. Otherwise calls `error()` if libsodium can't initialize |
| 24 | void checksodium(void); | 18 | void checksodium(void); |
| 25 | 19 | ||
| @@ -30,14 +24,17 @@ typedef void (*vxgg_naclfailcb)(void*); | |||
| 30 | // Sets the error callback for when libsodium fails. Runs `cb(data)` if `(sodium_init() < 0)` | 24 | // Sets the error callback for when libsodium fails. Runs `cb(data)` if `(sodium_init() < 0)` |
| 31 | void vxgg_setsodiumfailcb(const vxgg_naclfailcb cb, void *data); | 25 | void vxgg_setsodiumfailcb(const vxgg_naclfailcb cb, void *data); |
| 32 | #endif | 26 | #endif |
| 33 | |||
| 34 | #endif | 27 | #endif |
| 35 | 28 | ||
| 29 | // Chunk size for en/de-cryption. I originally wanted to use st_blksize from stat(), but given that those chunks may be of different | ||
| 30 | // sizes between computers / filesystems / architectures / files, it's easier to just have this be a consistent macro | ||
| 31 | #define CHUNKSIZE (1 << 9) | ||
| 32 | |||
| 36 | // Fuck reading from a file. Even if someone ran strings on the binary and got this they wouldn't be able to regenerate the key | 33 | // Fuck reading from a file. Even if someone ran strings on the binary and got this they wouldn't be able to regenerate the key |
| 37 | #define PASSWORD_WORDS (\ | 34 | #define PASSWORD_WORDS (\ |
| 38 | (const char *[]){\ | 35 | (const char *[]){\ |
| 39 | "the", "of", "to", "and", "for", "our", "their", "has", "in", "he", "a", "them", "that", "these", "by", "have", "we", "us",\ | 36 | "the", "of", "to", "and", "for", "our", "their", "has", "in", "he", "a", "them", "that", "these", "by", "have", "we", \ |
| 40 | "people", "which", "all", "is", "with", "laws", "be", "are", "his", "states", "on", "they", "right", "it", "from", \ | 37 | "us", "people", "which", "all", "is", "with", "laws", "be", "are", "his", "states", "on", "they", "right", "it", "from", \ |
| 41 | "government", "such", "among", "powers", "most", "an", "time", "should", "new", "as", "been", "colonies", "assent", \ | 38 | "government", "such", "among", "powers", "most", "an", "time", "should", "new", "as", "been", "colonies", "assent", \ |
| 42 | "large", "at", "independent", "free", "united", "when", "mankind", "hold", "rights", "governments", "consent", "its", \ | 39 | "large", "at", "independent", "free", "united", "when", "mankind", "hold", "rights", "governments", "consent", "its", \ |
| 43 | "long", "themselves", "abolishing", "usurpations", "absolute", "repeated", "this", "world", "refused", "pass", "other", \ | 40 | "long", "themselves", "abolishing", "usurpations", "absolute", "repeated", "this", "world", "refused", "pass", "other", \ |
| @@ -96,6 +93,9 @@ int maketmp(const char * const dest); | |||
| 96 | int encrypttofile(FILE *dst, FILE *src, unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | 93 | int encrypttofile(FILE *dst, FILE *src, unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); |
| 97 | int decrypttofile(FILE *dst, FILE *src, unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | 94 | int decrypttofile(FILE *dst, FILE *src, unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); |
| 98 | 95 | ||
| 99 | int encrypttotmp(const char * const target, const char * const output, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | 96 | int encryptviatmp(const char * const target, const char * const output, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); |
| 97 | int decryptto(const char * const encrypted, const char * const target, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | ||
| 98 | |||
| 99 | int genpassword(char **str, unsigned int words); | ||
| 100 | 100 | ||
| 101 | #endif \ No newline at end of file | 101 | #endif \ No newline at end of file |
