30#if defined(_WIN32) && defined(PWCRYPT_DLL)
31#ifdef PWCRYPT_BUILD_DLL
32#define PWCRYPT_API __declspec(dllexport)
34#define PWCRYPT_API __declspec(dllimport)
54 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x00,
65 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x00, 0x00,
67 0x00, 0x00, 0x00, 0x00,
68 0x00, 0x00, 0x00, 0x00,
69 0x00, 0x00, 0x00, 0x00,
75#define PWCRYPT_VERSION 430
80#define PWCRYPT_VERSION_STR "4.3.0"
82#ifndef PWCRYPT_Z_CHUNKSIZE
86#define PWCRYPT_Z_CHUNKSIZE (1024 * 256)
89#ifndef PWCRYPT_ARGON2_T_COST
93#define PWCRYPT_ARGON2_T_COST 4
96#ifndef PWCRYPT_ARGON2_M_COST
100#define PWCRYPT_ARGON2_M_COST (1024 * 256)
103#ifndef PWCRYPT_ARGON2_PARALLELISM
107#define PWCRYPT_ARGON2_PARALLELISM 2
113#define PWCRYPT_ALGO_ID_AES256_GCM 0
118#define PWCRYPT_ALGO_ID_CHACHA20_POLY1305 1
120#ifndef PWCRYPT_FILE_BUFFER_SIZE
124#define PWCRYPT_FILE_BUFFER_SIZE (1024 * 256)
130#define PWCRYPT_ERROR_INVALID_ARGS (-1)
135#define PWCRYPT_ERROR_OOM 1000
140#define PWCRYPT_ERROR_PW_TOO_WEAK 2000
145#define PWCRYPT_ERROR_ARGON2_FAILURE 3000
150#define PWCRYPT_ERROR_ENCRYPTION_FAILURE 4000
156#define PWCRYPT_ERROR_DECRYPTION_FAILURE 5000
161#define PWCRYPT_ERROR_BASE64_FAILURE 6000
166#define PWCRYPT_ERROR_COMPRESSION_FAILURE 7000
171#define PWCRYPT_ERROR_DECOMPRESSION_FAILURE 8000
176#define PWCRYPT_ERROR_FILE_FAILURE 9000
181#define PWCRYPT_MIN(x, y) (((x) < (y)) ? (x) : (y))
186#define PWCRYPT_MAX(x, y) (((x) > (y)) ? (x) : (y))
188#ifndef PWCRYPT_MAX_WIN_FILEPATH_LENGTH
192#define PWCRYPT_MAX_WIN_FILEPATH_LENGTH (1024 * 32)
214extern int (*pwcrypt_fprintf_fptr)(FILE* stream,
const char* format, ...);
227#define pwcrypt_fprintf pwcrypt_fprintf_fptr
234PWCRYPT_API
void dev_urandom(uint8_t* output_buffer,
size_t output_buffer_size);
274PWCRYPT_API
int pwcrypt_encrypt(
const uint8_t* input,
size_t input_length, uint32_t compress,
const uint8_t* password,
size_t password_length, uint32_t argon2_cost_t, uint32_t argon2_cost_m, uint32_t argon2_parallelism, uint32_t algo, uint8_t** output,
size_t* output_length, uint32_t output_base64);
292PWCRYPT_API
int pwcrypt_encrypt_file(
const char* input_file_path,
size_t input_file_path_length, uint32_t compress,
const uint8_t* password,
size_t password_length, uint32_t argon2_cost_t, uint32_t argon2_cost_m, uint32_t argon2_parallelism, uint32_t algo,
const char* output_file_path,
size_t output_file_path_length);
310PWCRYPT_API
int pwcrypt_encrypt_file_raw(FILE* input_file, FILE* output_file, uint32_t compress,
const uint8_t* password,
size_t password_length, uint32_t argon2_cost_t, uint32_t argon2_cost_m, uint32_t argon2_parallelism, uint32_t algo, uint32_t close_input_file, uint32_t close_output_file);
322PWCRYPT_API
int pwcrypt_decrypt(
const uint8_t* encrypted_data,
size_t encrypted_data_length,
const uint8_t* password,
size_t password_length, uint8_t** output,
size_t* output_length);
334PWCRYPT_API
int pwcrypt_decrypt_file(
const char* input_file_path,
size_t input_file_path_length,
const uint8_t* password,
size_t password_length,
const char* output_file_path,
size_t output_file_path_length);
346PWCRYPT_API
int pwcrypt_decrypt_file_raw(FILE* input_file, FILE* output_file,
const uint8_t* password,
size_t password_length, uint32_t close_input_file, uint32_t close_output_file);
PWCRYPT_API int pwcrypt_decrypt(const uint8_t *encrypted_data, size_t encrypted_data_length, const uint8_t *password, size_t password_length, uint8_t **output, size_t *output_length)
static const uint8_t EMPTY64[64]
Definition pwcrypt.h:52
PWCRYPT_API uint32_t pwcrypt_get_argon2_version_nr()
PWCRYPT_API void pwcrypt_disable_fprintf()
PWCRYPT_API void pwcrypt_enable_fprintf()
PWCRYPT_API int pwcrypt_decrypt_file(const char *input_file_path, size_t input_file_path_length, const uint8_t *password, size_t password_length, const char *output_file_path, size_t output_file_path_length)
static int pwcrypt_printvoid(FILE *stream, const char *format,...)
Definition pwcrypt.h:208
PWCRYPT_API void pwcrypt_free(void *ptr)
PWCRYPT_API size_t pwcrypt_get_filesize(const char *filepath)
PWCRYPT_API int pwcrypt_decrypt_file_raw(FILE *input_file, FILE *output_file, const uint8_t *password, size_t password_length, uint32_t close_input_file, uint32_t close_output_file)
PWCRYPT_API int pwcrypt_encrypt_file_raw(FILE *input_file, FILE *output_file, uint32_t compress, const uint8_t *password, size_t password_length, uint32_t argon2_cost_t, uint32_t argon2_cost_m, uint32_t argon2_parallelism, uint32_t algo, uint32_t close_input_file, uint32_t close_output_file)
PWCRYPT_API uint32_t pwcrypt_get_version_nr()
PWCRYPT_API int pwcrypt_assess_password_strength(const uint8_t *password, size_t password_length)
PWCRYPT_API char * pwcrypt_get_version_nr_string()
static const char PWCRYPT_INVALID_ARGS_ERROR_MSG[]
Definition pwcrypt.h:47
PWCRYPT_API int pwcrypt_encrypt_file(const char *input_file_path, size_t input_file_path_length, uint32_t compress, const uint8_t *password, size_t password_length, uint32_t argon2_cost_t, uint32_t argon2_cost_m, uint32_t argon2_parallelism, uint32_t algo, const char *output_file_path, size_t output_file_path_length)
PWCRYPT_API void dev_urandom(uint8_t *output_buffer, size_t output_buffer_size)
PWCRYPT_API int pwcrypt_encrypt(const uint8_t *input, size_t input_length, uint32_t compress, const uint8_t *password, size_t password_length, uint32_t argon2_cost_t, uint32_t argon2_cost_m, uint32_t argon2_parallelism, uint32_t algo, uint8_t **output, size_t *output_length, uint32_t output_base64)
PWCRYPT_API unsigned char pwcrypt_is_fprintf_enabled()
PWCRYPT_API void pwcrypt_get_temp_filepath(char output_buffer[256])
PWCRYPT_API FILE * pwcrypt_fopen(const char *filename, const char *mode)