diff options
Diffstat (limited to 'src/encryption.h')
| -rw-r--r-- | src/encryption.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/encryption.h b/src/encryption.h index 675ef18..2c8f976 100644 --- a/src/encryption.h +++ b/src/encryption.h | |||
| @@ -1,6 +1,21 @@ | |||
| 1 | #ifndef __VXGG_REWRITE___ENCRYPTION_H___1481879318188___ | 1 | #ifndef __VXGG_REWRITE___ENCRYPTION_H___1481879318188___ |
| 2 | #define __VXGG_REWRITE___ENCRYPTION_H___1481879318188___ | 2 | #define __VXGG_REWRITE___ENCRYPTION_H___1481879318188___ |
| 3 | 3 | ||
| 4 | // Determines whether any function that calls libsodium functions also checks to make sure libsodium is actually initialized. May | ||
| 5 | // cause unexpected issues with early exiting due to libsodium failing to initialize properly. It's recommended that you just | ||
| 6 | // manually run `sodium_init()` in some main or init function of your own so that you can deal with a potential error yourself | ||
| 7 | #define ___VXGG___ALWAYS_CHECK_LIBSODIUM___ 1 | ||
| 8 | |||
| 9 | #if defined ___VXGG___ALWAYS_CHECK_LIBSODIUM___ && ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 | ||
| 10 | |||
| 11 | // Definition for the callback function that fires when a call to checksodium fails | ||
| 12 | typedef void (*vxgg_naclfailcb)(void*); | ||
| 13 | |||
| 14 | // Sets the error callback for when libsodium fails. Runs `cb(data)` if `(sodium_init() < 0)` | ||
| 15 | void vxgg_setsodiumfailcb(const vxgg_naclfailcb cb, void *data); | ||
| 16 | |||
| 17 | #endif | ||
| 18 | |||
| 4 | // I need to store a dictionary of valid words for generating a password, and I don't want to read it in from another file, so I'm experimenting with this | 19 | // I need to store a dictionary of valid words for generating a password, and I don't want to read it in from another file, so I'm experimenting with this |
| 5 | #define PASSWORD_WORDS (\ | 20 | #define PASSWORD_WORDS (\ |
| 6 | (const char *[]){\ | 21 | (const char *[]){\ |
| @@ -56,9 +71,10 @@ | |||
| 56 | "reliance", "divine", "providence", "mutually", "pledge", "each", "fortunes", "sacred", "honor"\ | 71 | "reliance", "divine", "providence", "mutually", "pledge", "each", "fortunes", "sacred", "honor"\ |
| 57 | }\ | 72 | }\ |
| 58 | ) | 73 | ) |
| 74 | #define PASSWORD_WORDS_LEN (STATICARR_SIZE(PASSWORD_WORDS)) | ||
| 59 | 75 | ||
| 60 | // Checks if sodium is initialized. Initializes it if not | 76 | // 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 |
| 61 | int checkSodium(void); | 77 | void checksodium(void); |
| 62 | 78 | ||
| 63 | // open() with the flags O_TMPFILE, O_WRONLY, O_CLOEXEC, and O_SYNC. Opened with mode S_IRUSR, S_IWUSR | 79 | // open() with the flags O_TMPFILE, O_WRONLY, O_CLOEXEC, and O_SYNC. Opened with mode S_IRUSR, S_IWUSR |
| 64 | int maketmp(const char *dest); | 80 | int maketmp(const char *dest); |
