#ifndef GERBERA_H #define GERBERA_H #include #include #define GERBERA_MAGIC_SIZE 10 #define GERBERA_NONCE_SIZE 16 #define GERBERA_TAG_SIZE 16 #define GERBERA_BUFFER_SIZE 4096 #define GERBERA_HEADER_SIZE (GERBERA_MAGIC_SIZE + GERBERA_NONCE_SIZE + 8) #define GERBERA_OVERHEAD_SIZE (GERBERA_HEADER_SIZE + GERBERA_TAG_SIZE) typedef struct { uint8_t state[256]; uint8_t key[32]; uint8_t i; uint8_t j; uint64_t position; } GerberaCipher; typedef struct { uint8_t state[32]; uint64_t length; } GerberaAuth; void gerbera_cipher_init(GerberaCipher *ctx, const char *password, const uint8_t nonce[GERBERA_NONCE_SIZE]); void gerbera_cipher_apply(GerberaCipher *ctx, uint8_t data[], size_t length); void gerbera_auth_init(GerberaAuth *ctx, const char *password, const uint8_t nonce[GERBERA_NONCE_SIZE]); void gerbera_auth_update(GerberaAuth *ctx, const uint8_t data[], size_t length); void gerbera_auth_finish(GerberaAuth *ctx, uint8_t tag[GERBERA_TAG_SIZE]); int gerbera_constant_time_equal(const uint8_t a[], const uint8_t b[], size_t length); int encrypt_file(const char *input_path, const char *output_path, const char *password); int decrypt_file(const char *input_path, const char *output_path, const char *password); #endif