diff options
| author | @syxhe <https://t.me/syxhe> | 2025-03-30 23:13:35 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-03-30 23:13:35 -0500 |
| commit | 833cb417608eb138d3a9b99dc995c5c1aeffd1cd (patch) | |
| tree | 9698c034adb7e5124e91ac79b8eb4d68b047a0f9 /src/encryption.h | |
| parent | 97713275dc87ea1d0afa4fd6bc49f695ad40efc0 (diff) | |
Create encryption functions that actually work
Diffstat (limited to 'src/encryption.h')
| -rw-r--r-- | src/encryption.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/encryption.h b/src/encryption.h index 418e7f6..1bdd2b9 100644 --- a/src/encryption.h +++ b/src/encryption.h | |||
| @@ -1,12 +1,14 @@ | |||
| 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 | #include <sodium.h> | ||
| 5 | |||
| 4 | // 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 |
| 5 | // 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 |
| 6 | // 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 |
| 7 | #define ___VXGG___ALWAYS_CHECK_LIBSODIUM___ 0 | 9 | #define ___VXGG___ALWAYS_CHECK_LIBSODIUM___ 0 |
| 8 | 10 | ||
| 9 | #define CHUNK_SIZE ((int)(1 << 12)) | 11 | #define CHUNKSIZE (1 << 9) |
| 10 | 12 | ||
| 11 | // TODO: What the fuck was I thinking when I did any of this callback shit? Make this a different macro and decouple it from ALWAYS_CHECK | 13 | // TODO: What the fuck was I thinking when I did any of this callback shit? Make this a different macro and decouple it from ALWAYS_CHECK |
| 12 | #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 | 14 | #if ___VXGG___ALWAYS_CHECK_LIBSODIUM___ > 0 |
| @@ -82,4 +84,9 @@ void checksodium(void); | |||
| 82 | // open() with the flags O_TMPFILE, O_WRONLY, O_CLOEXEC, and O_SYNC. Opened with mode S_IRUSR, S_IWUSR | 84 | // open() with the flags O_TMPFILE, O_WRONLY, O_CLOEXEC, and O_SYNC. Opened with mode S_IRUSR, S_IWUSR |
| 83 | int maketmp(const char * const dest); | 85 | int maketmp(const char * const dest); |
| 84 | 86 | ||
| 87 | int encrypttofile(FILE *dst, FILE *src, unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | ||
| 88 | int decrypttofile(FILE *dst, FILE *src, unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | ||
| 89 | |||
| 90 | int encrypttotmp(const char * const target, const char * const output, const unsigned char key[crypto_secretstream_xchacha20poly1305_KEYBYTES]); | ||
| 91 | |||
| 85 | #endif \ No newline at end of file | 92 | #endif \ No newline at end of file |
